|
|
|
@@ -313,129 +313,156 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) :
|
|
|
|
|
drag_enabled_(false)
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout *outer_layout = new QVBoxLayout(this);
|
|
|
|
|
outer_layout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *basic_layout = new QHBoxLayout();
|
|
|
|
|
outer_layout->addLayout(basic_layout);
|
|
|
|
|
const int advanced_slider_width = QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("9999.9%"));
|
|
|
|
|
|
|
|
|
|
int advanced_slider_width = QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("9999.9%"));
|
|
|
|
|
{
|
|
|
|
|
QHBoxLayout *row_layout = new QHBoxLayout();
|
|
|
|
|
row_layout->setSpacing(0);
|
|
|
|
|
outer_layout->addLayout(row_layout);
|
|
|
|
|
|
|
|
|
|
font_combo_ = new QFontComboBox();
|
|
|
|
|
connect(font_combo_, &QFontComboBox::currentTextChanged, this, &ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged);
|
|
|
|
|
basic_layout->addWidget(font_combo_);
|
|
|
|
|
font_combo_ = new QFontComboBox();
|
|
|
|
|
connect(font_combo_, &QFontComboBox::currentTextChanged, this, &ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged);
|
|
|
|
|
row_layout->addWidget(font_combo_);
|
|
|
|
|
|
|
|
|
|
font_sz_slider_ = new FloatSlider();
|
|
|
|
|
font_sz_slider_->SetMinimum(0.1);
|
|
|
|
|
font_sz_slider_->SetMaximum(9999.9);
|
|
|
|
|
font_sz_slider_->SetDecimalPlaces(1);
|
|
|
|
|
font_sz_slider_->SetAlignment(Qt::AlignCenter);
|
|
|
|
|
font_sz_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
connect(font_sz_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::SizeChanged);
|
|
|
|
|
font_sz_slider_->SetLadderElementCount(2);
|
|
|
|
|
basic_layout->addWidget(font_sz_slider_);
|
|
|
|
|
font_sz_slider_ = new FloatSlider();
|
|
|
|
|
font_sz_slider_->SetMinimum(0.1);
|
|
|
|
|
font_sz_slider_->SetMaximum(9999.9);
|
|
|
|
|
font_sz_slider_->SetDecimalPlaces(1);
|
|
|
|
|
font_sz_slider_->SetAlignment(Qt::AlignCenter);
|
|
|
|
|
font_sz_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
connect(font_sz_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::SizeChanged);
|
|
|
|
|
font_sz_slider_->SetLadderElementCount(2);
|
|
|
|
|
row_layout->addWidget(font_sz_slider_);
|
|
|
|
|
|
|
|
|
|
style_combo_ = new QComboBox();
|
|
|
|
|
connect(style_combo_, &QComboBox::currentTextChanged, this, &ViewerTextEditorToolBar::StyleChanged);
|
|
|
|
|
basic_layout->addWidget(style_combo_);
|
|
|
|
|
style_combo_ = new QComboBox();
|
|
|
|
|
connect(style_combo_, &QComboBox::currentTextChanged, this, &ViewerTextEditorToolBar::StyleChanged);
|
|
|
|
|
row_layout->addWidget(style_combo_);
|
|
|
|
|
|
|
|
|
|
underline_btn_ = new QPushButton();
|
|
|
|
|
connect(underline_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::UnderlineChanged);
|
|
|
|
|
underline_btn_->setCheckable(true);
|
|
|
|
|
underline_btn_->setIcon(icon::TextUnderline);
|
|
|
|
|
basic_layout->addWidget(underline_btn_);
|
|
|
|
|
underline_btn_ = new QPushButton();
|
|
|
|
|
connect(underline_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::UnderlineChanged);
|
|
|
|
|
underline_btn_->setCheckable(true);
|
|
|
|
|
underline_btn_->setIcon(icon::TextUnderline);
|
|
|
|
|
row_layout->addWidget(underline_btn_);
|
|
|
|
|
|
|
|
|
|
strikethrough_btn_ = new QPushButton();
|
|
|
|
|
connect(strikethrough_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::StrikethroughChanged);
|
|
|
|
|
strikethrough_btn_->setCheckable(true);
|
|
|
|
|
strikethrough_btn_->setIcon(icon::TextStrikethrough);
|
|
|
|
|
basic_layout->addWidget(strikethrough_btn_);
|
|
|
|
|
strikethrough_btn_ = new QPushButton();
|
|
|
|
|
connect(strikethrough_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::StrikethroughChanged);
|
|
|
|
|
strikethrough_btn_->setCheckable(true);
|
|
|
|
|
strikethrough_btn_->setIcon(icon::TextStrikethrough);
|
|
|
|
|
row_layout->addWidget(strikethrough_btn_);
|
|
|
|
|
|
|
|
|
|
basic_layout->addWidget(QtUtils::CreateVerticalLine());
|
|
|
|
|
AddSpacer(row_layout);
|
|
|
|
|
|
|
|
|
|
align_left_btn_ = new QPushButton();
|
|
|
|
|
align_left_btn_->setCheckable(true);
|
|
|
|
|
align_left_btn_->setIcon(icon::TextAlignLeft);
|
|
|
|
|
connect(align_left_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignLeft);});
|
|
|
|
|
basic_layout->addWidget(align_left_btn_);
|
|
|
|
|
color_btn_ = new QPushButton();
|
|
|
|
|
color_btn_->setAutoFillBackground(true);
|
|
|
|
|
connect(color_btn_, &QPushButton::clicked, this, [this]{
|
|
|
|
|
QColor c = color_btn_->property("color").value<QColor>();
|
|
|
|
|
|
|
|
|
|
align_center_btn_ = new QPushButton();
|
|
|
|
|
align_center_btn_->setCheckable(true);
|
|
|
|
|
align_center_btn_->setIcon(icon::TextAlignCenter);
|
|
|
|
|
connect(align_center_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignCenter);});
|
|
|
|
|
basic_layout->addWidget(align_center_btn_);
|
|
|
|
|
QColorDialog cd(c, this);
|
|
|
|
|
if (cd.exec() == QDialog::Accepted) {
|
|
|
|
|
c = cd.selectedColor();
|
|
|
|
|
SetColor(c);
|
|
|
|
|
emit ColorChanged(c);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
row_layout->addWidget(color_btn_);
|
|
|
|
|
|
|
|
|
|
align_right_btn_ = new QPushButton();
|
|
|
|
|
align_right_btn_->setCheckable(true);
|
|
|
|
|
align_right_btn_->setIcon(icon::TextAlignRight);
|
|
|
|
|
connect(align_right_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignRight);});
|
|
|
|
|
basic_layout->addWidget(align_right_btn_);
|
|
|
|
|
row_layout->addStretch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
align_justify_btn_ = new QPushButton();
|
|
|
|
|
align_justify_btn_->setCheckable(true);
|
|
|
|
|
align_justify_btn_->setIcon(icon::TextAlignJustify);
|
|
|
|
|
connect(align_justify_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignJustify);});
|
|
|
|
|
basic_layout->addWidget(align_justify_btn_);
|
|
|
|
|
{
|
|
|
|
|
QHBoxLayout *row_layout = new QHBoxLayout();
|
|
|
|
|
row_layout->setSpacing(0);
|
|
|
|
|
outer_layout->addLayout(row_layout);
|
|
|
|
|
|
|
|
|
|
basic_layout->addWidget(QtUtils::CreateVerticalLine());
|
|
|
|
|
align_left_btn_ = new QPushButton();
|
|
|
|
|
align_left_btn_->setCheckable(true);
|
|
|
|
|
align_left_btn_->setIcon(icon::TextAlignLeft);
|
|
|
|
|
connect(align_left_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignLeft);});
|
|
|
|
|
row_layout->addWidget(align_left_btn_);
|
|
|
|
|
|
|
|
|
|
color_btn_ = new QPushButton();
|
|
|
|
|
color_btn_->setAutoFillBackground(true);
|
|
|
|
|
connect(color_btn_, &QPushButton::clicked, this, [this]{
|
|
|
|
|
QColor c = color_btn_->property("color").value<QColor>();
|
|
|
|
|
align_center_btn_ = new QPushButton();
|
|
|
|
|
align_center_btn_->setCheckable(true);
|
|
|
|
|
align_center_btn_->setIcon(icon::TextAlignCenter);
|
|
|
|
|
connect(align_center_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignHCenter);});
|
|
|
|
|
row_layout->addWidget(align_center_btn_);
|
|
|
|
|
|
|
|
|
|
QColorDialog cd(c, this);
|
|
|
|
|
if (cd.exec() == QDialog::Accepted) {
|
|
|
|
|
c = cd.selectedColor();
|
|
|
|
|
SetColor(c);
|
|
|
|
|
emit ColorChanged(c);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
basic_layout->addWidget(color_btn_);
|
|
|
|
|
align_right_btn_ = new QPushButton();
|
|
|
|
|
align_right_btn_->setCheckable(true);
|
|
|
|
|
align_right_btn_->setIcon(icon::TextAlignRight);
|
|
|
|
|
connect(align_right_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignRight);});
|
|
|
|
|
row_layout->addWidget(align_right_btn_);
|
|
|
|
|
|
|
|
|
|
basic_layout->addStretch();
|
|
|
|
|
align_justify_btn_ = new QPushButton();
|
|
|
|
|
align_justify_btn_->setCheckable(true);
|
|
|
|
|
align_justify_btn_->setIcon(icon::TextAlignJustify);
|
|
|
|
|
connect(align_justify_btn_, &QPushButton::clicked, this, [this]{emit AlignmentChanged(Qt::AlignJustify);});
|
|
|
|
|
row_layout->addWidget(align_justify_btn_);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *advanced_layout = new QHBoxLayout();
|
|
|
|
|
outer_layout->addLayout(advanced_layout);
|
|
|
|
|
AddSpacer(row_layout);
|
|
|
|
|
|
|
|
|
|
advanced_layout->addWidget(new QLabel(tr("Stretch: "))); // FIXME: Procure icon
|
|
|
|
|
align_top_btn_ = new QPushButton();
|
|
|
|
|
align_top_btn_->setCheckable(true);
|
|
|
|
|
align_top_btn_->setIcon(icon::TextAlignTop);
|
|
|
|
|
connect(align_top_btn_, &QPushButton::clicked, this, [this]{emit VerticalAlignmentChanged(Qt::AlignTop);});
|
|
|
|
|
row_layout->addWidget(align_top_btn_);
|
|
|
|
|
|
|
|
|
|
stretch_slider_ = new IntegerSlider();
|
|
|
|
|
stretch_slider_->SetMinimum(0);
|
|
|
|
|
stretch_slider_->SetDefaultValue(100);
|
|
|
|
|
stretch_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
stretch_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(stretch_slider_, &IntegerSlider::ValueChanged, this, &ViewerTextEditorToolBar::StretchChanged);
|
|
|
|
|
advanced_layout->addWidget(stretch_slider_);
|
|
|
|
|
align_middle_btn_ = new QPushButton();
|
|
|
|
|
align_middle_btn_->setCheckable(true);
|
|
|
|
|
align_middle_btn_->setIcon(icon::TextAlignMiddle);
|
|
|
|
|
connect(align_middle_btn_, &QPushButton::clicked, this, [this]{emit VerticalAlignmentChanged(Qt::AlignVCenter);});
|
|
|
|
|
row_layout->addWidget(align_middle_btn_);
|
|
|
|
|
|
|
|
|
|
advanced_layout->addWidget(new QLabel(tr("Kerning: "))); // FIXME: Procure icon
|
|
|
|
|
align_bottom_btn_ = new QPushButton();
|
|
|
|
|
align_bottom_btn_->setCheckable(true);
|
|
|
|
|
align_bottom_btn_->setIcon(icon::TextAlignBottom);
|
|
|
|
|
connect(align_bottom_btn_, &QPushButton::clicked, this, [this]{emit VerticalAlignmentChanged(Qt::AlignBottom);});
|
|
|
|
|
row_layout->addWidget(align_bottom_btn_);
|
|
|
|
|
|
|
|
|
|
kerning_slider_ = new FloatSlider();
|
|
|
|
|
kerning_slider_->SetMinimum(0);
|
|
|
|
|
kerning_slider_->SetDefaultValue(100);
|
|
|
|
|
kerning_slider_->SetDecimalPlaces(1);
|
|
|
|
|
kerning_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
kerning_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(kerning_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::KerningChanged);
|
|
|
|
|
advanced_layout->addWidget(kerning_slider_);
|
|
|
|
|
AddSpacer(row_layout);
|
|
|
|
|
|
|
|
|
|
advanced_layout->addWidget(new QLabel(tr("Line Height: "))); // FIXME: Procure icon
|
|
|
|
|
small_caps_btn_ = new QPushButton();
|
|
|
|
|
small_caps_btn_->setIcon(icon::TextSmallCaps);
|
|
|
|
|
small_caps_btn_->setCheckable(true);
|
|
|
|
|
connect(small_caps_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::SmallCapsChanged);
|
|
|
|
|
row_layout->addWidget(small_caps_btn_);
|
|
|
|
|
|
|
|
|
|
line_height_slider_ = new FloatSlider();
|
|
|
|
|
line_height_slider_->SetMinimum(0);
|
|
|
|
|
line_height_slider_->SetDefaultValue(100);
|
|
|
|
|
line_height_slider_->SetDecimalPlaces(1);
|
|
|
|
|
line_height_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
line_height_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(line_height_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::LineHeightChanged);
|
|
|
|
|
advanced_layout->addWidget(line_height_slider_);
|
|
|
|
|
AddSpacer(row_layout);
|
|
|
|
|
|
|
|
|
|
small_caps_btn_ = new QPushButton();
|
|
|
|
|
small_caps_btn_->setIcon(icon::TextSmallCaps);
|
|
|
|
|
small_caps_btn_->setCheckable(true);
|
|
|
|
|
connect(small_caps_btn_, &QPushButton::clicked, this, &ViewerTextEditorToolBar::SmallCapsChanged);
|
|
|
|
|
advanced_layout->addWidget(small_caps_btn_);
|
|
|
|
|
row_layout->addWidget(new QLabel(tr("Stretch: "))); // FIXME: Procure icon
|
|
|
|
|
|
|
|
|
|
advanced_layout->addStretch();
|
|
|
|
|
stretch_slider_ = new IntegerSlider();
|
|
|
|
|
stretch_slider_->SetMinimum(0);
|
|
|
|
|
stretch_slider_->SetDefaultValue(100);
|
|
|
|
|
stretch_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
stretch_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(stretch_slider_, &IntegerSlider::ValueChanged, this, &ViewerTextEditorToolBar::StretchChanged);
|
|
|
|
|
row_layout->addWidget(stretch_slider_);
|
|
|
|
|
|
|
|
|
|
row_layout->addWidget(new QLabel(tr("Kerning: "))); // FIXME: Procure icon
|
|
|
|
|
|
|
|
|
|
kerning_slider_ = new FloatSlider();
|
|
|
|
|
kerning_slider_->SetMinimum(0);
|
|
|
|
|
kerning_slider_->SetDefaultValue(100);
|
|
|
|
|
kerning_slider_->SetDecimalPlaces(1);
|
|
|
|
|
kerning_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
kerning_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(kerning_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::KerningChanged);
|
|
|
|
|
row_layout->addWidget(kerning_slider_);
|
|
|
|
|
|
|
|
|
|
row_layout->addWidget(new QLabel(tr("Line Height: "))); // FIXME: Procure icon
|
|
|
|
|
|
|
|
|
|
line_height_slider_ = new FloatSlider();
|
|
|
|
|
line_height_slider_->SetMinimum(0);
|
|
|
|
|
line_height_slider_->SetDefaultValue(100);
|
|
|
|
|
line_height_slider_->SetDecimalPlaces(1);
|
|
|
|
|
line_height_slider_->setFixedWidth(advanced_slider_width);
|
|
|
|
|
line_height_slider_->SetFormat(tr("%1%"));
|
|
|
|
|
connect(line_height_slider_, &FloatSlider::ValueChanged, this, &ViewerTextEditorToolBar::LineHeightChanged);
|
|
|
|
|
row_layout->addWidget(line_height_slider_);
|
|
|
|
|
|
|
|
|
|
row_layout->addStretch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setAutoFillBackground(true);
|
|
|
|
|
|
|
|
|
@@ -445,7 +472,7 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) :
|
|
|
|
|
void ViewerTextEditorToolBar::SetAlignment(Qt::Alignment a)
|
|
|
|
|
{
|
|
|
|
|
align_left_btn_->setChecked(a == Qt::AlignLeft);
|
|
|
|
|
align_center_btn_->setChecked(a == Qt::AlignCenter);
|
|
|
|
|
align_center_btn_->setChecked(a == Qt::AlignHCenter);
|
|
|
|
|
align_right_btn_->setChecked(a == Qt::AlignRight);
|
|
|
|
|
align_justify_btn_->setChecked(a == Qt::AlignJustify);
|
|
|
|
|
}
|
|
|
|
@@ -470,6 +497,20 @@ void ViewerTextEditorToolBar::paintEvent(QPaintEvent *event)
|
|
|
|
|
QWidget::paintEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewerTextEditorToolBar::AddSpacer(QLayout *l)
|
|
|
|
|
{
|
|
|
|
|
const int spacing = this->fontMetrics().height()/4;
|
|
|
|
|
QWidget *a = new QWidget();
|
|
|
|
|
a->setFixedSize(spacing, 1);
|
|
|
|
|
l->addWidget(a);
|
|
|
|
|
|
|
|
|
|
l->addWidget(QtUtils::CreateVerticalLine());
|
|
|
|
|
|
|
|
|
|
QWidget *b = new QWidget();
|
|
|
|
|
b->setFixedSize(spacing, 1);
|
|
|
|
|
l->addWidget(b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family)
|
|
|
|
|
{
|
|
|
|
|
QString temp = style_combo_->currentText();
|
|
|
|
|