From dab2b38bf5cb0279502445fd03360d51daa52332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Tue, 13 Oct 2026 22:55:41 +0200 Subject: [PATCH] [Client] Active pill for alts table, dismissed pill for report queue --- .../widgets/tabs/alt_table_delegate.cpp | 22 ++++++++++++++++--- .../widgets/tabs/alt_table_delegate.h | 8 +++++-- .../widgets/tabs/report_status_delegate.cpp | 2 +- .../widgets/tabs/report_status_delegate.h | 6 ++--- .../src/interface/widgets/tabs/tab_alts.cpp | 8 +++++-- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp index 3cc412a7e..b011925ce 100644 --- a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp +++ b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp @@ -14,9 +14,14 @@ namespace constexpr int ICON_TEXT_GAP = 4; } // namespace -AltTableDelegate::AltTableDelegate(int viaColumn, int warnsColumn, int bansColumn, int sharedColumn, QObject *parent) +AltTableDelegate::AltTableDelegate(int viaColumn, + int warnsColumn, + int bansColumn, + int sharedColumn, + int activeColumn, + QObject *parent) : QStyledItemDelegate(parent), viaColumn(viaColumn), warnsColumn(warnsColumn), bansColumn(bansColumn), - sharedColumn(sharedColumn) + sharedColumn(sharedColumn), activeColumn(activeColumn) { } @@ -79,13 +84,24 @@ void AltTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti } } + if (index.column() == activeColumn) { + const QVariant activeData = index.data(Qt::UserRole); + const bool active = + activeData.isValid() ? activeData.toBool() : text.compare(QStringLiteral("yes"), Qt::CaseInsensitive) == 0; + const QPalette::ColorRole tintRole = active ? QPalette::Highlight : QPalette::PlaceholderText; + if (!pill_painter::paint(painter, opt, tintRole, emphasisRole, text)) { + QStyledItemDelegate::paint(painter, opt, index); + } + return; + } + QStyledItemDelegate::paint(painter, opt, index); } QSize AltTableDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { const QSize hint = QStyledItemDelegate::sizeHint(option, index); - if (index.column() == viaColumn) { + if (index.column() == viaColumn || index.column() == activeColumn) { return hint + QSize(pill_painter::PAD_X + 2 * ICON_TEXT_GAP, pill_painter::PAD_Y); } if (index.column() == warnsColumn || index.column() == bansColumn) { diff --git a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h index 73386b00d..6cd5c7fad 100644 --- a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h +++ b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h @@ -8,8 +8,10 @@ * Badge + icon painting for the User Alts table. The match-evidence column * renders as a palette-tinted pill per match type (email / client id / IP), and * an IP shared by more than one other account is dimmed. Warn/ban counts gain - * the style's warning/critical icons when nonzero. Selected rows and unknown - * content fall back to default painting. + * the style's warning/critical icons when nonzero. The active column renders as + * a palette-tinted pill (Highlight when active, PlaceholderText when inactive, + * from Qt::UserRole). Selected rows and unknown content fall back to default + * painting. */ class AltTableDelegate : public QStyledItemDelegate { @@ -19,6 +21,7 @@ public: int warnsColumn, int bansColumn, int sharedColumn, + int activeColumn, QObject *parent = nullptr); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; [[nodiscard]] QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; @@ -28,6 +31,7 @@ private: int warnsColumn; int bansColumn; int sharedColumn; + int activeColumn; }; #endif // ALT_TABLE_DELEGATE_H diff --git a/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp b/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp index 62e427e0e..361e89605 100644 --- a/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp +++ b/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp @@ -25,7 +25,7 @@ void ReportStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & tintRole = QPalette::Highlight; } else if (status == QStringLiteral("assigned")) { tintRole = QPalette::Link; - } else if (status == QStringLiteral("resolved")) { + } else if (status == QStringLiteral("resolved") || status == QStringLiteral("dismissed")) { tintRole = QPalette::PlaceholderText; } diff --git a/cockatrice/src/interface/widgets/tabs/report_status_delegate.h b/cockatrice/src/interface/widgets/tabs/report_status_delegate.h index 5c168bcd6..f01f6d3e3 100644 --- a/cockatrice/src/interface/widgets/tabs/report_status_delegate.h +++ b/cockatrice/src/interface/widgets/tabs/report_status_delegate.h @@ -6,9 +6,9 @@ /** * Status pill for the report queue table. Paints the status text on a - * translucent badge tinted with a palette role per status, so the colors - * always follow the active theme. Falls back to default painting for - * selected rows and unknown statuses. + * translucent badge tinted with a palette role per status (open, assigned, + * resolved, dismissed), so the colors always follow the active theme. + * Falls back to default painting for selected rows and unknown statuses. */ class ReportStatusDelegate : public QStyledItemDelegate { diff --git a/cockatrice/src/interface/widgets/tabs/tab_alts.cpp b/cockatrice/src/interface/widgets/tabs/tab_alts.cpp index d6b13b40e..d2cec3855 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_alts.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_alts.cpp @@ -161,10 +161,12 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q altsTable = new QTableWidget(0, COL_ALTS_COUNT); configureAltTable(altsTable); - altsDelegate = new AltTableDelegate(COL_ALTS_VIA, COL_ALTS_WARNS, COL_ALTS_BANS, COL_ALTS_SHARED, altsTable); + altsDelegate = + new AltTableDelegate(COL_ALTS_VIA, COL_ALTS_WARNS, COL_ALTS_BANS, COL_ALTS_SHARED, COL_ALTS_ACTIVE, altsTable); altsTable->setItemDelegateForColumn(COL_ALTS_VIA, altsDelegate); altsTable->setItemDelegateForColumn(COL_ALTS_WARNS, altsDelegate); altsTable->setItemDelegateForColumn(COL_ALTS_BANS, altsDelegate); + altsTable->setItemDelegateForColumn(COL_ALTS_ACTIVE, altsDelegate); connectTableActivation(altsTable, this, [this](const QModelIndex &index) { if (!index.isValid()) { return; @@ -497,7 +499,9 @@ void TabAlts::renderTable() altsTable->setItem(row, COL_ALTS_LAST_LOGIN, new QTableWidgetItem(formatEpoch(alt.last_login()))); altsTable->setItem(row, COL_ALTS_WARNS, new QTableWidgetItem(QString::number(alt.warn_count()))); altsTable->setItem(row, COL_ALTS_BANS, new QTableWidgetItem(QString::number(alt.ban_count()))); - altsTable->setItem(row, COL_ALTS_ACTIVE, new QTableWidgetItem(alt.is_active() ? tr("yes") : tr("no"))); + auto *activeItem = new QTableWidgetItem(alt.is_active() ? tr("yes") : tr("no")); + activeItem->setData(Qt::UserRole, alt.is_active()); + altsTable->setItem(row, COL_ALTS_ACTIVE, activeItem); // shared_count already includes the investigated account, so anything // above 2 means the address is shared beyond that pair. if (QString::fromStdString(alt.match_reason()).startsWith(QStringLiteral("ip:")) && alt.has_shared_count() &&