From ecb77e631e1f7c55fbae2aeb05ca01166ceef59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 11 Oct 2026 12:04:29 +0200 Subject: [PATCH] [Client] Settings: remove the DlgSettings modal All entries now open the settings tab; close validation lives in TabSettings::closeRequest. Drop the unreferenced dialog and update the logging-category docs. --- cockatrice/CMakeLists.txt | 1 - .../widgets/dialogs/dlg_settings.cpp | 157 ------------------ .../interface/widgets/dialogs/dlg_settings.h | 59 ------- .../troubleshooting/enabling_debug_logs.md | 2 +- 4 files changed, 1 insertion(+), 218 deletions(-) delete mode 100644 cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp delete mode 100644 cockatrice/src/interface/widgets/dialogs/dlg_settings.h diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index cdd2a77d0..57fd9b615 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -53,7 +53,6 @@ set(cockatrice_SOURCES src/interface/widgets/dialogs/dlg_select_set_for_cards.cpp src/interface/widgets/dialogs/dlg_share_deck.cpp src/interface/widgets/dialogs/dlg_shared_decks_preview.cpp - src/interface/widgets/dialogs/dlg_settings.cpp src/interface/widgets/dialogs/dlg_startup_card_check.cpp src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp src/interface/widgets/dialogs/dlg_update.cpp diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp deleted file mode 100644 index 9b20372db..000000000 --- a/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @file dlg_settings.cpp - * @brief Implementation of the main settings dialog (thin frame around SettingsView) - * @ingroup Dialogs - */ -#include "dlg_settings.h" - -#include "../../../client/settings/cache_settings.h" -#include "../main.h" -#include "../settings_page/abstract_settings_page.h" -#include "libcockatrice/card/database/card_database.h" -#include "libcockatrice/card/database/card_database_loader.h" -#include "libcockatrice/card/database/card_database_manager.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent) -{ - auto rec = QGuiApplication::primaryScreen()->availableGeometry(); - setMinimumSize(qMin(750, rec.width()), qMin(700, rec.height())); - - connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this, &DlgSettings::updateLanguage); - - settingsView = new SettingsView(this); - - // Bottom buttons - auto *buttonBox = new QHBoxLayout; - buttonBox->addStretch(); - okButton = new QPushButton; - okButton->setDefault(true); - connect(okButton, &QPushButton::clicked, this, &DlgSettings::close); - buttonBox->addWidget(okButton); - - // Main layout - auto *mainLayout = new QVBoxLayout; - mainLayout->addWidget(settingsView); - mainLayout->addSpacing(4); - mainLayout->addLayout(buttonBox); - setLayout(mainLayout); - - connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this, &DlgSettings::retranslateUi); - retranslateUi(); - - adjustSize(); -} - -void DlgSettings::setTab(int index) -{ - settingsView->setTab(index); -} - -AbstractSettingsPage *DlgSettings::page(SettingsPage which) const -{ - return settingsView->page(which); -} - -void DlgSettings::updateLanguage() -{ - qApp->removeTranslator(translator); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) - installNewTranslator(); -} - -void DlgSettings::closeEvent(QCloseEvent *event) -{ - bool showLoadError = true; - QString loadErrorMessage = tr("Unknown Error loading card database"); - LoadStatus loadStatus = CardDatabaseManager::getInstance()->getLoadStatus(); - qCInfo(DlgSettingsLog) << "Card Database load status: " << loadStatus; - switch (loadStatus) { - case Ok: - showLoadError = false; - break; - case Invalid: - loadErrorMessage = tr("Your card database is invalid.\n\n" - "Cockatrice may not function correctly with an invalid database\n\n" - "You may need to rerun Oracle to update your card database.\n\n" - "Would you like to change your database location setting?"); - break; - case VersionTooOld: - loadErrorMessage = tr("Your card database version is too old.\n\n" - "This can cause problems loading card information or images\n\n" - "Usually this can be fixed by rerunning Oracle to to update your card database.\n\n" - "Would you like to change your database location setting?"); - break; - case NotLoaded: - loadErrorMessage = tr("Your card database did not finish loading\n\n" - "Please file a ticket at https://github.com/Cockatrice/Cockatrice/issues with your " - "cards.xml attached\n\n" - "Would you like to change your database location setting?"); - break; - case FileError: - loadErrorMessage = tr("File Error loading your card database.\n\n" - "Would you like to change your database location setting?"); - break; - case NoCards: - loadErrorMessage = tr("Your card database was loaded but contains no cards.\n\n" - "Would you like to change your database location setting?"); - break; - default: - loadErrorMessage = tr("Unknown card database load status\n\n" - "Please file a ticket at https://github.com/Cockatrice/Cockatrice/issues\n\n" - "Would you like to change your database location setting?"); - - break; - } - - if (showLoadError) { - if (QMessageBox::critical(this, tr("Error"), loadErrorMessage, QMessageBox::Yes | QMessageBox::No) == - QMessageBox::Yes) { - event->ignore(); - return; - } - } - - if (!QDir(SettingsCache::instance().paths().getDeckPath()).exists() || - SettingsCache::instance().paths().getDeckPath().isEmpty()) { - if (QMessageBox::critical( - this, tr("Error"), - tr("The path to your deck directory is invalid. Would you like to go back and set the correct path?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - event->ignore(); - return; - } - } - - if (!QDir(SettingsCache::instance().paths().getPicsPath()).exists() || - SettingsCache::instance().paths().getPicsPath().isEmpty()) { - if (QMessageBox::critical(this, tr("Error"), - tr("The path to your card pictures directory is invalid. Would you like to go back " - "and set the correct path?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - event->ignore(); - return; - } - } - event->accept(); -} - -void DlgSettings::retranslateUi() -{ - setWindowTitle(tr("Settings")); - okButton->setText(tr("OK")); -} diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_settings.h b/cockatrice/src/interface/widgets/dialogs/dlg_settings.h deleted file mode 100644 index 9942b410c..000000000 --- a/cockatrice/src/interface/widgets/dialogs/dlg_settings.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file dlg_settings.h - * @brief Main settings dialog for the Cockatrice client (thin frame around SettingsView) - * @ingroup Dialogs - */ -#ifndef DLG_SETTINGS_H -#define DLG_SETTINGS_H - -#include "settings_view.h" - -#include -#include -#include - -class QPushButton; -class AbstractSettingsPage; - -inline Q_LOGGING_CATEGORY(DlgSettingsLog, "dlg_settings"); - -/** - * @brief Main application settings dialog hosting the shared SettingsView - * - * Thin QDialog frame around SettingsView: only the window title, the OK button - * and the close validation live here. All pages, navigation and search are - * owned by SettingsView so other hosts (e.g. a settings tab) can reuse them. - */ -class DlgSettings : public QDialog -{ - Q_OBJECT -public: - using SettingsPage = SettingsView::SettingsPage; - static constexpr SettingsPage GeneralPage = SettingsView::GeneralPage; - static constexpr SettingsPage AppearancePage = SettingsView::AppearancePage; - static constexpr SettingsPage UserInterfacePage = SettingsView::UserInterfacePage; - static constexpr SettingsPage DeckEditorPage = SettingsView::DeckEditorPage; - static constexpr SettingsPage StoragePage = SettingsView::StoragePage; - static constexpr SettingsPage MessagesPage = SettingsView::MessagesPage; - static constexpr SettingsPage SoundPage = SettingsView::SoundPage; - static constexpr SettingsPage ShortcutsPage = SettingsView::ShortcutsPage; - static constexpr SettingsPage NumPages = SettingsView::NumPages; - - explicit DlgSettings(QWidget *parent = nullptr); - void setTab(int index); - AbstractSettingsPage *page(SettingsPage which) const; - -private slots: - void updateLanguage(); - -private: - SettingsView *settingsView; ///< Shared settings content - QPushButton *okButton; ///< Button to close the dialog - - void retranslateUi(); - -protected: - void closeEvent(QCloseEvent *event) override; -}; - -#endif // DLG_SETTINGS_H diff --git a/doc/doxygen/pages/user_documentation/troubleshooting/enabling_debug_logs.md b/doc/doxygen/pages/user_documentation/troubleshooting/enabling_debug_logs.md index 27c4272f5..8f48856bf 100644 --- a/doc/doxygen/pages/user_documentation/troubleshooting/enabling_debug_logs.md +++ b/doc/doxygen/pages/user_documentation/troubleshooting/enabling_debug_logs.md @@ -116,7 +116,7 @@ suffix, e.g. `card_picture_loader.*`, to include all sub categories). | User interface and themes | `theme_manager`, `sound_engine`, `flow_layout`, `flow_widget.*`, `pixel_map_generator`, `card_info_picture_widget` | | Networking and servers | `local_client`, `remote_client`, `tapped_out_interface`, `servers_settings` | | In-game logic | `player`, `game_scene.*`, `card_zone.*`, `view_zone`, `game_event_handler` | -| Dialogs and tabs | `dlg_settings`, `dlg_update`, `dlg_tip_of_the_day`, `tab_game`, `tab_message`, `tab_supervisor` | +| Dialogs and tabs | `tab_settings`, `dlg_update`, `dlg_tip_of_the_day`, `tab_game`, `tab_message`, `tab_supervisor` | | Settings and shortcuts | `settings_cache`, `shortcuts_settings` | | Deck and card filtering | `filter_string`, `deck_filter_string`, `syntax_help` |