mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Client] Active pill for alts table, dismissed pill for report queue
This commit is contained in:
parent
a1a5aae467
commit
b4acbcc0cf
5 changed files with 35 additions and 11 deletions
|
|
@ -14,9 +14,14 @@ namespace
|
||||||
constexpr int ICON_TEXT_GAP = 4;
|
constexpr int ICON_TEXT_GAP = 4;
|
||||||
} // namespace
|
} // 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),
|
: 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);
|
QStyledItemDelegate::paint(painter, opt, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize AltTableDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
QSize AltTableDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
const QSize hint = QStyledItemDelegate::sizeHint(option, index);
|
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);
|
return hint + QSize(pill_painter::PAD_X + 2 * ICON_TEXT_GAP, pill_painter::PAD_Y);
|
||||||
}
|
}
|
||||||
if (index.column() == warnsColumn || index.column() == bansColumn) {
|
if (index.column() == warnsColumn || index.column() == bansColumn) {
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@
|
||||||
* Badge + icon painting for the User Alts table. The match-evidence column
|
* 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
|
* 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
|
* 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
|
* the style's warning/critical icons when nonzero. The active column renders as
|
||||||
* content fall back to default painting.
|
* 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
|
class AltTableDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
|
@ -19,6 +21,7 @@ public:
|
||||||
int warnsColumn,
|
int warnsColumn,
|
||||||
int bansColumn,
|
int bansColumn,
|
||||||
int sharedColumn,
|
int sharedColumn,
|
||||||
|
int activeColumn,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
[[nodiscard]] QSize sizeHint(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 warnsColumn;
|
||||||
int bansColumn;
|
int bansColumn;
|
||||||
int sharedColumn;
|
int sharedColumn;
|
||||||
|
int activeColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALT_TABLE_DELEGATE_H
|
#endif // ALT_TABLE_DELEGATE_H
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ void ReportStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||||
tintRole = QPalette::Highlight;
|
tintRole = QPalette::Highlight;
|
||||||
} else if (status == QStringLiteral("assigned")) {
|
} else if (status == QStringLiteral("assigned")) {
|
||||||
tintRole = QPalette::Link;
|
tintRole = QPalette::Link;
|
||||||
} else if (status == QStringLiteral("resolved")) {
|
} else if (status == QStringLiteral("resolved") || status == QStringLiteral("dismissed")) {
|
||||||
tintRole = QPalette::PlaceholderText;
|
tintRole = QPalette::PlaceholderText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status pill for the report queue table. Paints the status text on a
|
* 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
|
* translucent badge tinted with a palette role per status (open, assigned,
|
||||||
* always follow the active theme. Falls back to default painting for
|
* resolved, dismissed), so the colors always follow the active theme.
|
||||||
* selected rows and unknown statuses.
|
* Falls back to default painting for selected rows and unknown statuses.
|
||||||
*/
|
*/
|
||||||
class ReportStatusDelegate : public QStyledItemDelegate
|
class ReportStatusDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -161,10 +161,12 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
||||||
|
|
||||||
altsTable = new QTableWidget(0, COL_ALTS_COUNT);
|
altsTable = new QTableWidget(0, COL_ALTS_COUNT);
|
||||||
configureAltTable(altsTable);
|
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_VIA, altsDelegate);
|
||||||
altsTable->setItemDelegateForColumn(COL_ALTS_WARNS, altsDelegate);
|
altsTable->setItemDelegateForColumn(COL_ALTS_WARNS, altsDelegate);
|
||||||
altsTable->setItemDelegateForColumn(COL_ALTS_BANS, altsDelegate);
|
altsTable->setItemDelegateForColumn(COL_ALTS_BANS, altsDelegate);
|
||||||
|
altsTable->setItemDelegateForColumn(COL_ALTS_ACTIVE, altsDelegate);
|
||||||
connectTableActivation(altsTable, this, [this](const QModelIndex &index) {
|
connectTableActivation(altsTable, this, [this](const QModelIndex &index) {
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return;
|
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_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_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_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
|
// shared_count already includes the investigated account, so anything
|
||||||
// above 2 means the address is shared beyond that pair.
|
// above 2 means the address is shared beyond that pair.
|
||||||
if (QString::fromStdString(alt.match_reason()).startsWith(QStringLiteral("ip:")) && alt.has_shared_count() &&
|
if (QString::fromStdString(alt.match_reason()).startsWith(QStringLiteral("ip:")) && alt.has_shared_count() &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue