Fix error background color for URLs

This commit is contained in:
Jonathan White 2020-07-19 09:59:40 -04:00
parent a88fe61a7b
commit c511cb518c
3 changed files with 7 additions and 6 deletions

View File

@ -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);

View File

@ -28,8 +28,6 @@ class URLEdit : public QLineEdit
Q_OBJECT
public:
static const QColor ErrorColor;
explicit URLEdit(QWidget* parent = nullptr);
void enableVerifyMode();

View File

@ -21,6 +21,7 @@
#include "core/Entry.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "gui/styles/StateColorPalette.h"
#include <algorithm>
@ -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) {