mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Client] Alt investigation entry points and in-tab navigation
TabModeration gains an Open alt graph button plus alts-table double-click, both routing to the User Alts tab. UserContextMenu gains an Investigate alts action. TabAlts gains row double-click navigation with a Back history stack so moderators can walk the alt graph without retyping names.
This commit is contained in:
parent
66807f543b
commit
221881a4ce
6 changed files with 78 additions and 1 deletions
|
|
@ -58,9 +58,14 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
investigateButton = new QPushButton;
|
||||
connect(investigateButton, &QPushButton::clicked, this, &TabAlts::investigateUser);
|
||||
|
||||
backButton = new QPushButton;
|
||||
backButton->setEnabled(false);
|
||||
connect(backButton, &QPushButton::clicked, this, &TabAlts::goBack);
|
||||
|
||||
statusLabel = new QLabel;
|
||||
|
||||
auto *topBar = new QHBoxLayout;
|
||||
topBar->addWidget(backButton);
|
||||
topBar->addWidget(searchEdit);
|
||||
topBar->addWidget(depthSpin);
|
||||
topBar->addWidget(investigateButton);
|
||||
|
|
@ -73,6 +78,12 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
altsTable->setAlternatingRowColors(true);
|
||||
altsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
altsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
connect(altsTable, &QTableWidget::cellDoubleClicked, this, [this](int row, int) {
|
||||
auto *userItem = altsTable->item(row, COL_ALTS_USER);
|
||||
if (userItem != nullptr && !userItem->text().isEmpty() && userItem->text() != currentUser) {
|
||||
investigate(userItem->text());
|
||||
}
|
||||
});
|
||||
|
||||
auto *mainLayout = new QVBoxLayout(centralWidget);
|
||||
mainLayout->addLayout(topBar);
|
||||
|
|
@ -89,6 +100,8 @@ void TabAlts::retranslateUi()
|
|||
depthSpin->setPrefix(tr("Depth: "));
|
||||
depthSpin->setToolTip(tr("Search depth: 1 finds direct matches, higher values follow alts of alts."));
|
||||
investigateButton->setText(tr("Investigate"));
|
||||
backButton->setText(tr("Back"));
|
||||
backButton->setToolTip(tr("Back to the previously investigated user"));
|
||||
if (currentUser.isEmpty()) {
|
||||
statusLabel->setText(tr("Enter a user name to investigate."));
|
||||
}
|
||||
|
|
@ -105,9 +118,29 @@ QString TabAlts::formatEpoch(quint64 ts) const
|
|||
|
||||
void TabAlts::investigate(const QString &userName)
|
||||
{
|
||||
if (userName.isEmpty()) {
|
||||
if (userName.isEmpty() || userName == currentUser) {
|
||||
return;
|
||||
}
|
||||
if (!currentUser.isEmpty()) {
|
||||
backStack << currentUser;
|
||||
backButton->setEnabled(true);
|
||||
}
|
||||
loadUser(userName);
|
||||
}
|
||||
|
||||
void TabAlts::goBack()
|
||||
{
|
||||
if (backStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const QString previousUser = backStack.takeLast();
|
||||
backButton->setEnabled(!backStack.isEmpty());
|
||||
loadUser(previousUser);
|
||||
}
|
||||
|
||||
void TabAlts::loadUser(const QString &userName)
|
||||
{
|
||||
currentUser = userName;
|
||||
searchEdit->setText(userName);
|
||||
investigateUser();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,18 +35,22 @@ public:
|
|||
|
||||
private slots:
|
||||
void investigateUser();
|
||||
void goBack();
|
||||
void altsResponse(const Response &response);
|
||||
|
||||
private:
|
||||
void loadUser(const QString &userName);
|
||||
void requestAlts(const QString &userName, int depth);
|
||||
[[nodiscard]] QString formatEpoch(quint64 ts) const;
|
||||
|
||||
AbstractClient *client;
|
||||
QString currentUser;
|
||||
QList<QString> backStack;
|
||||
|
||||
QLineEdit *searchEdit;
|
||||
QSpinBox *depthSpin;
|
||||
QPushButton *investigateButton;
|
||||
QPushButton *backButton;
|
||||
QLabel *statusLabel;
|
||||
QTableWidget *altsTable;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "libcockatrice/protocol/pb/serverinfo_moderator_login.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_user_alt.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_user_session.pb.h"
|
||||
#include "tab_supervisor.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QDateTime>
|
||||
|
|
@ -146,7 +147,19 @@ TabModeration::TabModeration(TabSupervisor *_tabSupervisor, AbstractClient *_cli
|
|||
altsGroup = new QGroupBox;
|
||||
altsTable = new QTableWidget(0, COL_ALTS_COUNT);
|
||||
configureTable(altsTable);
|
||||
connect(altsTable, &QTableWidget::cellDoubleClicked, this, [this](int row, int) {
|
||||
auto *userItem = altsTable->item(row, COL_ALTS_USER);
|
||||
if (userItem != nullptr && !userItem->text().isEmpty()) {
|
||||
getTabSupervisor()->openTabAlts(userItem->text());
|
||||
}
|
||||
});
|
||||
openAltsButton = new QPushButton;
|
||||
connect(openAltsButton, &QPushButton::clicked, this, &TabModeration::openAltsGraph);
|
||||
auto *altsHeader = new QHBoxLayout;
|
||||
altsHeader->addStretch();
|
||||
altsHeader->addWidget(openAltsButton);
|
||||
auto *altsLayout = new QVBoxLayout(altsGroup);
|
||||
altsLayout->addLayout(altsHeader);
|
||||
altsLayout->addWidget(altsTable);
|
||||
|
||||
sessionsGroup = new QGroupBox;
|
||||
|
|
@ -205,6 +218,8 @@ void TabModeration::retranslateUi()
|
|||
userInfoNotesLabel->setText(tr("Admin notes:"));
|
||||
|
||||
altsGroup->setTitle(tr("Alts"));
|
||||
openAltsButton->setText(tr("Open alt graph"));
|
||||
openAltsButton->setToolTip(tr("Open this user in the User Alts tab"));
|
||||
sessionsGroup->setTitle(tr("Sessions"));
|
||||
staffGroup->setTitle(tr("Staff Last Logins"));
|
||||
|
||||
|
|
@ -233,6 +248,7 @@ void TabModeration::clearUserData()
|
|||
resetPasswordButton->setEnabled(false);
|
||||
removeAvatarButton->setEnabled(false);
|
||||
removeBannerButton->setEnabled(false);
|
||||
openAltsButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void TabModeration::investigate(const QString &userName)
|
||||
|
|
@ -254,6 +270,7 @@ void TabModeration::investigateUser()
|
|||
resetPasswordButton->setEnabled(true);
|
||||
removeAvatarButton->setEnabled(true);
|
||||
removeBannerButton->setEnabled(true);
|
||||
openAltsButton->setEnabled(true);
|
||||
altsTable->setRowCount(0);
|
||||
sessionsTable->setRowCount(0);
|
||||
requestUserInfo(userName);
|
||||
|
|
@ -261,6 +278,14 @@ void TabModeration::investigateUser()
|
|||
requestAlts(userName);
|
||||
}
|
||||
|
||||
void TabModeration::openAltsGraph()
|
||||
{
|
||||
if (currentUser.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
getTabSupervisor()->openTabAlts(currentUser);
|
||||
}
|
||||
|
||||
void TabModeration::requestUserInfo(const QString &userName)
|
||||
{
|
||||
userInfoNameValue->setText(userName);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void investigateUser();
|
||||
void openAltsGraph();
|
||||
void userInfoResponse(const Response &response);
|
||||
void sessionsResponse(const Response &response);
|
||||
void altsResponse(const Response &response);
|
||||
|
|
@ -80,6 +81,7 @@ private:
|
|||
|
||||
QGroupBox *altsGroup;
|
||||
QTableWidget *altsTable;
|
||||
QPushButton *openAltsButton;
|
||||
QGroupBox *sessionsGroup;
|
||||
QTableWidget *sessionsTable;
|
||||
QGroupBox *staffGroup;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue