Save initial settings
This commit is contained in:
parent
48ee471def
commit
390fd64a74
|
@ -138,6 +138,8 @@ AppearanceSettingsPage::~AppearanceSettingsPage() {
|
||||||
void AppearanceSettingsPage::Load() {
|
void AppearanceSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
QPalette p = QApplication::palette();
|
QPalette p = QApplication::palette();
|
||||||
|
|
|
@ -71,13 +71,10 @@ BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog) : SettingsPage(
|
||||||
ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).width("-WW.W dB"));
|
ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).width("-WW.W dB"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_.beginGroup(BackendSettingsPage::kSettingsGroup);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendSettingsPage::~BackendSettingsPage() {
|
BackendSettingsPage::~BackendSettingsPage() {
|
||||||
|
|
||||||
s_.endGroup();
|
|
||||||
delete ui_;
|
delete ui_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,7 +84,12 @@ void BackendSettingsPage::Load() {
|
||||||
configloaded_ = false;
|
configloaded_ = false;
|
||||||
engineloaded_ = 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();
|
if (enginetype == Engine::None && engine()) enginetype = engine()->type();
|
||||||
|
|
||||||
ui_->combobox_engine->clear();
|
ui_->combobox_engine->clear();
|
||||||
|
@ -99,21 +101,21 @@ void BackendSettingsPage::Load() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enginetype_current_ = enginetype;
|
enginetype_current_ = enginetype;
|
||||||
output_current_ = s_.value("output", QString()).toString();
|
output_current_ = s.value("output", QString()).toString();
|
||||||
device_current_ = s_.value("device", QVariant());
|
device_current_ = s.value("device", QVariant());
|
||||||
|
|
||||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(enginetype)));
|
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(enginetype)));
|
||||||
if (EngineInitialised()) Load_Engine(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_->spinbox_bufferduration->setValue(s.value("bufferduration", 4000).toInt());
|
||||||
ui_->slider_bufferminfill->setValue(s_.value("bufferminfill", 33).toInt());
|
ui_->slider_bufferminfill->setValue(s.value("bufferminfill", 33).toInt());
|
||||||
|
|
||||||
ui_->checkbox_replaygain->setChecked(s_.value("rgenabled", false).toBool());
|
ui_->checkbox_replaygain->setChecked(s.value("rgenabled", false).toBool());
|
||||||
ui_->combobox_replaygainmode->setCurrentIndex(s_.value("rgmode", 0).toInt());
|
ui_->combobox_replaygainmode->setCurrentIndex(s.value("rgmode", 0).toInt());
|
||||||
ui_->stickslider_replaygainpreamp->setValue(s_.value("rgpreamp", 0.0).toDouble() * 10 + 150);
|
ui_->stickslider_replaygainpreamp->setValue(s.value("rgpreamp", 0.0).toDouble() * 10 + 150);
|
||||||
ui_->checkbox_replaygaincompression->setChecked(s_.value("rgcompression", true).toBool());
|
ui_->checkbox_replaygaincompression->setChecked(s.value("rgcompression", true).toBool());
|
||||||
|
|
||||||
#if defined(HAVE_ALSA)
|
#if defined(HAVE_ALSA)
|
||||||
bool fade_default = false;
|
bool fade_default = false;
|
||||||
|
@ -121,18 +123,18 @@ void BackendSettingsPage::Load() {
|
||||||
bool fade_default = true;
|
bool fade_default = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui_->checkbox_fadeout_stop->setChecked(s_.value("FadeoutEnabled", fade_default).toBool());
|
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_cross->setChecked(s.value("CrossfadeEnabled", fade_default).toBool());
|
||||||
ui_->checkbox_fadeout_auto->setChecked(s_.value("AutoCrossfadeEnabled", false).toBool());
|
ui_->checkbox_fadeout_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool());
|
||||||
ui_->checkbox_fadeout_samealbum->setChecked(s_.value("NoCrossfadeSameAlbum", true).toBool());
|
ui_->checkbox_fadeout_samealbum->setChecked(s.value("NoCrossfadeSameAlbum", true).toBool());
|
||||||
ui_->checkbox_fadeout_pauseresume->setChecked(s_.value("FadeoutPauseEnabled", false).toBool());
|
ui_->checkbox_fadeout_pauseresume->setChecked(s.value("FadeoutPauseEnabled", false).toBool());
|
||||||
ui_->spinbox_fadeduration->setValue(s_.value("FadeoutDuration", 2000).toInt());
|
ui_->spinbox_fadeduration->setValue(s.value("FadeoutDuration", 2000).toInt());
|
||||||
ui_->spinbox_fadeduration_pauseresume->setValue(s_.value("FadeoutPauseDuration", 250).toInt());
|
ui_->spinbox_fadeduration_pauseresume->setValue(s.value("FadeoutPauseDuration", 250).toInt());
|
||||||
|
|
||||||
#if defined(HAVE_ALSA)
|
#if defined(HAVE_ALSA)
|
||||||
ui_->lineedit_device->show();
|
ui_->lineedit_device->show();
|
||||||
ui_->widget_alsa_plugin->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)) {
|
if (alsa_plugin(alsaplug_int)) {
|
||||||
alsa_plugin alsaplugin = alsa_plugin(alsaplug_int);
|
alsa_plugin alsaplugin = alsa_plugin(alsaplug_int);
|
||||||
switch (alsaplugin) {
|
switch (alsaplugin) {
|
||||||
|
@ -199,6 +201,8 @@ void BackendSettingsPage::Load() {
|
||||||
set_changed();
|
set_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BackendSettingsPage::EngineInitialised() {
|
bool BackendSettingsPage::EngineInitialised() {
|
||||||
|
@ -396,33 +400,38 @@ void BackendSettingsPage::Save() {
|
||||||
else if (ui_->combobox_device->currentText() == "Custom") device_value = ui_->lineedit_device->text();
|
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<QVariant>();
|
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value<QVariant>();
|
||||||
|
|
||||||
s_.setValue("engine", EngineName(enginetype));
|
QSettings s;
|
||||||
s_.setValue("output", output_name);
|
s.beginGroup(kSettingsGroup);
|
||||||
s_.setValue("device", device_value);
|
|
||||||
|
|
||||||
s_.setValue("bufferduration", ui_->spinbox_bufferduration->value());
|
s.setValue("engine", EngineName(enginetype));
|
||||||
s_.setValue("bufferminfill", ui_->slider_bufferminfill->value());
|
s.setValue("output", output_name);
|
||||||
|
s.setValue("device", device_value);
|
||||||
|
|
||||||
s_.setValue("rgenabled", ui_->checkbox_replaygain->isChecked());
|
s.setValue("bufferduration", ui_->spinbox_bufferduration->value());
|
||||||
s_.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex());
|
s.setValue("bufferminfill", ui_->slider_bufferminfill->value());
|
||||||
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("rgenabled", ui_->checkbox_replaygain->isChecked());
|
||||||
s_.setValue("CrossfadeEnabled", ui_->checkbox_fadeout_cross->isChecked());
|
s.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex());
|
||||||
s_.setValue("AutoCrossfadeEnabled", ui_->checkbox_fadeout_auto->isChecked());
|
s.setValue("rgpreamp", float(ui_->stickslider_replaygainpreamp->value()) / 10 - 15);
|
||||||
s_.setValue("NoCrossfadeSameAlbum", ui_->checkbox_fadeout_samealbum->isChecked());
|
s.setValue("rgcompression", ui_->checkbox_replaygaincompression->isChecked());
|
||||||
s_.setValue("FadeoutPauseEnabled", ui_->checkbox_fadeout_pauseresume->isChecked());
|
|
||||||
s_.setValue("FadeoutDuration", ui_->spinbox_fadeduration->value());
|
s.setValue("FadeoutEnabled", ui_->checkbox_fadeout_stop->isChecked());
|
||||||
s_.setValue("FadeoutPauseDuration", ui_->spinbox_fadeduration_pauseresume->value());
|
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
|
#ifdef HAVE_ALSA
|
||||||
if (ui_->radiobutton_alsa_hw->isChecked()) s_.setValue("alsaplugin", static_cast<int>(alsa_plugin::alsa_hw));
|
if (ui_->radiobutton_alsa_hw->isChecked()) s.setValue("alsaplugin", static_cast<int>(alsa_plugin::alsa_hw));
|
||||||
else if (ui_->radiobutton_alsa_plughw->isChecked()) s_.setValue("alsaplugin", static_cast<int>(alsa_plugin::alsa_plughw));
|
else if (ui_->radiobutton_alsa_plughw->isChecked()) s.setValue("alsaplugin", static_cast<int>(alsa_plugin::alsa_plughw));
|
||||||
else s_.remove("alsaplugin");
|
else s.remove("alsaplugin");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_.setValue("volume_control", ui_->checkbox_volume_control->isChecked());
|
s.setValue("volume_control", ui_->checkbox_volume_control->isChecked());
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include "engine/enginetype.h"
|
#include "engine/enginetype.h"
|
||||||
#include "dialogs/errordialog.h"
|
#include "dialogs/errordialog.h"
|
||||||
|
@ -85,7 +84,6 @@ private:
|
||||||
void SwitchALSADevices(alsa_plugin alsaplugin);
|
void SwitchALSADevices(alsa_plugin alsaplugin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QSettings s_;
|
|
||||||
bool configloaded_;
|
bool configloaded_;
|
||||||
bool engineloaded_;
|
bool engineloaded_;
|
||||||
ErrorDialog errordialog_;
|
ErrorDialog errordialog_;
|
||||||
|
|
|
@ -149,8 +149,9 @@ BehaviourSettingsPage::~BehaviourSettingsPage() {
|
||||||
void BehaviourSettingsPage::Load() {
|
void BehaviourSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
ui_->checkbox_showtrayicon->setEnabled(true);
|
ui_->checkbox_showtrayicon->setEnabled(true);
|
||||||
|
|
|
@ -96,17 +96,17 @@ CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
||||||
|
|
||||||
void CollectionSettingsPage::Add() {
|
void CollectionSettingsPage::Add() {
|
||||||
|
|
||||||
QSettings settings;
|
QSettings s;
|
||||||
settings.beginGroup(kSettingsGroup);
|
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);
|
path = QFileDialog::getExistingDirectory(this, tr("Add directory..."), path);
|
||||||
|
|
||||||
if (!path.isNull()) {
|
if (!path.isNull()) {
|
||||||
dialog()->collection_directory_model()->AddDirectory(path);
|
dialog()->collection_directory_model()->AddDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setValue("last_path", path);
|
s.setValue("last_path", path);
|
||||||
|
|
||||||
set_changed();
|
set_changed();
|
||||||
|
|
||||||
|
@ -149,6 +149,7 @@ void CollectionSettingsPage::Load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
|
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
|
||||||
|
|
|
@ -125,8 +125,9 @@ ContextSettingsPage::~ContextSettingsPage() { delete ui_; }
|
||||||
void ContextSettingsPage::Load() {
|
void ContextSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
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_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString());
|
||||||
ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString());
|
ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString());
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ CoversSettingsPage::~CoversSettingsPage() { delete ui_; }
|
||||||
|
|
||||||
void CoversSettingsPage::Load() {
|
void CoversSettingsPage::Load() {
|
||||||
|
|
||||||
|
if (!QSettings().contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
ui_->providers->clear();
|
ui_->providers->clear();
|
||||||
|
|
||||||
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
|
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
|
||||||
|
|
|
@ -73,6 +73,8 @@ LyricsSettingsPage::~LyricsSettingsPage() { delete ui_; }
|
||||||
|
|
||||||
void LyricsSettingsPage::Load() {
|
void LyricsSettingsPage::Load() {
|
||||||
|
|
||||||
|
if (!QSettings().contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
ui_->providers->clear();
|
ui_->providers->clear();
|
||||||
|
|
||||||
QList<LyricsProvider*> lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List();
|
QList<LyricsProvider*> lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List();
|
||||||
|
|
|
@ -66,6 +66,8 @@ MoodbarSettingsPage::~MoodbarSettingsPage() { delete ui_; }
|
||||||
void MoodbarSettingsPage::Load() {
|
void MoodbarSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->moodbar_enabled->setChecked(s.value("enabled", false).toBool());
|
ui_->moodbar_enabled->setChecked(s.value("enabled", false).toBool());
|
||||||
ui_->moodbar_show->setChecked(s.value("show", false).toBool());
|
ui_->moodbar_show->setChecked(s.value("show", false).toBool());
|
||||||
|
|
|
@ -51,6 +51,7 @@ NetworkProxySettingsPage::~NetworkProxySettingsPage() { delete ui_; }
|
||||||
void NetworkProxySettingsPage::Load() {
|
void NetworkProxySettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
|
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
|
||||||
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode(s.value("mode", NetworkProxyFactory::Mode_System).toInt());
|
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode(s.value("mode", NetworkProxyFactory::Mode_System).toInt());
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
class QHideEvent;
|
class QHideEvent;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
|
||||||
const char *NotificationsSettingsPage::kSettingsGroup = "Notifications";
|
//const char *NotificationsSettingsPage::kSettingsGroup = "Notifications";
|
||||||
|
|
||||||
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
|
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
|
||||||
: SettingsPage(dialog), ui_(new Ui_NotificationsSettingsPage), pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) {
|
: SettingsPage(dialog), ui_(new Ui_NotificationsSettingsPage), pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) {
|
||||||
|
@ -142,6 +142,7 @@ void NotificationsSettingsPage::hideEvent(QHideEvent*) {
|
||||||
void NotificationsSettingsPage::Load() {
|
void NotificationsSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(OSDBase::kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(OSDBase::kSettingsGroup);
|
s.beginGroup(OSDBase::kSettingsGroup);
|
||||||
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour(s.value("Behaviour", OSDBase::Native).toInt());
|
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour(s.value("Behaviour", OSDBase::Native).toInt());
|
||||||
|
|
|
@ -43,7 +43,7 @@ class NotificationsSettingsPage : public SettingsPage {
|
||||||
explicit NotificationsSettingsPage(SettingsDialog *dialog);
|
explicit NotificationsSettingsPage(SettingsDialog *dialog);
|
||||||
~NotificationsSettingsPage() override;
|
~NotificationsSettingsPage() override;
|
||||||
|
|
||||||
static const char *kSettingsGroup;
|
//static const char *kSettingsGroup;
|
||||||
|
|
||||||
void Load() override;
|
void Load() override;
|
||||||
void Save() override;
|
void Save() override;
|
||||||
|
|
|
@ -49,6 +49,8 @@ PlaylistSettingsPage::~PlaylistSettingsPage() {
|
||||||
void PlaylistSettingsPage::Load() {
|
void PlaylistSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
|
|
@ -73,6 +73,7 @@ QobuzSettingsPage::~QobuzSettingsPage() { delete ui_; }
|
||||||
void QobuzSettingsPage::Load() {
|
void QobuzSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||||
|
|
|
@ -89,6 +89,9 @@ ScrobblerSettingsPage::~ScrobblerSettingsPage() { delete ui_; }
|
||||||
|
|
||||||
void ScrobblerSettingsPage::Load() {
|
void ScrobblerSettingsPage::Load() {
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
ui_->checkbox_enable->setChecked(scrobbler_->IsEnabled());
|
ui_->checkbox_enable->setChecked(scrobbler_->IsEnabled());
|
||||||
ui_->checkbox_scrobble_button->setChecked(scrobbler_->ScrobbleButton());
|
ui_->checkbox_scrobble_button->setChecked(scrobbler_->ScrobbleButton());
|
||||||
ui_->checkbox_love_button->setChecked(scrobbler_->LoveButton());
|
ui_->checkbox_love_button->setChecked(scrobbler_->LoveButton());
|
||||||
|
|
|
@ -65,8 +65,6 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog)
|
||||||
ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
setWindowIcon(IconLoader::Load("keyboard"));
|
setWindowIcon(IconLoader::Load("keyboard"));
|
||||||
|
|
||||||
settings_.beginGroup(kSettingsGroup);
|
|
||||||
|
|
||||||
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*)));
|
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*)));
|
||||||
connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked()));
|
connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked()));
|
||||||
connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked()));
|
connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked()));
|
||||||
|
@ -102,6 +100,10 @@ bool GlobalShortcutsSettingsPage::IsEnabled() const {
|
||||||
|
|
||||||
void GlobalShortcutsSettingsPage::Load() {
|
void GlobalShortcutsSettingsPage::Load() {
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
|
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
|
||||||
|
|
||||||
if (!initialised_) {
|
if (!initialised_) {
|
||||||
|
@ -128,32 +130,32 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||||
else {
|
else {
|
||||||
qLog(Debug) << "X11 backend is unavailable.";
|
qLog(Debug) << "X11 backend is unavailable.";
|
||||||
ui_->widget_x11->hide();
|
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 shortcut;
|
||||||
shortcut.s = s;
|
shortcut.s = i;
|
||||||
shortcut.key = s.action->shortcut();
|
shortcut.key = i.action->shortcut();
|
||||||
shortcut.item = new QTreeWidgetItem(ui_->list, QStringList() << s.action->text() << s.action->shortcut().toString(QKeySequence::NativeText));
|
shortcut.item = new QTreeWidgetItem(ui_->list, QStringList() << i.action->text() << i.action->shortcut().toString(QKeySequence::NativeText));
|
||||||
shortcut.item->setData(0, Qt::UserRole, s.id);
|
shortcut.item->setData(0, Qt::UserRole, i.id);
|
||||||
shortcuts_[s.id] = shortcut;
|
shortcuts_[i.id] = shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_->list->sortItems(0, Qt::AscendingOrder);
|
ui_->list->sortItems(0, Qt::AscendingOrder);
|
||||||
ItemClicked(ui_->list->topLevelItem(0));
|
ItemClicked(ui_->list->topLevelItem(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Shortcut &s : shortcuts_.values()) {
|
for (const Shortcut &shortcut : shortcuts_.values()) {
|
||||||
SetShortcut(s.s.id, s.s.action->shortcut());
|
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)) {
|
if (ui_->widget_gsd->isVisibleTo(this)) {
|
||||||
ui_->checkbox_gsd->setChecked(use_gsd);
|
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)) {
|
if (ui_->widget_x11->isVisibleTo(this)) {
|
||||||
ui_->checkbox_x11->setChecked(use_x11);
|
ui_->checkbox_x11->setChecked(use_x11);
|
||||||
}
|
}
|
||||||
|
@ -174,20 +176,27 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||||
ui_->label_macos_mavericks->setVisible(macos_version >= 9);
|
ui_->label_macos_mavericks->setVisible(macos_version >= 9);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
Init(ui_->layout_globalshortcutssettingspage->parentWidget());
|
Init(ui_->layout_globalshortcutssettingspage->parentWidget());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutsSettingsPage::Save() {
|
void GlobalShortcutsSettingsPage::Save() {
|
||||||
|
|
||||||
for (const Shortcut &s : shortcuts_.values()) {
|
QSettings s;
|
||||||
s.s.action->setShortcut(s.key);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.s.shortcut->setKey(s.key);
|
|
||||||
settings_.setValue(s.s.id, s.key.toString());
|
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());
|
s.setValue("use_gsd", ui_->checkbox_gsd->isChecked());
|
||||||
settings_.setValue("use_x11", ui_->checkbox_x11->isChecked());
|
s.setValue("use_x11", ui_->checkbox_x11->isChecked());
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
dialog()->global_shortcuts_manager()->ReloadSettings();
|
dialog()->global_shortcuts_manager()->ReloadSettings();
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
|
||||||
bool initialised_;
|
bool initialised_;
|
||||||
std::unique_ptr<GlobalShortcutGrabber> grabber_;
|
std::unique_ptr<GlobalShortcutGrabber> grabber_;
|
||||||
|
|
||||||
QSettings settings_;
|
|
||||||
QMap<QString, Shortcut> shortcuts_;
|
QMap<QString, Shortcut> shortcuts_;
|
||||||
|
|
||||||
QString current_id_;
|
QString current_id_;
|
||||||
|
|
|
@ -65,6 +65,7 @@ SubsonicSettingsPage::~SubsonicSettingsPage() { delete ui_; }
|
||||||
void SubsonicSettingsPage::Load() {
|
void SubsonicSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||||
|
|
|
@ -85,6 +85,7 @@ TidalSettingsPage::~TidalSettingsPage() { delete ui_; }
|
||||||
void TidalSettingsPage::Load() {
|
void TidalSettingsPage::Load() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
if (!s.contains(kSettingsGroup)) set_changed();
|
||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||||
|
|
Loading…
Reference in New Issue