diff --git a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp index aa9ce907c..9b2869959 100644 --- a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp +++ b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.cpp @@ -15,9 +15,14 @@ constexpr int PILL_PAD_Y = 4; 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) { } @@ -116,13 +121,21 @@ 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; + paintPill(active ? QPalette::Highlight : QPalette::PlaceholderText, emphasisRole, QIcon(), text); + 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_PAD_X + 2 * ICON_TEXT_GAP, PILL_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 7d7af2928..7842cba70 100644 --- a/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h +++ b/cockatrice/src/interface/widgets/tabs/alt_table_delegate.h @@ -9,7 +9,9 @@ * renders as a palette-tinted pill per match type (email / client id / IP), * with the style's warning icon once an IP is shared by more than the VPN * threshold. Warn/ban counts gain the style's warning/critical icons when - * nonzero. Selected rows and unknown content fall back to default painting. + * 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 setVpnThreshold(int threshold); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; @@ -29,6 +32,7 @@ private: int warnsColumn; int bansColumn; int sharedColumn; + int activeColumn; int vpnThreshold = 10; }; diff --git a/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp b/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp index fe59702c4..4079c9ac8 100644 --- a/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp +++ b/cockatrice/src/interface/widgets/tabs/report_status_delegate.cpp @@ -30,7 +30,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 97ecbdad3..c148d185e 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_alts.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_alts.cpp @@ -154,12 +154,14 @@ 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); altsDelegate->setVpnThreshold(vpnSpin->value()); connect(vpnSpin, &QSpinBox::valueChanged, altsDelegate, &AltTableDelegate::setVpnThreshold); altsTable->setItemDelegateForColumn(COL_ALTS_VIA, altsDelegate); altsTable->setItemDelegateForColumn(COL_ALTS_WARNS, altsDelegate); altsTable->setItemDelegateForColumn(COL_ALTS_BANS, altsDelegate); + altsTable->setItemDelegateForColumn(COL_ALTS_ACTIVE, altsDelegate); connect(altsTable, &QTableWidget::activated, this, [this](const QModelIndex &index) { if (!index.isValid()) { return; @@ -456,7 +458,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); if (QString::fromStdString(alt.match_reason()).startsWith(QStringLiteral("ip:")) && alt.has_shared_count() && alt.shared_count() > 1) { for (int col = 0; col < COL_ALTS_COUNT; ++col) {