mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Comments and fixes
Took 9 seconds Took 1 minute
This commit is contained in:
parent
37bfd2a8c0
commit
9e084614c0
3 changed files with 64 additions and 10 deletions
|
|
@ -480,6 +480,10 @@ void DlgRegister::newHostSelected(bool state)
|
||||||
portEdit->setPlaceholderText(tr("Communication Port"));
|
portEdit->setPlaceholderText(tr("Communication Port"));
|
||||||
playernameEdit->setDisabled(false);
|
playernameEdit->setDisabled(false);
|
||||||
playernameEdit->clear();
|
playernameEdit->clear();
|
||||||
|
} else {
|
||||||
|
// Rebuild the list so the previously selected host's details are
|
||||||
|
// repopulated (mirrors DlgConnect::newHostSelected).
|
||||||
|
preRebuildComboBoxList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,6 +523,24 @@ void DlgRegister::actOk()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServersSettings &servers = SettingsCache::instance().servers();
|
||||||
|
|
||||||
|
if (newHostButton->isChecked()) {
|
||||||
|
// Persist the new host so it shows up in the Connect dialog later.
|
||||||
|
// The password is never stored: the account is not verified yet.
|
||||||
|
const QString host = hostEdit->text().trimmed();
|
||||||
|
if (!host.isEmpty()) {
|
||||||
|
servers.addNewServer(host, host, portEdit->text().trimmed(), playernameEdit->text().trimmed(), QString(),
|
||||||
|
false);
|
||||||
|
servers.setPrevioushostName(host);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const QString saveName = previousHosts->currentText();
|
||||||
|
if (!saveName.isEmpty() && saveName != placeHolderText) {
|
||||||
|
servers.setPrevioushostName(saveName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,14 @@
|
||||||
#include "../../interface/widgets/general/background_sources.h"
|
#include "../../interface/widgets/general/background_sources.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <libcockatrice/settings/paths_settings.h>
|
||||||
#include <libcockatrice/settings/personal_settings.h>
|
#include <libcockatrice/settings/personal_settings.h>
|
||||||
|
|
||||||
ThemeSetupPage::ThemeSetupPage(QWidget *parent) : FirstRunWizardPage(parent)
|
ThemeSetupPage::ThemeSetupPage(QWidget *parent) : FirstRunWizardPage(parent)
|
||||||
|
|
@ -96,8 +100,10 @@ void ThemeSetupPage::initializePage()
|
||||||
homeTabBackgroundCombo->setCurrentIndex(homeTabIdx >= 0 ? homeTabIdx : 0);
|
homeTabBackgroundCombo->setCurrentIndex(homeTabIdx >= 0 ? homeTabIdx : 0);
|
||||||
homeTabBackgroundCombo->blockSignals(false);
|
homeTabBackgroundCombo->blockSignals(false);
|
||||||
|
|
||||||
|
// Opening the page must not touch the running application's palette:
|
||||||
|
// previews and auto-generation only happen in response to the user
|
||||||
|
// actually changing a control, never on mere page visibility.
|
||||||
paletteDirty = false;
|
paletteDirty = false;
|
||||||
maybeAutoGeneratePalette();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ThemeSetupPage::currentScheme() const
|
QString ThemeSetupPage::currentScheme() const
|
||||||
|
|
@ -156,11 +162,12 @@ void ThemeSetupPage::maybeAutoGeneratePalette()
|
||||||
return; // theme already has something real to show -- leave it alone
|
return; // theme already has something real to show -- leave it alone
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing saved, nothing shipped. Rather than showing flat native Qt
|
// The theme+scheme combination has nothing saved and nothing shipped, and
|
||||||
// colours during the very first thing a new user sees, seed one from
|
// the user just switched to it. Rather than leaving a flat, unstyled look,
|
||||||
// whatever accent QuickSetupPanel currently holds (its own built-in
|
// seed one from whatever accent QuickSetupPanel currently holds and mark
|
||||||
// default the first time through), and mark it dirty so it's written to
|
// it dirty so it's written to disk if the user moves on. Only ever reached
|
||||||
// disk if the user moves on without touching the accent controls.
|
// through user interaction (theme/scheme change, accent drag) -- never on
|
||||||
|
// page open.
|
||||||
PaletteConfig generated =
|
PaletteConfig generated =
|
||||||
PaletteGenerator::fromAccent(quickSetupPanel->accentColor(), quickSetupPanel->intensity(), scheme);
|
PaletteGenerator::fromAccent(quickSetupPanel->accentColor(), quickSetupPanel->intensity(), scheme);
|
||||||
themeManager->previewPalette(generated, scheme);
|
themeManager->previewPalette(generated, scheme);
|
||||||
|
|
@ -170,16 +177,38 @@ void ThemeSetupPage::maybeAutoGeneratePalette()
|
||||||
bool ThemeSetupPage::validatePage()
|
bool ThemeSetupPage::validatePage()
|
||||||
{
|
{
|
||||||
if (paletteDirty) {
|
if (paletteDirty) {
|
||||||
const QString dirPath = themeManager->getAvailableThemes().value(SettingsCache::instance().getThemeName());
|
|
||||||
const QString scheme = resolvedScheme();
|
const QString scheme = resolvedScheme();
|
||||||
PaletteConfig cfg =
|
PaletteConfig cfg =
|
||||||
PaletteGenerator::fromAccent(quickSetupPanel->accentColor(), quickSetupPanel->intensity(), scheme);
|
PaletteGenerator::fromAccent(quickSetupPanel->accentColor(), quickSetupPanel->intensity(), scheme);
|
||||||
ThemeManager::commitPalette(dirPath, scheme, cfg);
|
if (!ThemeManager::commitPalette(writableThemeDir(), scheme, cfg)) {
|
||||||
|
QMessageBox::warning(this, tr("Save failed"),
|
||||||
|
tr("Could not write the theme palette to:\n%1").arg(writableThemeDir()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
themeManager->reloadCurrentTheme();
|
themeManager->reloadCurrentTheme();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ThemeSetupPage::writableThemeDir() const
|
||||||
|
{
|
||||||
|
// Built-in themes resolve to the read-only system themes directory;
|
||||||
|
// palette edits must go to the user themes directory instead, exactly
|
||||||
|
// as PaletteEditorDialog does.
|
||||||
|
const QString dirPath = themeManager->getAvailableThemes().value(SettingsCache::instance().getThemeName());
|
||||||
|
if (!dirPath.isEmpty()) {
|
||||||
|
const QString probe = QDir(dirPath).absoluteFilePath(".cockatrice_write_test");
|
||||||
|
QFile f(probe);
|
||||||
|
if (f.open(QIODevice::WriteOnly)) {
|
||||||
|
f.close();
|
||||||
|
f.remove();
|
||||||
|
return dirPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QDir(SettingsCache::instance().paths().getThemesPath())
|
||||||
|
.absoluteFilePath(SettingsCache::instance().getThemeName());
|
||||||
|
}
|
||||||
|
|
||||||
bool ThemeSetupPage::isSkippable() const
|
bool ThemeSetupPage::isSkippable() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ class QuickSetupPanel;
|
||||||
*
|
*
|
||||||
* Behavior specific to this page (deliberately not pushed down into
|
* Behavior specific to this page (deliberately not pushed down into
|
||||||
* ThemeManager, to avoid changing app-wide behaviour for existing installs):
|
* ThemeManager, to avoid changing app-wide behaviour for existing installs):
|
||||||
* - If the selected theme+scheme has no saved palette and no shipped
|
* - Opening the page never changes the running palette; previews and
|
||||||
|
* auto-generation only happen when the user actually changes a control.
|
||||||
|
* - If a theme+scheme the user selects has no saved palette and no shipped
|
||||||
* default, one is generated from the QuickSetupPanel's current accent so
|
* default, one is generated from the QuickSetupPanel's current accent so
|
||||||
* onboarding never shows a flat, unstyled look. */
|
* the preview doesn't fall back to a flat, unstyled look. */
|
||||||
class ThemeSetupPage : public FirstRunWizardPage
|
class ThemeSetupPage : public FirstRunWizardPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -41,6 +43,7 @@ private:
|
||||||
QString currentScheme() const;
|
QString currentScheme() const;
|
||||||
QString resolvedScheme() const; // "System" -> actual Light/Dark
|
QString resolvedScheme() const; // "System" -> actual Light/Dark
|
||||||
void maybeAutoGeneratePalette();
|
void maybeAutoGeneratePalette();
|
||||||
|
QString writableThemeDir() const;
|
||||||
|
|
||||||
QComboBox *themeCombo;
|
QComboBox *themeCombo;
|
||||||
QComboBox *schemeCombo;
|
QComboBox *schemeCombo;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue