mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-13 05:20:00 -08:00
[Report] Add context menu to report queue rows
- Open the standard UserContextMenu on right-click/Menu key for the reported user, selecting the row first so the details panel matches the menu target - Carry the reported user's level in ServerInfo_Report so the menu shows the same actions as the user list, with an IsUser fallback for deleted or unregistered users - Wire the Private chat action through TabReport to TabSupervisor and retranslate the menu on live language switches
This commit is contained in:
parent
a804c1a6fe
commit
a8fe6419a1
5 changed files with 79 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "tab_report.h"
|
||||
|
||||
#include "../server/user/user_context_menu.h"
|
||||
#include "../utility/report_utils.h"
|
||||
#include "abstract_client.h"
|
||||
#include "tab_supervisor.h"
|
||||
|
|
@ -25,6 +26,7 @@
|
|||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/network/server/remote/user_level.h>
|
||||
#include <libcockatrice/protocol/pb/command_replay_download_by_game_id.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_report_add_comment.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_report_assign.pb.h>
|
||||
|
|
@ -111,6 +113,10 @@ TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : T
|
|||
table->horizontalHeader()->setSectionResizeMode(COL_REPORTED, QHeaderView::Stretch);
|
||||
table->horizontalHeader()->setSectionResizeMode(COL_REPORTER, QHeaderView::ResizeToContents);
|
||||
connect(table, &QTableWidget::itemSelectionChanged, this, &TabReport::onSelectionChanged);
|
||||
table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(table, &QTableWidget::customContextMenuRequested, this, &TabReport::showTableContextMenu);
|
||||
userContextMenu = new UserContextMenu(tabSupervisor, this);
|
||||
connect(userContextMenu, &UserContextMenu::openMessageDialog, this, &TabReport::openMessageDialog);
|
||||
|
||||
descGroup = new QGroupBox;
|
||||
descriptionEdit = new QTextEdit;
|
||||
|
|
@ -266,6 +272,7 @@ TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : T
|
|||
|
||||
void TabReport::retranslateUi()
|
||||
{
|
||||
userContextMenu->retranslateUi();
|
||||
searchEdit->setPlaceholderText(tr("Search by username, category..."));
|
||||
statusFilter->clear();
|
||||
statusFilter->addItem(tr("All Statuses"), "");
|
||||
|
|
@ -496,6 +503,36 @@ void TabReport::onSelectionChanged()
|
|||
updateActionStates();
|
||||
}
|
||||
|
||||
void TabReport::showTableContextMenu(const QPoint &pos)
|
||||
{
|
||||
QTableWidgetItem *clickedItem = table->itemAt(pos);
|
||||
if (!clickedItem || clickedItem->row() < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int row = clickedItem->row();
|
||||
const QTableWidgetItem *reportedItem = table->item(row, COL_REPORTED);
|
||||
const QTableWidgetItem *idItem = table->item(row, COL_ID);
|
||||
if (!reportedItem || !idItem || reportedItem->text().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userLevel = ServerInfo_User::IsUser;
|
||||
const int reportId = idItem->data(Qt::UserRole).toInt();
|
||||
for (const ServerInfo_Report &r : filteredReports) {
|
||||
if (r.report_id() == reportId) {
|
||||
if (r.reported_user_level() != 0) {
|
||||
userLevel = r.reported_user_level();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
table->selectRow(row);
|
||||
userContextMenu->showContextMenu(table->viewport()->mapToGlobal(pos), reportedItem->text(),
|
||||
UserLevelFlags(userLevel));
|
||||
}
|
||||
|
||||
void TabReport::loadReportDetails(int reportId)
|
||||
{
|
||||
detailsRequestedReportId = reportId;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "tab.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QPoint>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_report.pb.h>
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ class QTableWidget;
|
|||
class QTextEdit;
|
||||
class QTimer;
|
||||
class GameReplay;
|
||||
class UserContextMenu;
|
||||
|
||||
class TabReport : public Tab
|
||||
{
|
||||
|
|
@ -34,6 +36,7 @@ public:
|
|||
signals:
|
||||
void openReplay(GameReplay *replay);
|
||||
void requestJoinGame(int gameId, int roomId);
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
|
||||
private slots:
|
||||
void refreshList();
|
||||
|
|
@ -43,6 +46,7 @@ private slots:
|
|||
void resolveReport(bool dismissed, bool promptNote);
|
||||
void resolveResponse(const Response &response);
|
||||
void onSelectionChanged();
|
||||
void showTableContextMenu(const QPoint &pos);
|
||||
void viewReplay();
|
||||
void viewReplayResponse(const Response &response);
|
||||
void joinGame();
|
||||
|
|
@ -91,6 +95,7 @@ private:
|
|||
QPushButton *joinGameButton;
|
||||
QLabel *statusLabel;
|
||||
QTimer *refreshTimer;
|
||||
UserContextMenu *userContextMenu;
|
||||
|
||||
QGroupBox *userContextGroup;
|
||||
QLabel *userContextName;
|
||||
|
|
|
|||
|
|
@ -884,6 +884,7 @@ void TabSupervisor::openTabReport()
|
|||
myAddTab(tabReport, aTabReport);
|
||||
connect(tabReport, &TabReport::openReplay, this, &TabSupervisor::openReplay);
|
||||
connect(tabReport, &TabReport::requestJoinGame, this, &TabSupervisor::joinReportGame);
|
||||
connect(tabReport, &TabReport::openMessageDialog, this, &TabSupervisor::addMessageTab);
|
||||
connect(tabReport, &QObject::destroyed, this, [this] {
|
||||
tabReport = nullptr;
|
||||
aTabReport->setChecked(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue