[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.
This commit is contained in:
Lukas Brübach 2026-10-11 12:04:29 +02:00
parent 8c64c6fc9e
commit ecb77e631e
4 changed files with 1 additions and 218 deletions

View file

@ -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

View file

@ -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 <QApplication>
#include <QCloseEvent>
#include <QDir>
#include <QGuiApplication>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QMessageLogger>
#include <QPushButton>
#include <QScreen>
#include <QSize>
#include <QVBoxLayout>
#include <QWidget>
#include <QtGlobal>
#include <libcockatrice/settings/paths_settings.h>
#include <libcockatrice/settings/personal_settings.h>
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"));
}

View file

@ -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 <QDialog>
#include <QLoggingCategory>
#include <qtmetamacros.h>
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

View file

@ -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` |