From ae7079bbcfd33581dfdd0f49c044434d581a898c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 1 Nov 2026 06:02:50 +0100 Subject: [PATCH] Fix remaining review threads on the alts search controls - Disable keyboard tracking on the depth and window spin boxes so typing a two-digit value sends one search, not one per digit. - Reload the user under investigation on a filter change instead of reading the search box, which could switch to a name never submitted. - Keep a chip's last match count while it is unchecked; the server omits unchecked match types, so the label used to drop to "(0)". --- .../src/interface/widgets/tabs/tab_alts.cpp | 27 +++++++++++++++---- .../src/interface/widgets/tabs/tab_alts.h | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/interface/widgets/tabs/tab_alts.cpp b/cockatrice/src/interface/widgets/tabs/tab_alts.cpp index 97ecbdad3..77763f2d0 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_alts.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_alts.cpp @@ -93,6 +93,7 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q depthSpin->setMinimum(1); depthSpin->setMaximum(MAX_ALT_DEPTH); depthSpin->setValue(1); + depthSpin->setKeyboardTracking(false); connect(depthSpin, &QSpinBox::valueChanged, this, &TabAlts::onSearchFilterChanged); investigateButton = new QPushButton; @@ -140,6 +141,7 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q monthsSpin->setMinimum(1); monthsSpin->setMaximum(24); monthsSpin->setValue(6); + monthsSpin->setKeyboardTracking(false); connect(monthsSpin, &QSpinBox::valueChanged, this, &TabAlts::onSearchFilterChanged); auto *filterBar = new QHBoxLayout; @@ -334,12 +336,17 @@ void TabAlts::investigateUser() } currentUser = userName; updateTrail(); + reloadCurrentUser(); +} + +void TabAlts::reloadCurrentUser() +{ lastAlts.clear(); selectedUser.clear(); clearDetails(); altsTable->setRowCount(0); statusLabel->setText(tr("Loading alts for %1...").arg(currentUser)); - requestAlts(userName, depthSpin->value()); + requestAlts(currentUser, depthSpin->value()); } void TabAlts::requestAlts(const QString &userName, int depth) @@ -419,9 +426,17 @@ void TabAlts::renderTable() ++ipCount; } } - emailChip->setText(tr("Email (%1)").arg(emailCount)); - clientIdChip->setText(tr("Client ID (%1)").arg(clientIdCount)); - ipChip->setText(tr("IP (%1)").arg(ipCount)); + // The server omits unchecked match types, so keep the last count while a + // chip is off instead of relabelling it "(0)". + if (emailChip->isChecked()) { + emailChip->setText(tr("Email (%1)").arg(emailCount)); + } + if (clientIdChip->isChecked()) { + clientIdChip->setText(tr("Client ID (%1)").arg(clientIdCount)); + } + if (ipChip->isChecked()) { + ipChip->setText(tr("IP (%1)").arg(ipCount)); + } QFont userFont = altsTable->font(); userFont.setBold(true); @@ -502,7 +517,9 @@ void TabAlts::onSearchFilterChanged() if (currentUser.isEmpty()) { return; } - investigateUser(); + // A filter change reloads the user being investigated; it must not switch + // to a name that was typed into the search box but never submitted. + reloadCurrentUser(); } void TabAlts::onDisplayFilterChanged() diff --git a/cockatrice/src/interface/widgets/tabs/tab_alts.h b/cockatrice/src/interface/widgets/tabs/tab_alts.h index 150f32a58..0e4cd46b5 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_alts.h +++ b/cockatrice/src/interface/widgets/tabs/tab_alts.h @@ -54,6 +54,7 @@ private slots: private: void loadUser(const QString &userName); void updateTrail(); + void reloadCurrentUser(); void requestAlts(const QString &userName, int depth); void requestDetails(const QString &userName); void clearDetails();