Fix stylesheet warnings introduced by 3b330ee2 (#3610)

Fixes regression introduced by 3b330ee.
The previous changes could add an invalid style
sheet to PasswordEdit's QLineEdit.
This commit is contained in:
Janek Bevendorff 2019-10-09 13:44:46 +02:00 committed by GitHub
parent a93b22f89a
commit ca0c4f5a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,14 +94,14 @@ bool PasswordEdit::passwordsEqual() const
void PasswordEdit::updateStylesheet() void PasswordEdit::updateStylesheet()
{ {
QString stylesheet("QLineEdit { background: %1; }"); const QString stylesheetTemplate("QLineEdit { background: %1; }");
if (m_basePasswordEdit && !passwordsEqual()) { if (m_basePasswordEdit && !passwordsEqual()) {
bool isCorrect = true; bool isCorrect = true;
if (m_basePasswordEdit->text().startsWith(text())) { if (m_basePasswordEdit->text().startsWith(text())) {
stylesheet = stylesheet.arg(CorrectSoFarColor.name()); setStyleSheet(stylesheetTemplate.arg(CorrectSoFarColor.name()));
} else { } else {
stylesheet = stylesheet.arg(ErrorColor.name()); setStyleSheet(stylesheetTemplate.arg(ErrorColor.name()));
isCorrect = false; isCorrect = false;
} }
m_correctAction->setVisible(isCorrect); m_correctAction->setVisible(isCorrect);
@ -109,9 +109,8 @@ void PasswordEdit::updateStylesheet()
} else { } else {
m_correctAction->setVisible(false); m_correctAction->setVisible(false);
m_errorAction->setVisible(false); m_errorAction->setVisible(false);
setStyleSheet("");
} }
setStyleSheet(stylesheet);
} }
void PasswordEdit::autocompletePassword(const QString& password) void PasswordEdit::autocompletePassword(const QString& password)