From 390fd64a74502b3127f3f23dc868cfd1069c1318 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 1 Oct 2020 22:04:38 +0200 Subject: [PATCH] Save initial settings --- src/settings/appearancesettingspage.cpp | 2 + src/settings/backendsettingspage.cpp | 91 ++++++++++++---------- src/settings/backendsettingspage.h | 2 - src/settings/behavioursettingspage.cpp | 3 +- src/settings/collectionsettingspage.cpp | 9 ++- src/settings/contextsettingspage.cpp | 3 +- src/settings/coverssettingspage.cpp | 2 + src/settings/lyricssettingspage.cpp | 2 + src/settings/moodbarsettingspage.cpp | 2 + src/settings/networkproxysettingspage.cpp | 1 + src/settings/notificationssettingspage.cpp | 3 +- src/settings/notificationssettingspage.h | 2 +- src/settings/playlistsettingspage.cpp | 2 + src/settings/qobuzsettingspage.cpp | 1 + src/settings/scrobblersettingspage.cpp | 3 + src/settings/shortcutssettingspage.cpp | 47 ++++++----- src/settings/shortcutssettingspage.h | 1 - src/settings/subsonicsettingspage.cpp | 1 + src/settings/tidalsettingspage.cpp | 1 + 19 files changed, 107 insertions(+), 71 deletions(-) diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index 611007971..a01fb1adf 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -138,6 +138,8 @@ AppearanceSettingsPage::~AppearanceSettingsPage() { void AppearanceSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + s.beginGroup(kSettingsGroup); QPalette p = QApplication::palette(); diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp index 417289a93..f3b3ed6f2 100644 --- a/src/settings/backendsettingspage.cpp +++ b/src/settings/backendsettingspage.cpp @@ -71,13 +71,10 @@ BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog) : SettingsPage( ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).width("-WW.W dB")); #endif - s_.beginGroup(BackendSettingsPage::kSettingsGroup); - } BackendSettingsPage::~BackendSettingsPage() { - s_.endGroup(); delete ui_; } @@ -87,7 +84,12 @@ void BackendSettingsPage::Load() { configloaded_ = false; engineloaded_ = false; - Engine::EngineType enginetype = Engine::EngineTypeFromName(s_.value("engine", EngineName(Engine::None)).toString()); + QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + + s.beginGroup(kSettingsGroup); + + Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::None)).toString()); if (enginetype == Engine::None && engine()) enginetype = engine()->type(); ui_->combobox_engine->clear(); @@ -99,21 +101,21 @@ void BackendSettingsPage::Load() { #endif enginetype_current_ = enginetype; - output_current_ = s_.value("output", QString()).toString(); - device_current_ = s_.value("device", QVariant()); + output_current_ = s.value("output", QString()).toString(); + device_current_ = s.value("device", QVariant()); ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast(enginetype))); if (EngineInitialised()) Load_Engine(enginetype); - ui_->checkbox_volume_control->setChecked(s_.value("volume_control", true).toBool()); + ui_->checkbox_volume_control->setChecked(s.value("volume_control", true).toBool()); - ui_->spinbox_bufferduration->setValue(s_.value("bufferduration", 4000).toInt()); - ui_->slider_bufferminfill->setValue(s_.value("bufferminfill", 33).toInt()); + ui_->spinbox_bufferduration->setValue(s.value("bufferduration", 4000).toInt()); + ui_->slider_bufferminfill->setValue(s.value("bufferminfill", 33).toInt()); - ui_->checkbox_replaygain->setChecked(s_.value("rgenabled", false).toBool()); - ui_->combobox_replaygainmode->setCurrentIndex(s_.value("rgmode", 0).toInt()); - ui_->stickslider_replaygainpreamp->setValue(s_.value("rgpreamp", 0.0).toDouble() * 10 + 150); - ui_->checkbox_replaygaincompression->setChecked(s_.value("rgcompression", true).toBool()); + ui_->checkbox_replaygain->setChecked(s.value("rgenabled", false).toBool()); + ui_->combobox_replaygainmode->setCurrentIndex(s.value("rgmode", 0).toInt()); + ui_->stickslider_replaygainpreamp->setValue(s.value("rgpreamp", 0.0).toDouble() * 10 + 150); + ui_->checkbox_replaygaincompression->setChecked(s.value("rgcompression", true).toBool()); #if defined(HAVE_ALSA) bool fade_default = false; @@ -121,18 +123,18 @@ void BackendSettingsPage::Load() { bool fade_default = true; #endif - ui_->checkbox_fadeout_stop->setChecked(s_.value("FadeoutEnabled", fade_default).toBool()); - ui_->checkbox_fadeout_cross->setChecked(s_.value("CrossfadeEnabled", fade_default).toBool()); - ui_->checkbox_fadeout_auto->setChecked(s_.value("AutoCrossfadeEnabled", false).toBool()); - ui_->checkbox_fadeout_samealbum->setChecked(s_.value("NoCrossfadeSameAlbum", true).toBool()); - ui_->checkbox_fadeout_pauseresume->setChecked(s_.value("FadeoutPauseEnabled", false).toBool()); - ui_->spinbox_fadeduration->setValue(s_.value("FadeoutDuration", 2000).toInt()); - ui_->spinbox_fadeduration_pauseresume->setValue(s_.value("FadeoutPauseDuration", 250).toInt()); + ui_->checkbox_fadeout_stop->setChecked(s.value("FadeoutEnabled", fade_default).toBool()); + ui_->checkbox_fadeout_cross->setChecked(s.value("CrossfadeEnabled", fade_default).toBool()); + ui_->checkbox_fadeout_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool()); + ui_->checkbox_fadeout_samealbum->setChecked(s.value("NoCrossfadeSameAlbum", true).toBool()); + ui_->checkbox_fadeout_pauseresume->setChecked(s.value("FadeoutPauseEnabled", false).toBool()); + ui_->spinbox_fadeduration->setValue(s.value("FadeoutDuration", 2000).toInt()); + ui_->spinbox_fadeduration_pauseresume->setValue(s.value("FadeoutPauseDuration", 250).toInt()); #if defined(HAVE_ALSA) ui_->lineedit_device->show(); ui_->widget_alsa_plugin->show(); - int alsaplug_int = alsa_plugin(s_.value("alsaplugin", 0).toInt()); + int alsaplug_int = alsa_plugin(s.value("alsaplugin", 0).toInt()); if (alsa_plugin(alsaplug_int)) { alsa_plugin alsaplugin = alsa_plugin(alsaplug_int); switch (alsaplugin) { @@ -199,6 +201,8 @@ void BackendSettingsPage::Load() { set_changed(); } + s.endGroup(); + } bool BackendSettingsPage::EngineInitialised() { @@ -396,33 +400,38 @@ void BackendSettingsPage::Save() { else if (ui_->combobox_device->currentText() == "Custom") device_value = ui_->lineedit_device->text(); else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value(); - s_.setValue("engine", EngineName(enginetype)); - s_.setValue("output", output_name); - s_.setValue("device", device_value); + QSettings s; + s.beginGroup(kSettingsGroup); - s_.setValue("bufferduration", ui_->spinbox_bufferduration->value()); - s_.setValue("bufferminfill", ui_->slider_bufferminfill->value()); + s.setValue("engine", EngineName(enginetype)); + s.setValue("output", output_name); + s.setValue("device", device_value); - s_.setValue("rgenabled", ui_->checkbox_replaygain->isChecked()); - s_.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex()); - s_.setValue("rgpreamp", float(ui_->stickslider_replaygainpreamp->value()) / 10 - 15); - s_.setValue("rgcompression", ui_->checkbox_replaygaincompression->isChecked()); + s.setValue("bufferduration", ui_->spinbox_bufferduration->value()); + s.setValue("bufferminfill", ui_->slider_bufferminfill->value()); - s_.setValue("FadeoutEnabled", ui_->checkbox_fadeout_stop->isChecked()); - s_.setValue("CrossfadeEnabled", ui_->checkbox_fadeout_cross->isChecked()); - s_.setValue("AutoCrossfadeEnabled", ui_->checkbox_fadeout_auto->isChecked()); - s_.setValue("NoCrossfadeSameAlbum", ui_->checkbox_fadeout_samealbum->isChecked()); - s_.setValue("FadeoutPauseEnabled", ui_->checkbox_fadeout_pauseresume->isChecked()); - s_.setValue("FadeoutDuration", ui_->spinbox_fadeduration->value()); - s_.setValue("FadeoutPauseDuration", ui_->spinbox_fadeduration_pauseresume->value()); + s.setValue("rgenabled", ui_->checkbox_replaygain->isChecked()); + s.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex()); + s.setValue("rgpreamp", float(ui_->stickslider_replaygainpreamp->value()) / 10 - 15); + s.setValue("rgcompression", ui_->checkbox_replaygaincompression->isChecked()); + + s.setValue("FadeoutEnabled", ui_->checkbox_fadeout_stop->isChecked()); + s.setValue("CrossfadeEnabled", ui_->checkbox_fadeout_cross->isChecked()); + s.setValue("AutoCrossfadeEnabled", ui_->checkbox_fadeout_auto->isChecked()); + s.setValue("NoCrossfadeSameAlbum", ui_->checkbox_fadeout_samealbum->isChecked()); + s.setValue("FadeoutPauseEnabled", ui_->checkbox_fadeout_pauseresume->isChecked()); + s.setValue("FadeoutDuration", ui_->spinbox_fadeduration->value()); + s.setValue("FadeoutPauseDuration", ui_->spinbox_fadeduration_pauseresume->value()); #ifdef HAVE_ALSA - if (ui_->radiobutton_alsa_hw->isChecked()) s_.setValue("alsaplugin", static_cast(alsa_plugin::alsa_hw)); - else if (ui_->radiobutton_alsa_plughw->isChecked()) s_.setValue("alsaplugin", static_cast(alsa_plugin::alsa_plughw)); - else s_.remove("alsaplugin"); + if (ui_->radiobutton_alsa_hw->isChecked()) s.setValue("alsaplugin", static_cast(alsa_plugin::alsa_hw)); + else if (ui_->radiobutton_alsa_plughw->isChecked()) s.setValue("alsaplugin", static_cast(alsa_plugin::alsa_plughw)); + else s.remove("alsaplugin"); #endif - s_.setValue("volume_control", ui_->checkbox_volume_control->isChecked()); + s.setValue("volume_control", ui_->checkbox_volume_control->isChecked()); + + s.endGroup(); } diff --git a/src/settings/backendsettingspage.h b/src/settings/backendsettingspage.h index 049c73675..b8d89a4a8 100644 --- a/src/settings/backendsettingspage.h +++ b/src/settings/backendsettingspage.h @@ -25,7 +25,6 @@ #include #include #include -#include #include "engine/enginetype.h" #include "dialogs/errordialog.h" @@ -85,7 +84,6 @@ private: void SwitchALSADevices(alsa_plugin alsaplugin); #endif - QSettings s_; bool configloaded_; bool engineloaded_; ErrorDialog errordialog_; diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index 4b88d0458..35fef0970 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -149,8 +149,9 @@ BehaviourSettingsPage::~BehaviourSettingsPage() { void BehaviourSettingsPage::Load() { QSettings s; - + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(kSettingsGroup); + #ifndef Q_OS_MACOS if (QSystemTrayIcon::isSystemTrayAvailable()) { ui_->checkbox_showtrayicon->setEnabled(true); diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp index 8f1789924..9970808d9 100644 --- a/src/settings/collectionsettingspage.cpp +++ b/src/settings/collectionsettingspage.cpp @@ -96,17 +96,17 @@ CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; } void CollectionSettingsPage::Add() { - QSettings settings; - settings.beginGroup(kSettingsGroup); + QSettings s; + s.beginGroup(kSettingsGroup); - QString path(settings.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString()); + QString path(s.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString()); path = QFileDialog::getExistingDirectory(this, tr("Add directory..."), path); if (!path.isNull()) { dialog()->collection_directory_model()->AddDirectory(path); } - settings.setValue("last_path", path); + s.setValue("last_path", path); set_changed(); @@ -149,6 +149,7 @@ void CollectionSettingsPage::Load() { } QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(kSettingsGroup); ui_->auto_open->setChecked(s.value("auto_open", true).toBool()); diff --git a/src/settings/contextsettingspage.cpp b/src/settings/contextsettingspage.cpp index 9479500c6..b46b370ad 100644 --- a/src/settings/contextsettingspage.cpp +++ b/src/settings/contextsettingspage.cpp @@ -125,8 +125,9 @@ ContextSettingsPage::~ContextSettingsPage() { delete ui_; } void ContextSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); - s.beginGroup(ContextSettingsPage::kSettingsGroup); + s.beginGroup(kSettingsGroup); ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString()); ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString()); diff --git a/src/settings/coverssettingspage.cpp b/src/settings/coverssettingspage.cpp index 1f712463c..0b86d6475 100644 --- a/src/settings/coverssettingspage.cpp +++ b/src/settings/coverssettingspage.cpp @@ -73,6 +73,8 @@ CoversSettingsPage::~CoversSettingsPage() { delete ui_; } void CoversSettingsPage::Load() { + if (!QSettings().contains(kSettingsGroup)) set_changed(); + ui_->providers->clear(); QList cover_providers_sorted = dialog()->app()->cover_providers()->List(); diff --git a/src/settings/lyricssettingspage.cpp b/src/settings/lyricssettingspage.cpp index a002c0116..4a8016475 100644 --- a/src/settings/lyricssettingspage.cpp +++ b/src/settings/lyricssettingspage.cpp @@ -73,6 +73,8 @@ LyricsSettingsPage::~LyricsSettingsPage() { delete ui_; } void LyricsSettingsPage::Load() { + if (!QSettings().contains(kSettingsGroup)) set_changed(); + ui_->providers->clear(); QList lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List(); diff --git a/src/settings/moodbarsettingspage.cpp b/src/settings/moodbarsettingspage.cpp index f861a0964..4d9af3191 100644 --- a/src/settings/moodbarsettingspage.cpp +++ b/src/settings/moodbarsettingspage.cpp @@ -66,6 +66,8 @@ MoodbarSettingsPage::~MoodbarSettingsPage() { delete ui_; } void MoodbarSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + s.beginGroup(kSettingsGroup); ui_->moodbar_enabled->setChecked(s.value("enabled", false).toBool()); ui_->moodbar_show->setChecked(s.value("show", false).toBool()); diff --git a/src/settings/networkproxysettingspage.cpp b/src/settings/networkproxysettingspage.cpp index 050ac1c96..cb216fbd2 100644 --- a/src/settings/networkproxysettingspage.cpp +++ b/src/settings/networkproxysettingspage.cpp @@ -51,6 +51,7 @@ NetworkProxySettingsPage::~NetworkProxySettingsPage() { delete ui_; } void NetworkProxySettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(NetworkProxyFactory::kSettingsGroup); NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode(s.value("mode", NetworkProxyFactory::Mode_System).toInt()); diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index 6140c9084..8406cb00f 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -56,7 +56,7 @@ class QHideEvent; class QShowEvent; -const char *NotificationsSettingsPage::kSettingsGroup = "Notifications"; +//const char *NotificationsSettingsPage::kSettingsGroup = "Notifications"; NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_NotificationsSettingsPage), pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) { @@ -142,6 +142,7 @@ void NotificationsSettingsPage::hideEvent(QHideEvent*) { void NotificationsSettingsPage::Load() { QSettings s; + if (!s.contains(OSDBase::kSettingsGroup)) set_changed(); s.beginGroup(OSDBase::kSettingsGroup); OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour(s.value("Behaviour", OSDBase::Native).toInt()); diff --git a/src/settings/notificationssettingspage.h b/src/settings/notificationssettingspage.h index 34da4e35f..2e2d8c97b 100644 --- a/src/settings/notificationssettingspage.h +++ b/src/settings/notificationssettingspage.h @@ -43,7 +43,7 @@ class NotificationsSettingsPage : public SettingsPage { explicit NotificationsSettingsPage(SettingsDialog *dialog); ~NotificationsSettingsPage() override; - static const char *kSettingsGroup; + //static const char *kSettingsGroup; void Load() override; void Save() override; diff --git a/src/settings/playlistsettingspage.cpp b/src/settings/playlistsettingspage.cpp index 4d38639c4..506e135fd 100644 --- a/src/settings/playlistsettingspage.cpp +++ b/src/settings/playlistsettingspage.cpp @@ -49,6 +49,8 @@ PlaylistSettingsPage::~PlaylistSettingsPage() { void PlaylistSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + s.beginGroup(kSettingsGroup); #ifdef Q_OS_MACOS diff --git a/src/settings/qobuzsettingspage.cpp b/src/settings/qobuzsettingspage.cpp index db2e422c0..2985e5054 100644 --- a/src/settings/qobuzsettingspage.cpp +++ b/src/settings/qobuzsettingspage.cpp @@ -73,6 +73,7 @@ QobuzSettingsPage::~QobuzSettingsPage() { delete ui_; } void QobuzSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(kSettingsGroup); ui_->enable->setChecked(s.value("enabled", false).toBool()); diff --git a/src/settings/scrobblersettingspage.cpp b/src/settings/scrobblersettingspage.cpp index 4c7cf324c..c4289efee 100644 --- a/src/settings/scrobblersettingspage.cpp +++ b/src/settings/scrobblersettingspage.cpp @@ -89,6 +89,9 @@ ScrobblerSettingsPage::~ScrobblerSettingsPage() { delete ui_; } void ScrobblerSettingsPage::Load() { + QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + ui_->checkbox_enable->setChecked(scrobbler_->IsEnabled()); ui_->checkbox_scrobble_button->setChecked(scrobbler_->ScrobbleButton()); ui_->checkbox_love_button->setChecked(scrobbler_->LoveButton()); diff --git a/src/settings/shortcutssettingspage.cpp b/src/settings/shortcutssettingspage.cpp index a0a3fd9bf..a7b0f3541 100644 --- a/src/settings/shortcutssettingspage.cpp +++ b/src/settings/shortcutssettingspage.cpp @@ -65,8 +65,6 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog) ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); setWindowIcon(IconLoader::Load("keyboard")); - settings_.beginGroup(kSettingsGroup); - connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*))); connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked())); connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked())); @@ -102,6 +100,10 @@ bool GlobalShortcutsSettingsPage::IsEnabled() const { void GlobalShortcutsSettingsPage::Load() { + QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); + s.beginGroup(kSettingsGroup); + GlobalShortcuts *manager = dialog()->global_shortcuts_manager(); if (!initialised_) { @@ -128,32 +130,32 @@ void GlobalShortcutsSettingsPage::Load() { else { qLog(Debug) << "X11 backend is unavailable."; ui_->widget_x11->hide(); - settings_.setValue("use_x11", false); + s.setValue("use_x11", false); } - for (const GlobalShortcuts::Shortcut &s : manager->shortcuts().values()) { + for (const GlobalShortcuts::Shortcut &i : manager->shortcuts().values()) { Shortcut shortcut; - shortcut.s = s; - shortcut.key = s.action->shortcut(); - shortcut.item = new QTreeWidgetItem(ui_->list, QStringList() << s.action->text() << s.action->shortcut().toString(QKeySequence::NativeText)); - shortcut.item->setData(0, Qt::UserRole, s.id); - shortcuts_[s.id] = shortcut; + shortcut.s = i; + shortcut.key = i.action->shortcut(); + shortcut.item = new QTreeWidgetItem(ui_->list, QStringList() << i.action->text() << i.action->shortcut().toString(QKeySequence::NativeText)); + shortcut.item->setData(0, Qt::UserRole, i.id); + shortcuts_[i.id] = shortcut; } ui_->list->sortItems(0, Qt::AscendingOrder); ItemClicked(ui_->list->topLevelItem(0)); } - for (const Shortcut &s : shortcuts_.values()) { - SetShortcut(s.s.id, s.s.action->shortcut()); + for (const Shortcut &shortcut : shortcuts_.values()) { + SetShortcut(shortcut.s.id, shortcut.s.action->shortcut()); } - bool use_gsd = settings_.value("use_gsd", true).toBool(); + bool use_gsd = s.value("use_gsd", true).toBool(); if (ui_->widget_gsd->isVisibleTo(this)) { ui_->checkbox_gsd->setChecked(use_gsd); } - bool use_x11 = settings_.value("use_x11", false).toBool(); + bool use_x11 = s.value("use_x11", false).toBool(); if (ui_->widget_x11->isVisibleTo(this)) { ui_->checkbox_x11->setChecked(use_x11); } @@ -174,20 +176,27 @@ void GlobalShortcutsSettingsPage::Load() { ui_->label_macos_mavericks->setVisible(macos_version >= 9); #endif // Q_OS_MACOS + s.endGroup(); + Init(ui_->layout_globalshortcutssettingspage->parentWidget()); } void GlobalShortcutsSettingsPage::Save() { - for (const Shortcut &s : shortcuts_.values()) { - s.s.action->setShortcut(s.key); - s.s.shortcut->setKey(s.key); - settings_.setValue(s.s.id, s.key.toString()); + QSettings s; + s.beginGroup(kSettingsGroup); + + for (const Shortcut &shortcut : shortcuts_.values()) { + shortcut.s.action->setShortcut(shortcut.key); + shortcut.s.shortcut->setKey(shortcut.key); + s.setValue(shortcut.s.id, shortcut.key.toString()); } - settings_.setValue("use_gsd", ui_->checkbox_gsd->isChecked()); - settings_.setValue("use_x11", ui_->checkbox_x11->isChecked()); + s.setValue("use_gsd", ui_->checkbox_gsd->isChecked()); + s.setValue("use_x11", ui_->checkbox_x11->isChecked()); + + s.endGroup(); dialog()->global_shortcuts_manager()->ReloadSettings(); diff --git a/src/settings/shortcutssettingspage.h b/src/settings/shortcutssettingspage.h index 729c06843..306582135 100644 --- a/src/settings/shortcutssettingspage.h +++ b/src/settings/shortcutssettingspage.h @@ -81,7 +81,6 @@ class GlobalShortcutsSettingsPage : public SettingsPage { bool initialised_; std::unique_ptr grabber_; - QSettings settings_; QMap shortcuts_; QString current_id_; diff --git a/src/settings/subsonicsettingspage.cpp b/src/settings/subsonicsettingspage.cpp index d388844c9..0d1e4176a 100644 --- a/src/settings/subsonicsettingspage.cpp +++ b/src/settings/subsonicsettingspage.cpp @@ -65,6 +65,7 @@ SubsonicSettingsPage::~SubsonicSettingsPage() { delete ui_; } void SubsonicSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(kSettingsGroup); ui_->enable->setChecked(s.value("enabled", false).toBool()); diff --git a/src/settings/tidalsettingspage.cpp b/src/settings/tidalsettingspage.cpp index 2be864f28..a97bbb70c 100644 --- a/src/settings/tidalsettingspage.cpp +++ b/src/settings/tidalsettingspage.cpp @@ -85,6 +85,7 @@ TidalSettingsPage::~TidalSettingsPage() { delete ui_; } void TidalSettingsPage::Load() { QSettings s; + if (!s.contains(kSettingsGroup)) set_changed(); s.beginGroup(kSettingsGroup); ui_->enable->setChecked(s.value("enabled", false).toBool());