fix: placeholder text color and H badge in search album results
- Add QPalette::PlaceholderText (#8C8C8C) to the dark palette so placeholder text in search box and settings fields is readable - Add H column to search album results (same gold badge as album list view) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QHeaderView>
|
||||
#include <QFont>
|
||||
#include <QJsonArray>
|
||||
|
||||
static constexpr int IdRole = Qt::UserRole + 1;
|
||||
@@ -38,8 +40,12 @@ SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
||||
m_trackResults->setRootIsDecorated(false);
|
||||
|
||||
m_albumResults = new QTreeWidget(this);
|
||||
m_albumResults->setHeaderLabels({tr("Album"), tr("Artist")});
|
||||
m_albumResults->setHeaderLabels({tr(""), tr("Album"), tr("Artist")});
|
||||
m_albumResults->setRootIsDecorated(false);
|
||||
m_albumResults->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_albumResults->header()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
m_albumResults->header()->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||
m_albumResults->header()->setStretchLastSection(false);
|
||||
|
||||
m_artistResults = new QTreeWidget(this);
|
||||
m_artistResults->setHeaderLabels({tr("Artist")});
|
||||
@@ -84,14 +90,28 @@ void SearchTab::onSearchResult(const QJsonObject &result)
|
||||
|
||||
// Populate albums
|
||||
m_albumResults->clear();
|
||||
const QJsonArray albums = result["albums"].toObject()["items"].toArray();
|
||||
for (const auto &v : albums) {
|
||||
const QJsonObject a = v.toObject();
|
||||
const QString artist = a["artist"].toObject()["name"].toString();
|
||||
auto *item = new QTreeWidgetItem(m_albumResults,
|
||||
QStringList{a["title"].toString(), artist});
|
||||
item->setData(0, IdRole, a["id"].toString());
|
||||
item->setData(0, TypeRole, QStringLiteral("album"));
|
||||
{
|
||||
QFont hiResFont;
|
||||
hiResFont.setBold(true);
|
||||
hiResFont.setPointSizeF(hiResFont.pointSizeF() * 0.85);
|
||||
|
||||
const QJsonArray albums = result["albums"].toObject()["items"].toArray();
|
||||
for (const auto &v : albums) {
|
||||
const QJsonObject a = v.toObject();
|
||||
const QString artist = a["artist"].toObject()["name"].toString();
|
||||
const bool hiRes = a["hires_streamable"].toBool();
|
||||
|
||||
auto *item = new QTreeWidgetItem(m_albumResults,
|
||||
QStringList{QString(), a["title"].toString(), artist});
|
||||
if (hiRes) {
|
||||
item->setText(0, QStringLiteral("H"));
|
||||
item->setForeground(0, QColor(QStringLiteral("#FFD700")));
|
||||
item->setFont(0, hiResFont);
|
||||
item->setTextAlignment(0, Qt::AlignCenter);
|
||||
}
|
||||
item->setData(1, IdRole, a["id"].toString());
|
||||
item->setData(1, TypeRole, QStringLiteral("album"));
|
||||
}
|
||||
}
|
||||
|
||||
// Populate artists
|
||||
@@ -114,7 +134,7 @@ void SearchTab::onItemDoubleClicked(QTreeWidgetItem *item, int)
|
||||
if (type == QStringLiteral("track")) {
|
||||
emit trackPlayRequested(item->data(0, IdRole).toLongLong());
|
||||
} else if (type == QStringLiteral("album")) {
|
||||
emit albumSelected(item->data(0, IdRole).toString());
|
||||
emit albumSelected(item->data(1, IdRole).toString());
|
||||
} else if (type == QStringLiteral("artist")) {
|
||||
emit artistSelected(item->data(0, IdRole).toLongLong());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user