[LyX/master] Minor checkedLineEdit fixes

Juergen Spitzmueller spitz at lyx.org
Sun Dec 11 08:06:08 UTC 2022


commit c7c3b394131819707b650628260b6794ab4ef571
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Dec 11 10:01:09 2022 +0100

    Minor checkedLineEdit fixes
    
    * Do not disallow application if an invalid widget is disabled
    * Fix coloring of text
---
 src/frontends/qt/ButtonController.cpp |    7 +++++++
 src/frontends/qt/GuiDocument.cpp      |   14 +++++++-------
 src/frontends/qt/qt_helpers.cpp       |    4 +++-
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/frontends/qt/ButtonController.cpp b/src/frontends/qt/ButtonController.cpp
index 85facfd..47d9c7e 100644
--- a/src/frontends/qt/ButtonController.cpp
+++ b/src/frontends/qt/ButtonController.cpp
@@ -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;
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 4bfda55..beaed5c 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -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()),
@@ -1523,13 +1523,13 @@ GuiDocument::GuiDocument(GuiView & lv)
 		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"));
diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index 6891c30..2657f3d 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -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);
 		}
 	}


More information about the lyx-cvs mailing list