[Client] Active pill for alts table, dismissed pill for report queue

This commit is contained in:
Lukas Brübach 2026-10-13 22:55:41 +02:00
parent b054ef8c40
commit dab2b38bf5
5 changed files with 35 additions and 11 deletions

View file

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

View file

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

View file

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

View file

@ -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
{

View file

@ -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() &&