mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Client] Report queue dashboard and status pills (#7515)
* [Client] Moderation and alts dashboards Turn the two staff tables into dashboards without behavior changes: TabModeration gets an identity header (display-size name, status, registered/last-login subline), Reports/Warnings/Bans/Alts count cards with an Open-graph deep link, full-width admin notes, and Alts/Sessions/Staff tabbed sections with tab memory. TabAlts gets toggle chips with match counts, bold usernames, palette-token dimming of shared-IP rows, and a resizable side card for the selected-user timeline with selection restore. Row activation works via Enter as well as double-click; async responses are guarded against stale investigations and retranslation re-applies cached dashboard data. * [Client] Report queue dashboard and status pills TabReport becomes a dashboard: selected-report identity header (display-size user, bold status, category/time/room subline), Description/Chat/Comments/Reported-user tabbed sections with tab memory, always-visible user context with empty cues, and bold reported users. ReportStatusDelegate paints palette-tinted status pills with paint-through selection, translated status strings, and font/elision handling. report_utils gains formatReportStatus plus an opt-out status-color flag so the delegate owns color in the mod queue while the user dialog keeps its colors. Async responses stay guarded; retranslation re-applies header and comment states. * Fix remaining review threads on the report queue dashboard - Read the raw report status from Qt::UserRole in DlgMyReports, so regular users can comment on their own open reports again. - Exclude the server's depth-0 seed row from the related-alt count. - Dim only IP matches shared by more than the pair, not every IP match. - Activate alts rows on double-click or Enter instead of `activated`, which fires on a single click on single-click platforms. - Fold the reported-user bolding pass into the fill loop. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
e603257e08
commit
18f9b26a3d
14 changed files with 615 additions and 171 deletions
|
|
@ -80,6 +80,23 @@ QString formatReportTime(qint64 secondsSinceEpoch)
|
|||
return dt.toString("yyyy-MM-dd hh:mm");
|
||||
}
|
||||
|
||||
QString formatReportStatus(const QString &status)
|
||||
{
|
||||
if (status == QStringLiteral("open")) {
|
||||
return QObject::tr("Open");
|
||||
}
|
||||
if (status == QStringLiteral("assigned")) {
|
||||
return QObject::tr("Assigned");
|
||||
}
|
||||
if (status == QStringLiteral("resolved")) {
|
||||
return QObject::tr("Resolved");
|
||||
}
|
||||
if (status == QStringLiteral("dismissed")) {
|
||||
return QObject::tr("Dismissed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void fillReportTableRow(QTableWidget *table,
|
||||
int row,
|
||||
const ServerInfo_Report &report,
|
||||
|
|
@ -89,7 +106,8 @@ void fillReportTableRow(QTableWidget *table,
|
|||
int categoryColumn,
|
||||
int gameIdColumn,
|
||||
int statusColumn,
|
||||
int assignedColumn)
|
||||
int assignedColumn,
|
||||
bool colorizeStatus)
|
||||
{
|
||||
auto *idItem = new QTableWidgetItem(QString::number(report.report_id()));
|
||||
idItem->setData(Qt::UserRole, report.report_id());
|
||||
|
|
@ -102,8 +120,12 @@ void fillReportTableRow(QTableWidget *table,
|
|||
table->setItem(row, gameIdColumn,
|
||||
new QTableWidgetItem(report.game_id() > 0 ? QString::number(report.game_id()) : QString()));
|
||||
|
||||
auto *statusItem = new QTableWidgetItem(QString::fromStdString(report.status()));
|
||||
setReportStatusItemColor(statusItem, QString::fromStdString(report.status()));
|
||||
const QString rawStatus = QString::fromStdString(report.status());
|
||||
auto *statusItem = new QTableWidgetItem(formatReportStatus(rawStatus));
|
||||
statusItem->setData(Qt::UserRole, rawStatus);
|
||||
if (colorizeStatus) {
|
||||
setReportStatusItemColor(statusItem, rawStatus);
|
||||
}
|
||||
table->setItem(row, statusColumn, statusItem);
|
||||
|
||||
table->setItem(row, assignedColumn, new QTableWidgetItem(QString::fromStdString(report.assigned_mod_name())));
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ QFont reportLogFont();
|
|||
|
||||
QString formatReportCategory(const QString &category);
|
||||
QString formatReportTime(qint64 secondsSinceEpoch);
|
||||
QString formatReportStatus(const QString &status);
|
||||
|
||||
void fillReportTableRow(QTableWidget *table,
|
||||
int row,
|
||||
|
|
@ -30,7 +31,8 @@ void fillReportTableRow(QTableWidget *table,
|
|||
int categoryColumn,
|
||||
int gameIdColumn,
|
||||
int statusColumn,
|
||||
int assignedColumn);
|
||||
int assignedColumn,
|
||||
bool colorizeStatus = true);
|
||||
|
||||
void renderReportDetails(QTextEdit *chatLogEdit,
|
||||
QTextEdit *commentsEdit,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
#include "table_activation.h"
|
||||
|
||||
#include <QKeySequence>
|
||||
#include <QShortcut>
|
||||
#include <QTableWidget>
|
||||
|
||||
namespace
|
||||
{
|
||||
void addActivationShortcut(QTableWidget *table,
|
||||
QObject *context,
|
||||
int key,
|
||||
const std::function<void(const QModelIndex &)> &handler)
|
||||
{
|
||||
auto *shortcut = new QShortcut(QKeySequence(key), table);
|
||||
// The table's viewport takes focus, so match children as well.
|
||||
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
QObject::connect(shortcut, &QShortcut::activated, context, [table, handler] { handler(table->currentIndex()); });
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void connectTableActivation(QTableWidget *table,
|
||||
QObject *context,
|
||||
const std::function<void(const QModelIndex &)> &handler)
|
||||
{
|
||||
QObject::connect(table, &QTableWidget::doubleClicked, context, handler);
|
||||
addActivationShortcut(table, context, Qt::Key_Return, handler);
|
||||
addActivationShortcut(table, context, Qt::Key_Enter, handler);
|
||||
}
|
||||
32
cockatrice/src/interface/widgets/utility/table_activation.h
Normal file
32
cockatrice/src/interface/widgets/utility/table_activation.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @file table_activation.h
|
||||
* @brief Row activation for tables that must not navigate on a single click.
|
||||
*/
|
||||
|
||||
#ifndef TABLE_ACTIVATION_H
|
||||
#define TABLE_ACTIVATION_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
class QTableWidget;
|
||||
|
||||
/**
|
||||
* @brief Call @p handler on double-click or Enter, never on a single click.
|
||||
*
|
||||
* QAbstractItemView::activated fires on a single click on platforms where
|
||||
* SH_ItemView_ActivateItemOnSingleClick is set, so navigation actions must not
|
||||
* use it. This connects doubleClicked and installs Return/Enter shortcuts that
|
||||
* forward the current index.
|
||||
*
|
||||
* @param table The table whose rows activate.
|
||||
* @param context Object that owns the connections; the handler is disconnected
|
||||
* with it.
|
||||
* @param handler Receives the activated row's index, which may be invalid.
|
||||
*/
|
||||
void connectTableActivation(QTableWidget *table,
|
||||
QObject *context,
|
||||
const std::function<void(const QModelIndex &)> &handler);
|
||||
|
||||
#endif // TABLE_ACTIVATION_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue