mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33: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
ff6c0402a8
commit
66ae189a57
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue