Drop some settings, add some new ones.

Took 19 minutes
This commit is contained in:
Lukas Brübach 2026-08-24 21:42:03 +02:00
parent c2f80abc15
commit 16f792d071
5 changed files with 157 additions and 127 deletions

View file

@ -1,28 +1,27 @@
#include "preferences_setup_page.h"
#include "../../client/settings/cache_settings.h"
#include "libcockatrice/settings/appearance_settings.h"
#include "libcockatrice/settings/download_settings.h"
#include "libcockatrice/settings/network_settings.h"
#include "../../client/sound_engine.h"
#include "libcockatrice/settings/interface_settings.h"
#include "libcockatrice/settings/sound_settings.h"
#include "libcockatrice/settings/tabs_settings.h"
#include <QCheckBox>
#include <QComboBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QScrollArea>
#include <QVBoxLayout>
#include <libcockatrice/settings/cards_display_settings.h>
#include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/settings/personal_settings.h>
#include <libcockatrice/settings/sound_settings.h>
#include <libcockatrice/settings/updates_settings.h>
namespace
{
QGroupBox *makeGroup(QWidget *parent, QVBoxLayout *outerLayout)
// The server destinations are omitted: during first run their tabs are not
// open yet, and the wizard offers no way to fill in the server/room details.
QList<StartupTab> wizardStartupTabOrder()
{
auto *group = new QGroupBox(parent);
new QVBoxLayout(group);
outerLayout->addWidget(group);
return group;
return {StartupTabHome, StartupTabVisualDeckStorage, StartupTabDeckStorage,
StartupTabReplays, StartupTabDeckEditor, StartupTabVisualDeckEditor};
}
} // namespace
@ -31,45 +30,34 @@ PreferencesSetupPage::PreferencesSetupPage(QWidget *parent) : FirstRunWizardPage
auto *content = new QWidget;
auto *contentLayout = new QVBoxLayout(content);
appearanceGroup = makeGroup(content, contentLayout);
styleUserListCheckBox = new QCheckBox(appearanceGroup);
cardScalingCheckBox = new QCheckBox(appearanceGroup);
roundCardCornersCheckBox = new QCheckBox(appearanceGroup);
displayCardNamesCheckBox = new QCheckBox(appearanceGroup);
autoRotateCardsCheckBox = new QCheckBox(appearanceGroup);
tapAnimationCheckBox = new QCheckBox(appearanceGroup);
appearanceGroup->layout()->addWidget(styleUserListCheckBox);
appearanceGroup->layout()->addWidget(cardScalingCheckBox);
appearanceGroup->layout()->addWidget(roundCardCornersCheckBox);
appearanceGroup->layout()->addWidget(displayCardNamesCheckBox);
appearanceGroup->layout()->addWidget(autoRotateCardsCheckBox);
appearanceGroup->layout()->addWidget(tapAnimationCheckBox);
notificationsGroup = makeGroup(content, contentLayout);
notificationsEnabledCheckBox = new QCheckBox(notificationsGroup);
soundEnabledCheckBox = new QCheckBox(notificationsGroup);
notificationsGroup->layout()->addWidget(notificationsEnabledCheckBox);
notificationsGroup->layout()->addWidget(soundEnabledCheckBox);
gameplayGroup = makeGroup(content, contentLayout);
gameplayGroup = new QGroupBox(content);
auto *gameplayLayout = new QVBoxLayout(gameplayGroup);
contentLayout->addWidget(gameplayGroup);
doubleClickToPlayCheckBox = new QCheckBox(gameplayGroup);
horizontalHandCheckBox = new QCheckBox(gameplayGroup);
playToStackCheckBox = new QCheckBox(gameplayGroup);
gameplayGroup->layout()->addWidget(doubleClickToPlayCheckBox);
gameplayGroup->layout()->addWidget(horizontalHandCheckBox);
gameplayGroup->layout()->addWidget(playToStackCheckBox);
gameplayLayout->addWidget(doubleClickToPlayCheckBox);
gameplayLayout->addWidget(horizontalHandCheckBox);
gameplayLayout->addWidget(playToStackCheckBox);
menuGroup = makeGroup(content, contentLayout);
showShortcutsCheckBox = new QCheckBox(menuGroup);
menuGroup->layout()->addWidget(showShortcutsCheckBox);
notificationsGroup = new QGroupBox(content);
auto *notificationsLayout = new QVBoxLayout(notificationsGroup);
contentLayout->addWidget(notificationsGroup);
notificationsEnabledCheckBox = new QCheckBox(notificationsGroup);
soundEnabledCheckBox = new QCheckBox(notificationsGroup);
notificationsLayout->addWidget(notificationsEnabledCheckBox);
notificationsLayout->addWidget(soundEnabledCheckBox);
dataGroup = makeGroup(content, contentLayout);
picDownloadCheckBox = new QCheckBox(dataGroup);
checkUpdatesOnStartupCheckBox = new QCheckBox(dataGroup);
showTipsOnStartupCheckBox = new QCheckBox(dataGroup);
dataGroup->layout()->addWidget(picDownloadCheckBox);
dataGroup->layout()->addWidget(checkUpdatesOnStartupCheckBox);
dataGroup->layout()->addWidget(showTipsOnStartupCheckBox);
startupGroup = new QGroupBox(content);
auto *startupForm = new QFormLayout(startupGroup);
contentLayout->addWidget(startupGroup);
startupTabLabel = new QLabel(startupGroup);
startupTabSelector = new QComboBox(startupGroup);
startupTabSelector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
for (StartupTab tab : wizardStartupTabOrder()) {
startupTabSelector->addItem(QString(), tab); // texts set in retranslateUi
}
startupForm->addRow(startupTabLabel, startupTabSelector);
contentLayout->addStretch();
@ -83,35 +71,23 @@ PreferencesSetupPage::PreferencesSetupPage(QWidget *parent) : FirstRunWizardPage
SettingsCache &settings = SettingsCache::instance();
connect(styleUserListCheckBox, &QCheckBox::toggled, &settings.appearance(), &AppearanceSettings::setStyleUserList);
connect(cardScalingCheckBox, &QCheckBox::toggled, &settings.cardsDisplay(), &CardsDisplaySettings::setCardScaling);
connect(roundCardCornersCheckBox, &QCheckBox::toggled, &settings.cardsDisplay(),
&CardsDisplaySettings::setRoundCardCorners);
connect(displayCardNamesCheckBox, &QCheckBox::toggled, &settings.cardsDisplay(),
&CardsDisplaySettings::setDisplayCardNames);
connect(autoRotateCardsCheckBox, &QCheckBox::toggled, &settings.cardsDisplay(),
&CardsDisplaySettings::setAutoRotateSidewaysLayoutCards);
connect(tapAnimationCheckBox, &QCheckBox::toggled, &settings.cardsDisplay(),
&CardsDisplaySettings::setTapAnimation);
connect(notificationsEnabledCheckBox, &QCheckBox::toggled, &settings.userInterface(),
&InterfaceSettings::setNotificationsEnabled);
connect(soundEnabledCheckBox, &QCheckBox::toggled, &settings.sound(), &SoundSettings::setSoundEnabled);
connect(doubleClickToPlayCheckBox, &QCheckBox::toggled, &settings.userInterface(),
&InterfaceSettings::setDoubleClickToPlay);
connect(horizontalHandCheckBox, &QCheckBox::toggled, &settings.userInterface(),
&InterfaceSettings::setHorizontalHand);
connect(playToStackCheckBox, &QCheckBox::toggled, &settings.userInterface(), &InterfaceSettings::setPlayToStack);
connect(showShortcutsCheckBox, &QCheckBox::toggled, &settings.userInterface(),
&InterfaceSettings::setShowShortcuts);
connect(notificationsEnabledCheckBox, &QCheckBox::toggled, &settings.userInterface(),
&InterfaceSettings::setNotificationsEnabled);
connect(soundEnabledCheckBox, &QCheckBox::toggled, &settings.sound(), &SoundSettings::setSoundEnabled);
connect(soundEnabledCheckBox, &QCheckBox::toggled, soundEngine, &SoundEngine::testSound);
connect(picDownloadCheckBox, &QCheckBox::toggled, &settings.downloads(), &DownloadSettings::setPicDownload);
connect(checkUpdatesOnStartupCheckBox, &QCheckBox::toggled, &settings.updates(),
&UpdatesSettings::setCheckUpdatesOnStartup);
connect(showTipsOnStartupCheckBox, &QCheckBox::toggled, &settings.personal(),
&PersonalSettings::setShowTipsOnStartup);
connect(startupTabSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index) {
if (index < 0) {
return;
}
SettingsCache::instance().tabs().setStartupTabIndex(startupTabSelector->itemData(index).toInt());
});
retranslateUi();
}
@ -120,25 +96,14 @@ void PreferencesSetupPage::initializePage()
{
SettingsCache &settings = SettingsCache::instance();
styleUserListCheckBox->setChecked(settings.appearance().getStyleUserList());
cardScalingCheckBox->setChecked(settings.cardsDisplay().getScaleCards());
roundCardCornersCheckBox->setChecked(settings.cardsDisplay().getRoundCardCorners());
displayCardNamesCheckBox->setChecked(settings.cardsDisplay().getDisplayCardNames());
autoRotateCardsCheckBox->setChecked(settings.cardsDisplay().getAutoRotateSidewaysLayoutCards());
tapAnimationCheckBox->setChecked(settings.cardsDisplay().getTapAnimation());
notificationsEnabledCheckBox->setChecked(settings.userInterface().getNotificationsEnabled());
soundEnabledCheckBox->setChecked(settings.sound().getSoundEnabled());
doubleClickToPlayCheckBox->setChecked(settings.userInterface().getDoubleClickToPlay());
horizontalHandCheckBox->setChecked(settings.userInterface().getHorizontalHand());
playToStackCheckBox->setChecked(settings.userInterface().getPlayToStack());
showShortcutsCheckBox->setChecked(settings.userInterface().getShowShortcuts());
notificationsEnabledCheckBox->setChecked(settings.userInterface().getNotificationsEnabled());
soundEnabledCheckBox->setChecked(settings.sound().getSoundEnabled());
picDownloadCheckBox->setChecked(settings.downloads().getPicDownload());
checkUpdatesOnStartupCheckBox->setChecked(settings.updates().getCheckUpdatesOnStartup());
showTipsOnStartupCheckBox->setChecked(settings.personal().getShowTipsOnStartup());
startupTabSelector->setCurrentIndex(startupTabSelector->findData(settings.tabs().getStartupTabIndex()));
}
bool PreferencesSetupPage::isSkippable() const
@ -158,30 +123,51 @@ QString PreferencesSetupPage::stepSubtitle() const
void PreferencesSetupPage::retranslateUi()
{
appearanceGroup->setTitle(tr("Appearance"));
styleUserListCheckBox->setText(tr("Use the styled user list (avatars, role colours)"));
cardScalingCheckBox->setText(tr("Scale cards to fit the window"));
roundCardCornersCheckBox->setText(tr("Round card corners"));
displayCardNamesCheckBox->setText(tr("Display card names on pictured cards"));
autoRotateCardsCheckBox->setText(tr("Auto-rotate sideways layout cards"));
tapAnimationCheckBox->setText(tr("Animate tapping cards"));
gameplayGroup->setTitle(tr("Gameplay"));
doubleClickToPlayCheckBox->setText(tr("Double-click cards to play them"));
doubleClickToPlayCheckBox->setToolTip(tr("When disabled, a single click plays the selected card onto the table."));
horizontalHandCheckBox->setText(tr("Display hand horizontally"));
horizontalHandCheckBox->setToolTip(
tr("Shows your hand as a row along the bottom of the table instead of a column beside it."));
playToStackCheckBox->setText(tr("Play all nonlands onto the stack by default"));
playToStackCheckBox->setToolTip(
tr("Cards you play appear on the stack so other players can respond to them, as in a tabletop game."));
notificationsGroup->setTitle(tr("Notifications && Sound"));
notificationsEnabledCheckBox->setText(tr("Show desktop notifications"));
soundEnabledCheckBox->setText(tr("Play sound effects"));
gameplayGroup->setTitle(tr("Gameplay"));
doubleClickToPlayCheckBox->setText(tr("Double-click a card to play it"));
horizontalHandCheckBox->setText(tr("Display hand horizontally"));
playToStackCheckBox->setText(tr("Play cards to top of stack"));
menuGroup->setTitle(tr("Menus"));
showShortcutsCheckBox->setText(tr("Show keyboard shortcuts in menus"));
dataGroup->setTitle(tr("Updates && Data"));
picDownloadCheckBox->setText(tr("Automatically download card images"));
picDownloadCheckBox->setToolTip(tr("Turn this off if you're on a limited connection — "
"card art just won't load until you turn it back on."));
checkUpdatesOnStartupCheckBox->setText(tr("Check for client updates on startup"));
showTipsOnStartupCheckBox->setText(tr("Show tip of the day on startup"));
startupGroup->setTitle(tr("Startup"));
startupTabLabel->setText(tr("Startup tab:"));
const QList<StartupTab> tabs = wizardStartupTabOrder();
for (int i = 0; i < tabs.size(); ++i) {
QString name;
switch (tabs[i]) {
case StartupTabHome:
name = tr("Home");
break;
case StartupTabVisualDeckStorage:
name = tr("Visual Deck Storage");
break;
case StartupTabDeckStorage:
name = tr("Deck Storage");
break;
case StartupTabReplays:
name = tr("Game Replays");
break;
case StartupTabDeckEditor:
name = tr("Deck Editor");
break;
case StartupTabVisualDeckEditor:
name = tr("Visual Deck Editor");
break;
case StartupTabServer:
name = tr("Server");
break;
case StartupTabServerRoom:
name = tr("Server Room");
break;
}
startupTabSelector->setItemText(i, name);
}
}

View file

@ -4,7 +4,9 @@
#include "../first_run_wizard_page.h"
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
/** @brief A curated subset of settings for the user to adjust.
**/
@ -22,30 +24,18 @@ public:
void retranslateUi() override;
private:
QGroupBox *appearanceGroup;
QCheckBox *styleUserListCheckBox;
QCheckBox *cardScalingCheckBox;
QCheckBox *roundCardCornersCheckBox;
QCheckBox *displayCardNamesCheckBox;
QCheckBox *autoRotateCardsCheckBox;
QCheckBox *tapAnimationCheckBox;
QGroupBox *notificationsGroup;
QCheckBox *notificationsEnabledCheckBox;
QCheckBox *soundEnabledCheckBox;
QGroupBox *gameplayGroup;
QCheckBox *doubleClickToPlayCheckBox;
QCheckBox *horizontalHandCheckBox;
QCheckBox *playToStackCheckBox;
QGroupBox *menuGroup;
QCheckBox *showShortcutsCheckBox;
QGroupBox *notificationsGroup;
QCheckBox *notificationsEnabledCheckBox;
QCheckBox *soundEnabledCheckBox;
QGroupBox *dataGroup;
QCheckBox *picDownloadCheckBox;
QCheckBox *checkUpdatesOnStartupCheckBox;
QCheckBox *showTipsOnStartupCheckBox;
QGroupBox *startupGroup;
QLabel *startupTabLabel;
QComboBox *startupTabSelector;
};
#endif // PREFERENCES_SETUP_PAGE_H

