Minor checkedLineEdit fixes

* Do not disallow application if an invalid widget is disabled
* Fix coloring of text
This commit is contained in:
Juergen Spitzmueller 2022-12-11 10:01:09 +01:00
parent 6741a8fbf8
commit c7c3b39413
3 changed files with 17 additions and 8 deletions

View 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;

View 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"));

View 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);
}
}