]> git.lyx.org Git - features.git/commitdiff
Minor checkedLineEdit fixes
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 11 Dec 2022 09:01:09 +0000 (10:01 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 11 Dec 2022 09:01:09 +0000 (10:01 +0100)
* Do not disallow application if an invalid widget is disabled
* Fix coloring of text

src/frontends/qt/ButtonController.cpp
src/frontends/qt/GuiDocument.cpp
src/frontends/qt/qt_helpers.cpp

index 85facfd68870514d0a9747fde835bf2f4b33a73d..47d9c7e615eb24e445e573fa602acf6cb964a652 100644 (file)
@@ -53,6 +53,13 @@ CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
 
 bool CheckedLineEdit::check() const
 {
+       if (!input_->isEnabled()) {
+               // we do not check diabled widgets
+               if (label_)
+                       setValid(label_, true);
+               return true;
+       }
+
        QValidator const * validator = input_->validator();
        if (!validator)
                return true;
index 4bfda55f468d76f839759c6a1206dde438eb37d6..beaed5cf9b7edd9a3bb84faedd3700e58783dc94 100644 (file)
@@ -876,8 +876,8 @@ GuiDocument::GuiDocument(GuiView & lv)
        textLayoutModule->lspacingCO->insertItem(
                Spacing::Other, qt_("Custom"));
        // initialize the length validator
-       bc().addCheckedLineEdit(textLayoutModule->indentLE);
-       bc().addCheckedLineEdit(textLayoutModule->skipLE);
+       bc().addCheckedLineEdit(textLayoutModule->indentLE, textLayoutModule->indentRB);
+       bc().addCheckedLineEdit(textLayoutModule->skipLE, textLayoutModule->skipRB);
 
        textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default"));
        getTableStyles();
@@ -937,7 +937,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        outputModule->synccustomCB->addItem("\\synctex=-1");
        outputModule->synccustomCB->addItem("\\usepackage[active]{srcltx}");
 
-       outputModule->synccustomCB->setValidator(new NoNewLineValidator(
+       outputModule->synccustomCB->lineEdit()->setValidator(new NoNewLineValidator(
                outputModule->synccustomCB));
 
        connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
@@ -1522,14 +1522,14 @@ 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)),
+       connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
                this, SLOT(change_adaptor()));
        connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
                this, SLOT(enableMathIndent(int)));
+       connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
+               this, SLOT(change_adaptor()));
        connect(mathsModule->MathIndentLE, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
        connect(mathsModule->MathIndentLengthCO, SIGNAL(activated(int)),
@@ -1541,7 +1541,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        mathsModule->MathIndentLE->setValidator(new LengthValidator(
                mathsModule->MathIndentLE));
        // initialize the length validator
-       bc().addCheckedLineEdit(mathsModule->MathIndentLE);
+       bc().addCheckedLineEdit(mathsModule->MathIndentLE, mathsModule->MathIndentCB);
        mathsModule->MathNumberingPosCO->addItem(qt_("Left"));
        mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
        mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
index 6891c3088a8a7615be6657fd4910929c2cc88eee..2657f3d6bc35a5d437603e7268f0344040226251 100644 (file)
@@ -239,10 +239,12 @@ void setValid(QWidget * widget, bool valid)
                if (qobject_cast<QCheckBox*>(widget) != nullptr) {
                        // Check boxes need to be treated differenty, see
                        // https://forum.qt.io/topic/93253/
-                       widget->setStyleSheet("QCheckBox:unchecked{ color: red; }QCheckBox:checked{ color: red; }");
+                       if (qobject_cast<QCheckBox*>(widget)->isChecked())
+                               widget->setStyleSheet("QCheckBox:unchecked{ color: red; }QCheckBox:checked{ color: red; }");
                } else {
                        QPalette pal = widget->palette();
                        pal.setColor(QPalette::Active, QPalette::WindowText, QColor(255, 0, 0));
+                       pal.setColor(QPalette::Active, QPalette::Text, QColor(255, 0, 0));
                        widget->setPalette(pal);
                }
        }