View file

@ -1,6 +1,16 @@
#include "welcome_page.h"
#include "../../../../main.h"
#include "../../client/settings/cache_settings.h"
#include "../../settings_page/general_settings_page.h"
#include "libcockatrice/settings/personal_settings.h"
#include <QApplication>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLocale>
#include <QTranslator>
#include <QVBoxLayout>
WelcomePage::WelcomePage(QWidget *parent) : FirstRunWizardPage(parent)
@ -9,14 +19,51 @@ WelcomePage::WelcomePage(QWidget *parent) : FirstRunWizardPage(parent)
bodyLabel->setWordWrap(true);
bodyLabel->setAlignment(Qt::AlignCenter);
languageLabel = new QLabel(this);
langCombo = new QComboBox(this);
for (const QString &code : GeneralSettingsPage::findQmFiles()) {
langCombo->addItem(GeneralSettingsPage::languageName(code), code);
}
QString current = SettingsCache::instance().personal().getLang();
if (current.isEmpty()) {
current = QLocale::system().name();
}
int index = langCombo->findData(current);
if (index < 0) {
index = langCombo->findData(current.section('_', 0, 0));
}
if (index >= 0) {
langCombo->setCurrentIndex(index);
}
connect(langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &WelcomePage::languageChanged);
auto *languageRow = new QHBoxLayout;
languageRow->addStretch();
languageRow->addWidget(languageLabel);
languageRow->addWidget(langCombo);
languageRow->addStretch();
auto *layout = new QVBoxLayout(this);
layout->addStretch();
layout->addWidget(bodyLabel);
layout->addStretch();
layout->addLayout(languageRow);
retranslateUi();
}
void WelcomePage::languageChanged(int index)
{
if (index < 0) {
return;
}
SettingsCache::instance().personal().setLang(langCombo->itemData(index).toString());
qApp->removeTranslator(translator); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
installNewTranslator();
}
QString WelcomePage::stepTitle() const
{
return tr("Welcome!");
@ -28,4 +75,5 @@ void WelcomePage::retranslateUi()
"we'll grab the card database, pick a look you like, "
"and get you ready to connect to a server.\n\n"
"You can change any of this later from Settings."));
languageLabel->setText(tr("Language:"));
}

View file

@ -3,6 +3,7 @@
#include "../first_run_wizard_page.h"
class QComboBox;
class QLabel;
class WelcomePage : public FirstRunWizardPage
@ -15,8 +16,13 @@ public:
QString stepTitle() const override;
void retranslateUi() override;
private slots:
void languageChanged(int index);
private:
QLabel *bodyLabel;
QLabel *languageLabel;
QComboBox *langCombo;
};
#endif // WELCOME_PAGE_H

View file

@ -20,6 +20,9 @@ public:
GeneralSettingsPage();
void retranslateUi() override;
static QStringList findQmFiles();
static QString languageName(const QString &lang);
private slots:
void deckPathButtonClicked();
void filtersPathButtonClicked();
@ -33,9 +36,6 @@ private slots:
void updateStartupServerControlsVisibility();
private:
QStringList findQmFiles();
QString languageName(const QString &lang);
QGroupBox *languageGroupBox;
QGroupBox *versionGroupBox;
QGroupBox *cardDatabaseGroupBox;