refactor: centralize hardcoded color values into Colors namespace
Add src/util/colors.hpp with named constants for all QColor values (brand accents, badge colors, text shades, surface backgrounds) and replace scattered QColor constructor calls across 7 source files. Stylesheet string colors are intentionally left inline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "view.hpp"
|
||||
#include "../../util/colors.hpp"
|
||||
#include "../../util/trackinfo.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
@@ -125,7 +126,7 @@ void SearchTab::onMostPopularResult(const QJsonObject &result)
|
||||
const QString artist = content["performer"].toObject()["name"].toString();
|
||||
const QString album = content["album"].toObject()["title"].toString();
|
||||
item->setText(0, QStringLiteral("T"));
|
||||
item->setForeground(0, QColor(QStringLiteral("#2FA84F")));
|
||||
item->setForeground(0, Colors::BadgeGreen);
|
||||
item->setFont(0, badgeFont);
|
||||
item->setTextAlignment(0, Qt::AlignCenter);
|
||||
item->setText(1, title);
|
||||
@@ -139,8 +140,8 @@ void SearchTab::onMostPopularResult(const QJsonObject &result)
|
||||
|| content["rights"].toObject()["hires_streamable"].toBool();
|
||||
item->setText(0, hiRes ? QStringLiteral("H") : QStringLiteral("A"));
|
||||
item->setForeground(0, hiRes
|
||||
? QColor(QStringLiteral("#FFB232"))
|
||||
: QColor(QStringLiteral("#8E8E93")));
|
||||
? Colors::QobuzOrange
|
||||
: Colors::BadgeGray);
|
||||
item->setFont(0, badgeFont);
|
||||
item->setTextAlignment(0, Qt::AlignCenter);
|
||||
item->setText(1, title);
|
||||
@@ -149,7 +150,7 @@ void SearchTab::onMostPopularResult(const QJsonObject &result)
|
||||
item->setData(1, IdRole, content["id"].toString());
|
||||
} else if (type == QStringLiteral("artists")) {
|
||||
item->setText(0, QStringLiteral("A"));
|
||||
item->setForeground(0, QColor(QStringLiteral("#2B7CD3")));
|
||||
item->setForeground(0, Colors::BadgeBlue);
|
||||
item->setFont(0, badgeFont);
|
||||
item->setTextAlignment(0, Qt::AlignCenter);
|
||||
item->setText(1, content["name"].toString());
|
||||
@@ -193,7 +194,7 @@ void SearchTab::onSearchResult(const QJsonObject &result)
|
||||
QStringList{QString(), a["title"].toString(), artist});
|
||||
if (hiRes) {
|
||||
item->setText(0, QStringLiteral("H"));
|
||||
item->setForeground(0, QColor(QStringLiteral("#FFB232")));
|
||||
item->setForeground(0, Colors::QobuzOrange);
|
||||
item->setFont(0, hiResFont);
|
||||
item->setTextAlignment(0, Qt::AlignCenter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user