From da8b73244367c3c6c6ddd489222b030928740493 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Tue, 25 Apr 2017 03:01:39 +0200 Subject: [PATCH] Move mathindent from text layout to math settings as discussed --- src/frontends/qt4/GuiDocument.cpp | 116 ++++++++++++------------ src/frontends/qt4/ui/MathsUi.ui | 131 +++++++++++++++++++++++++-- src/frontends/qt4/ui/TextLayoutUi.ui | 84 +---------------- 3 files changed, 182 insertions(+), 149 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 353cd3214d..3b2fd56c2f 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -724,27 +724,6 @@ GuiDocument::GuiDocument(GuiView & lv) connect(textLayoutModule->justCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)), - this, SLOT(change_adaptor())); - connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)), - this, SLOT(allowMathIndent())); - connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)), - this, SLOT(change_adaptor())); - connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)), - this, SLOT(setMathIndent(int))); - connect(textLayoutModule->MathIndentLE, SIGNAL(textChanged(const QString &)), - this, SLOT(change_adaptor())); - connect(textLayoutModule->MathIndentLengthCO, SIGNAL(activated(int)), - this, SLOT(change_adaptor())); - - - textLayoutModule->MathIndentCO->addItem(qt_("Default")); - textLayoutModule->MathIndentCO->addItem(qt_("Custom")); - textLayoutModule->MathIndentLE->setValidator(new LengthValidator( - textLayoutModule->MathIndentLE)); - // initialize the length validator - bc().addCheckedLineEdit(textLayoutModule->MathIndentLE); - textLayoutModule->lspacingLE->setValidator(new QDoubleValidator( textLayoutModule->lspacingLE)); textLayoutModule->indentLE->setValidator(new LengthValidator( @@ -1282,6 +1261,26 @@ GuiDocument::GuiDocument(GuiView & lv) connect(mathsModule->MathNumberingPosCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)), + this, SLOT(change_adaptor())); + connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)), + this, SLOT(allowMathIndent())); + connect(mathsModule->MathIndentCO, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); + connect(mathsModule->MathIndentCO, SIGNAL(activated(int)), + this, SLOT(setMathIndent(int))); + connect(mathsModule->MathIndentLE, SIGNAL(textChanged(const QString &)), + this, SLOT(change_adaptor())); + connect(mathsModule->MathIndentLengthCO, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); + + + mathsModule->MathIndentCO->addItem(qt_("Default")); + mathsModule->MathIndentCO->addItem(qt_("Custom")); + mathsModule->MathIndentLE->setValidator(new LengthValidator( + mathsModule->MathIndentLE)); + // initialize the length validator + bc().addCheckedLineEdit(mathsModule->MathIndentLE); mathsModule->MathNumberingPosCO->addItem(qt_("Before")); mathsModule->MathNumberingPosCO->addItem(qt_("After")); mathsModule->MathNumberingPosCO->setCurrentIndex(2); @@ -1619,14 +1618,14 @@ void GuiDocument::enableSkip(bool skip) void GuiDocument::allowMathIndent() { // only disable when not checked, checked does not always allow enabling - if (!textLayoutModule->MathIndentCB->isChecked()) { - textLayoutModule->MathIndentLE->setEnabled(false); - textLayoutModule->MathIndentLengthCO->setEnabled(false); + if (!mathsModule->MathIndentCB->isChecked()) { + mathsModule->MathIndentLE->setEnabled(false); + mathsModule->MathIndentLengthCO->setEnabled(false); } - if (textLayoutModule->MathIndentCB->isChecked() - && textLayoutModule->MathIndentCO->currentIndex() == 1) { - textLayoutModule->MathIndentLE->setEnabled(true); - textLayoutModule->MathIndentLengthCO->setEnabled(true); + if (mathsModule->MathIndentCB->isChecked() + && mathsModule->MathIndentCO->currentIndex() == 1) { + mathsModule->MathIndentLE->setEnabled(true); + mathsModule->MathIndentLengthCO->setEnabled(true); } isValid(); } @@ -1634,8 +1633,8 @@ void GuiDocument::allowMathIndent() { void GuiDocument::setMathIndent(int item) { bool const enable = (item == 1); - textLayoutModule->MathIndentLE->setEnabled(enable); - textLayoutModule->MathIndentLengthCO->setEnabled(enable); + mathsModule->MathIndentLE->setEnabled(enable); + mathsModule->MathIndentLengthCO->setEnabled(enable); isValid(); } @@ -2921,13 +2920,31 @@ void GuiDocument::applyView() if (rb->isChecked()) bp_.use_package(it->first, BufferParams::package_off); } - bp_.is_math_indent = textLayoutModule->MathIndentCB->isChecked(); + bp_.is_math_indent = mathsModule->MathIndentCB->isChecked(); // if math is indented if (bp_.is_math_indent) { - Length mathindent(widgetsToLength(textLayoutModule->MathIndentLE, - textLayoutModule->MathIndentLengthCO)); + Length mathindent(widgetsToLength(mathsModule->MathIndentLE, + mathsModule->MathIndentLengthCO)); bp_.setMathIndent(mathindent); } + if (mathsModule->MathIndentCB->isChecked()) { + // if formulas are indented + switch (mathsModule->MathIndentCO->currentIndex()) { + case 0: + bp_.setMathIndent(Length()); + break; + case 1: { + Length mathindent(widgetsToLength(mathsModule->MathIndentLE, + mathsModule->MathIndentLengthCO)); + bp_.setMathIndent(mathindent); + break; + } + default: + // this should never happen + bp_.setMathIndent(Length()); + break; + } + } switch (mathsModule->MathNumberingPosCO->currentIndex()) { case 0: bp_.math_number_before = true; @@ -3026,25 +3043,6 @@ void GuiDocument::applyView() } } - if (textLayoutModule->MathIndentCB->isChecked()) { - // if formulas are indented - switch (textLayoutModule->MathIndentCO->currentIndex()) { - case 0: - bp_.setMathIndent(Length()); - break; - case 1: { - Length mathindent(widgetsToLength(textLayoutModule->MathIndentLE, - textLayoutModule->MathIndentLengthCO)); - bp_.setMathIndent(mathindent); - break; - } - default: - // this should never happen - bp_.setMathIndent(Length()); - break; - } - } - bp_.options = fromqstr(latexModule->optionsLE->text()); @@ -3410,16 +3408,16 @@ void GuiDocument::paramsToDialog() // math if (bp_.is_math_indent) { - textLayoutModule->MathIndentCB->setChecked(bp_.is_math_indent); + mathsModule->MathIndentCB->setChecked(bp_.is_math_indent); Length const mathindent = bp_.getMathIndent(); int indent = 0; if (!mathindent.empty()) { - lengthToWidgets(textLayoutModule->MathIndentLE, - textLayoutModule->MathIndentLengthCO, + lengthToWidgets(mathsModule->MathIndentLE, + mathsModule->MathIndentLengthCO, mathindent, default_unit); indent = 1; } - textLayoutModule->MathIndentCO->setCurrentIndex(indent); + mathsModule->MathIndentCO->setCurrentIndex(indent); setMathIndent(indent); } if (bp_.math_number_before) @@ -4094,11 +4092,11 @@ bool GuiDocument::isValid() ) && ( // if we're asking for indentation - !textLayoutModule->MathIndentCB->isChecked() || + !mathsModule->MathIndentCB->isChecked() || // then either we haven't chosen custom - textLayoutModule->MathIndentCO->currentIndex() != 1 || + mathsModule->MathIndentCO->currentIndex() != 1 || // or else a length has been given - !textLayoutModule->MathIndentLE->text().isEmpty() + !mathsModule->MathIndentLE->text().isEmpty() ); } diff --git a/src/frontends/qt4/ui/MathsUi.ui b/src/frontends/qt4/ui/MathsUi.ui index ec3e8c453e..e776e7875c 100644 --- a/src/frontends/qt4/ui/MathsUi.ui +++ b/src/frontends/qt4/ui/MathsUi.ui @@ -21,28 +21,109 @@ - + Load A&utomatically - + Load Alwa&ys - + Do &Not Load - + + + + Indent displayed formulas instead of centering + + + Indent &Formulas + + + + + + + false + + + + 0 + 0 + + + + Size of the indentation + + + + + + + Qt::Horizontal + + + + 234 + 20 + + + + + + + + false + + + + + + + + + + + + + false + + + + 0 + 0 + + + + + + + + + + + Qt::Horizontal + + + + 153 + 20 + + + + + @@ -55,30 +136,36 @@ - + true + + + 0 + 0 + + Size of the indentation - + Qt::Horizontal - 268 - 20 + 234 + 17 - + @@ -103,9 +190,33 @@ + + + lyx::frontend::LengthCombo + QComboBox +
LengthCombo.h
+
+
qt_i18n.h - + + + MathIndentCB + toggled(bool) + MathIndentCO + setEnabled(bool) + + + 66 + 291 + + + 164 + 290 + + + + diff --git a/src/frontends/qt4/ui/TextLayoutUi.ui b/src/frontends/qt4/ui/TextLayoutUi.ui index 59f063957f..f300bb5447 100644 --- a/src/frontends/qt4/ui/TextLayoutUi.ui +++ b/src/frontends/qt4/ui/TextLayoutUi.ui @@ -14,7 +14,7 @@ - + Paragraph Separation @@ -185,7 +185,7 @@
- + @@ -285,66 +285,7 @@ - - - - false - - - Size of the indentation - - - - - - - Qt::Horizontal - - - - 203 - 20 - - - - - - - - false - - - - - - - - - - - - - false - - - - - - - - - - Qt::Horizontal - - - - 79 - 20 - - - - - + Qt::Vertical @@ -385,22 +326,5 @@ qt_i18n.h - - - MathIndentCB - toggled(bool) - MathIndentCO - setEnabled(bool) - - - 59 - 274 - - - 182 - 270 - - - - + -- 2.39.5