From 7986fd3e316a7db0b26cfac4a22f68b64b52f79f Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Mon, 14 May 2012 20:24:00 +0200 Subject: [PATCH] Use stylesheets to color the password edit background. --- src/gui/EditEntryWidget.cpp | 13 +++++++------ src/gui/EditEntryWidget.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/EditEntryWidget.cpp b/src/gui/EditEntryWidget.cpp index 2a3d81327..35c28817a 100644 --- a/src/gui/EditEntryWidget.cpp +++ b/src/gui/EditEntryWidget.cpp @@ -125,7 +125,6 @@ EditEntryWidget::~EditEntryWidget() { } -const QColor EditEntryWidget::NormalColor = Qt::white; const QColor EditEntryWidget::CorrectSoFarColor = QColor(255, 205, 15); const QColor EditEntryWidget::ErrorColor = QColor(255, 125, 125); @@ -282,19 +281,21 @@ bool EditEntryWidget::passwordsEqual() void EditEntryWidget::setPasswordCheckColors() { - QPalette pal; if (passwordsEqual()) { - pal.setColor(QPalette::Base, NormalColor); + m_mainUi->passwordRepeatEdit->setStyleSheet(""); } else { + QString stylesheet = "QLineEdit { background: %1; }"; + if (m_mainUi->passwordEdit->text().startsWith(m_mainUi->passwordRepeatEdit->text())) { - pal.setColor(QPalette::Base, CorrectSoFarColor); + stylesheet = stylesheet.arg(CorrectSoFarColor.name()); } else { - pal.setColor(QPalette::Base, ErrorColor); + stylesheet = stylesheet.arg(ErrorColor.name()); } + + m_mainUi->passwordRepeatEdit->setStyleSheet(stylesheet); } - m_mainUi->passwordRepeatEdit->setPalette(pal); } void EditEntryWidget::insertAttribute() diff --git a/src/gui/EditEntryWidget.h b/src/gui/EditEntryWidget.h index 7b766fd09..03a6514a3 100644 --- a/src/gui/EditEntryWidget.h +++ b/src/gui/EditEntryWidget.h @@ -52,7 +52,6 @@ public: void loadEntry(Entry* entry, bool create, const QString& groupName, Database* database); - static const QColor NormalColor; static const QColor CorrectSoFarColor; static const QColor ErrorColor;