From c511cb518cbd8c4aeb9d2fff1b980013919356c5 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 19 Jul 2020 09:59:40 -0400 Subject: [PATCH] Fix error background color for URLs --- src/gui/URLEdit.cpp | 7 ++++--- src/gui/URLEdit.h | 2 -- src/gui/entry/EntryURLModel.cpp | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/URLEdit.cpp b/src/gui/URLEdit.cpp index 428a918db..4880b6221 100644 --- a/src/gui/URLEdit.cpp +++ b/src/gui/URLEdit.cpp @@ -24,8 +24,7 @@ #include "core/Resources.h" #include "core/Tools.h" #include "gui/Font.h" - -const QColor URLEdit::ErrorColor = QColor(255, 125, 125); +#include "gui/styles/StateColorPalette.h" URLEdit::URLEdit(QWidget* parent) : QLineEdit(parent) @@ -50,7 +49,9 @@ void URLEdit::updateStylesheet() const QString stylesheetTemplate("QLineEdit { background: %1; }"); if (!Tools::checkUrlValid(text())) { - setStyleSheet(stylesheetTemplate.arg(ErrorColor.name())); + StateColorPalette statePalette; + QColor color = statePalette.color(StateColorPalette::ColorRole::Error); + setStyleSheet(stylesheetTemplate.arg(color.name())); m_errorAction->setVisible(true); } else { m_errorAction->setVisible(false); diff --git a/src/gui/URLEdit.h b/src/gui/URLEdit.h index 11b743b41..a852f2664 100644 --- a/src/gui/URLEdit.h +++ b/src/gui/URLEdit.h @@ -28,8 +28,6 @@ class URLEdit : public QLineEdit Q_OBJECT public: - static const QColor ErrorColor; - explicit URLEdit(QWidget* parent = nullptr); void enableVerifyMode(); diff --git a/src/gui/entry/EntryURLModel.cpp b/src/gui/entry/EntryURLModel.cpp index 7bf673a99..522185d28 100644 --- a/src/gui/entry/EntryURLModel.cpp +++ b/src/gui/entry/EntryURLModel.cpp @@ -21,6 +21,7 @@ #include "core/Entry.h" #include "core/Resources.h" #include "core/Tools.h" +#include "gui/styles/StateColorPalette.h" #include @@ -70,7 +71,8 @@ QVariant EntryURLModel::data(const QModelIndex& index, int role) const const auto urlValid = Tools::checkUrlValid(value); if (role == Qt::BackgroundRole && !urlValid) { - return QColor(255, 125, 125); + StateColorPalette statePalette; + return statePalette.color(StateColorPalette::ColorRole::Error); } else if (role == Qt::DecorationRole && !urlValid) { return m_errorIcon; } else if (role == Qt::DisplayRole || role == Qt::EditRole) {