Only save settings that has been changed

This commit is contained in:
Jonas Kvinge 2020-05-25 23:56:54 +02:00
parent 0489b312a3
commit 5f1002894e
39 changed files with 327 additions and 28 deletions

View File

@ -188,6 +188,8 @@ void AppearanceSettingsPage::Load() {
s.endGroup(); s.endGroup();
Init(ui_->layout_appearancesettingspage->parentWidget());
} }
void AppearanceSettingsPage::Save() { void AppearanceSettingsPage::Save() {
@ -269,6 +271,8 @@ void AppearanceSettingsPage::SelectForegroundColor() {
UpdateColorSelectorColor(ui_->select_foreground_color, color_selected); UpdateColorSelectorColor(ui_->select_foreground_color, color_selected);
set_changed();
} }
void AppearanceSettingsPage::SelectBackgroundColor() { void AppearanceSettingsPage::SelectBackgroundColor() {
@ -281,6 +285,8 @@ void AppearanceSettingsPage::SelectBackgroundColor() {
UpdateColorSelectorColor(ui_->select_background_color, color_selected); UpdateColorSelectorColor(ui_->select_background_color, color_selected);
set_changed();
} }
void AppearanceSettingsPage::UseCustomColorSetOptionChanged(bool checked) { void AppearanceSettingsPage::UseCustomColorSetOptionChanged(bool checked) {

View File

@ -182,6 +182,8 @@ void BackendSettingsPage::Load() {
FadingOptionsChanged(); FadingOptionsChanged();
RgPreampChanged(ui_->stickslider_replaygainpreamp->value()); RgPreampChanged(ui_->stickslider_replaygainpreamp->value());
Init(ui_->layout_backendsettings->parentWidget());
} }
bool BackendSettingsPage::EngineInitialised() { bool BackendSettingsPage::EngineInitialised() {

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Backend</string> <string>Backend</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="layout_backendsettings">
<item> <item>
<widget class="QGroupBox" name="groupbox_audio_output"> <widget class="QGroupBox" name="groupbox_audio_output">
<property name="title"> <property name="title">

View File

@ -196,6 +196,8 @@ void BehaviourSettingsPage::Load() {
s.endGroup(); s.endGroup();
Init(ui_->layout_behavioursettingspage->parentWidget());
} }
void BehaviourSettingsPage::Save() { void BehaviourSettingsPage::Save() {

View File

@ -105,10 +105,16 @@ void CollectionSettingsPage::Add() {
} }
settings.setValue("last_path", path); settings.setValue("last_path", path);
set_changed();
} }
void CollectionSettingsPage::Remove() { void CollectionSettingsPage::Remove() {
dialog()->collection_directory_model()->RemoveDirectory(ui_->list->currentIndex()); dialog()->collection_directory_model()->RemoveDirectory(ui_->list->currentIndex());
set_changed();
} }
void CollectionSettingsPage::CurrentRowChanged(const QModelIndex& index) { void CollectionSettingsPage::CurrentRowChanged(const QModelIndex& index) {
@ -178,6 +184,8 @@ void CollectionSettingsPage::Load() {
ui_->disk_cache_in_use->setText((dialog()->app()->collection_model()->icon_cache_disk_size() == 0 ? "empty" : Utilities::PrettySize(dialog()->app()->collection_model()->icon_cache_disk_size()))); ui_->disk_cache_in_use->setText((dialog()->app()->collection_model()->icon_cache_disk_size() == 0 ? "empty" : Utilities::PrettySize(dialog()->app()->collection_model()->icon_cache_disk_size())));
Init(ui_->layout_collectionsettingspage->parentWidget());
} }
void CollectionSettingsPage::Save() { void CollectionSettingsPage::Save() {

View File

@ -310,6 +310,12 @@ If there are no matches then it will use the largest image in the directory.</st
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -328,6 +334,12 @@ If there are no matches then it will use the largest image in the directory.</st
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -381,6 +393,12 @@ If there are no matches then it will use the largest image in the directory.</st
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -419,6 +437,12 @@ If there are no matches then it will use the largest image in the directory.</st
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>

View File

@ -154,6 +154,8 @@ void ContextSettingsPage::Load() {
ui_->checkbox_search_cover->setChecked(s.value("search_for_cover_auto", true).toBool()); ui_->checkbox_search_cover->setChecked(s.value("search_for_cover_auto", true).toBool());
s.endGroup(); s.endGroup();
Init(ui_->layout_contextsettingspage->parentWidget());
} }
void ContextSettingsPage::Save() { void ContextSettingsPage::Save() {

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>500</width>
<height>780</height> <height>809</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

View File

@ -85,6 +85,8 @@ void CoversSettingsPage::Load() {
item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text)); item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
} }
Init(ui_->layout_coverssettingspage->parentWidget());
} }
void CoversSettingsPage::Save() { void CoversSettingsPage::Save() {
@ -171,12 +173,16 @@ void CoversSettingsPage::ProvidersMove(const int d) {
ui_->providers->insertItem(row + d, item); ui_->providers->insertItem(row + d, item);
ui_->providers->setCurrentRow(row + d); ui_->providers->setCurrentRow(row + d);
set_changed();
} }
void CoversSettingsPage::ItemChanged(QListWidgetItem *item) { void CoversSettingsPage::ItemChanged(QListWidgetItem *item) {
item->setForeground((item->checkState() == Qt::Checked) ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text)); item->setForeground((item->checkState() == Qt::Checked) ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
set_changed();
} }
void CoversSettingsPage::NoProviderSelected() { void CoversSettingsPage::NoProviderSelected() {

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Covers</string> <string>Covers</string>
</property> </property>
<layout class="QVBoxLayout" name="layout_tidalsettingspage"> <layout class="QVBoxLayout" name="layout_coverssettingspage">
<item> <item>
<widget class="QGroupBox" name="groupbox_providers"> <widget class="QGroupBox" name="groupbox_providers">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -85,6 +85,8 @@ void LyricsSettingsPage::Load() {
item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text)); item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
} }
Init(ui_->layout_lyricssettingspage->parentWidget());
} }
void LyricsSettingsPage::Save() { void LyricsSettingsPage::Save() {
@ -165,12 +167,16 @@ void LyricsSettingsPage::ProvidersMove(const int d) {
ui_->providers->insertItem(row + d, item); ui_->providers->insertItem(row + d, item);
ui_->providers->setCurrentRow(row + d); ui_->providers->setCurrentRow(row + d);
set_changed();
} }
void LyricsSettingsPage::ItemChanged(QListWidgetItem *item) { void LyricsSettingsPage::ItemChanged(QListWidgetItem *item) {
item->setForeground((item->checkState() == Qt::Checked) ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text)); item->setForeground((item->checkState() == Qt::Checked) ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
set_changed();
} }
void LyricsSettingsPage::NoProviderSelected() { void LyricsSettingsPage::NoProviderSelected() {

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Lyrics</string> <string>Lyrics</string>
</property> </property>
<layout class="QVBoxLayout" name="layout_tidalsettingspage"> <layout class="QVBoxLayout" name="layout_lyricssettingspage">
<item> <item>
<widget class="QGroupBox" name="groupbox_providers"> <widget class="QGroupBox" name="groupbox_providers">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -75,6 +75,8 @@ void MoodbarSettingsPage::Load() {
InitMoodbarPreviews(); InitMoodbarPreviews();
Init(ui_->layout_moodbarsettingspage->parentWidget());
} }
void MoodbarSettingsPage::Save() { void MoodbarSettingsPage::Save() {

View File

@ -51,6 +51,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<spacer name="spacer_bottom">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -77,6 +77,8 @@ void NetworkProxySettingsPage::Load() {
ui_->proxy_password->setText(s.value("password").toString()); ui_->proxy_password->setText(s.value("password").toString());
s.endGroup(); s.endGroup();
Init(ui_->layout_networkproxysettingspage->parentWidget());
} }
void NetworkProxySettingsPage::Save() { void NetworkProxySettingsPage::Save() {

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Network Proxy</string> <string>Network Proxy</string>
</property> </property>
<layout class="QVBoxLayout" name="layout_networkproxysettingsPage"> <layout class="QVBoxLayout" name="layout_networkproxysettingspage">
<item> <item>
<widget class="QRadioButton" name="proxy_system"> <widget class="QRadioButton" name="proxy_system">
<property name="text"> <property name="text">

View File

@ -196,6 +196,8 @@ void NotificationsSettingsPage::Load() {
ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration()); ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration());
UpdatePopupVisible(); UpdatePopupVisible();
Init(ui_->layout_notificationssettingspage->parentWidget());
} }
void NotificationsSettingsPage::Save() { void NotificationsSettingsPage::Save() {

View File

@ -85,6 +85,8 @@ void PlaylistSettingsPage::Load() {
s.endGroup(); s.endGroup();
Init(ui_->layout_playlistsettingspage->parentWidget());
} }
void PlaylistSettingsPage::Save() { void PlaylistSettingsPage::Save() {

View File

@ -107,6 +107,8 @@ void ScrobblerSettingsPage::Load() {
ui_->lineedit_listenbrainz_user_token->setText(listenbrainzscrobbler_->user_token()); ui_->lineedit_listenbrainz_user_token->setText(listenbrainzscrobbler_->user_token());
ListenBrainz_RefreshControls(listenbrainzscrobbler_->IsAuthenticated()); ListenBrainz_RefreshControls(listenbrainzscrobbler_->IsAuthenticated());
Init(ui_->layout_scrobblersettingspage->parentWidget());
} }
void ScrobblerSettingsPage::Save() { void ScrobblerSettingsPage::Save() {

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Scrobbler</string> <string>Scrobbler</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="layout_scrobblersettingspage">
<item> <item>
<widget class="QCheckBox" name="checkbox_enable"> <widget class="QCheckBox" name="checkbox_enable">
<property name="enabled"> <property name="enabled">

View File

@ -201,7 +201,11 @@ void SettingsDialog::closeEvent(QCloseEvent*) {
void SettingsDialog::accept() { void SettingsDialog::accept() {
Save(); for (const PageData &page : pages_.values()) {
page.page_->Accept();
}
emit ReloadSettings();
SaveGeometry(); SaveGeometry();
QDialog::accept(); QDialog::accept();
@ -212,7 +216,7 @@ void SettingsDialog::reject() {
// Notify each page that user clicks on Cancel // Notify each page that user clicks on Cancel
for (const PageData &page : pages_.values()) { for (const PageData &page : pages_.values()) {
page.page_->Cancel(); page.page_->Reject();
} }
SaveGeometry(); SaveGeometry();
@ -309,18 +313,23 @@ void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *paren
void SettingsDialog::Save() { void SettingsDialog::Save() {
for (const PageData &page : pages_.values()) { for (const PageData &page : pages_.values()) {
page.page_->Save(); page.page_->Apply();
} }
emit ReloadSettings(); emit ReloadSettings();
} }
void SettingsDialog::DialogButtonClicked(QAbstractButton *button) { void SettingsDialog::DialogButtonClicked(QAbstractButton *button) {
// While we only connect Apply at the moment, this might change in the future // While we only connect Apply at the moment, this might change in the future
if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) { if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) {
Save(); for (const PageData &page : pages_.values()) {
page.page_->Apply();
}
emit ReloadSettings();
} }
} }
void SettingsDialog::OpenAtPage(Page page) { void SettingsDialog::OpenAtPage(Page page) {

View File

@ -133,6 +133,7 @@ class SettingsDialog : public QDialog {
QTreeWidgetItem *AddCategory(const QString &name); QTreeWidgetItem *AddCategory(const QString &name);
void AddPage(Page id, SettingsPage *page, QTreeWidgetItem *parent = nullptr); void AddPage(Page id, SettingsPage *page, QTreeWidgetItem *parent = nullptr);
void Apply();
void Save(); void Save();
signals: signals:

View File

@ -19,8 +19,119 @@
*/ */
#include <QWidget> #include <QWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QSpinBox>
#include <QRadioButton>
#include <QSlider>
#include <QLineEdit>
#include <QShowEvent>
#include "core/logging.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "settingspage.h" #include "settingspage.h"
SettingsPage::SettingsPage(SettingsDialog *dialog) : QWidget(dialog), dialog_(dialog) { } SettingsPage::SettingsPage(SettingsDialog *dialog) : QWidget(dialog), dialog_(dialog), ui_widget_(nullptr), changed_(false) {}
void SettingsPage::showEvent(QShowEvent *e) {
changed_ = false;
QWidget::showEvent(e);
}
void SettingsPage::Init(QWidget *ui_widget) {
if (!ui_widget) return;
ui_widget_ = ui_widget;
changed_ = false;
checkboxes_.clear();
radiobuttons_.clear();
comboboxes_.clear();
spinboxes_.clear();
sliders_.clear();
lineedits_.clear();
QList<QWidget*> list = ui_widget_->findChildren<QWidget*>(QString(), Qt::FindChildrenRecursively);
for (QWidget *w : list) {
if (QCheckBox *checkbox = qobject_cast<QCheckBox*>(w)) {
checkboxes_ << qMakePair(checkbox, checkbox->checkState());
}
else if (QRadioButton *radiobutton = qobject_cast<QRadioButton*>(w)) {
radiobuttons_ << qMakePair(radiobutton, radiobutton->isChecked());
}
else if (QComboBox *combobox = qobject_cast<QComboBox*>(w)) {
comboboxes_ << qMakePair(combobox, combobox->currentText());
}
else if (QSpinBox *spinbox = qobject_cast<QSpinBox*>(w)) {
spinboxes_ << qMakePair(spinbox, spinbox->value());
}
else if (QLineEdit *lineedit = qobject_cast<QLineEdit*>(w)) {
lineedits_ << qMakePair(lineedit, lineedit->text());
}
else if (QSlider *slider = qobject_cast<QSlider*>(w)) {
sliders_ << qMakePair(slider, slider->value());
}
}
}
void SettingsPage::Accept() {
Apply();
}
void SettingsPage::Reject() {
Cancel();
changed_ = false;
}
void SettingsPage::Apply() {
if (!ui_widget_) {
qLog(Error) << windowTitle() << "is not initialized!";
changed_ = true;
}
for (QPair<QCheckBox*, Qt::CheckState> &checkbox : checkboxes_) {
if (checkbox.first->checkState() == checkbox.second) continue;
changed_ = true;
qLog(Info) << checkbox.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
for (QPair<QRadioButton*, bool> &radiobutton : radiobuttons_) {
if (radiobutton.first->isChecked() == radiobutton.second) continue;
changed_ = true;
qLog(Info) << radiobutton.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
for (QPair<QComboBox*, QString> &combobox : comboboxes_) {
if (combobox.first->currentText() == combobox.second) continue;
changed_ = true;
qLog(Info) << combobox.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
for (QPair<QSpinBox*, int> &spinbox : spinboxes_) {
if (spinbox.first->value() == spinbox.second) continue;
changed_ = true;
qLog(Info) << spinbox.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
for (QPair<QLineEdit*, QString> &lineedit : lineedits_) {
if (lineedit.first->text() == lineedit.second) continue;
changed_ = true;
if (lineedit.first->objectName().isEmpty()) continue;
qLog(Info) << lineedit.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
for (QPair<QSlider*, int> &slider : sliders_) {
if (slider.first->value() == slider.second) continue;
changed_ = true;
qLog(Info) << slider.first->objectName() << "is changed for" << windowTitle() << "settings.";
}
if (changed_) {
qLog(Info) << "Saving settings for" << windowTitle();
Save();
Init(ui_widget_);
}
}

View File

@ -25,10 +25,21 @@
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
#include <QPair>
#include <QList>
#include <QVariant>
#include <QString> #include <QString>
#include "widgets/osd.h" #include "widgets/osd.h"
class QCheckBox;
class QComboBox;
class QRadioButton;
class QSpinBox;
class QSlider;
class QLineEdit;
class QShowEvent;
class SettingsDialog; class SettingsDialog;
class SettingsPage : public QWidget { class SettingsPage : public QWidget {
@ -37,23 +48,42 @@ class SettingsPage : public QWidget {
public: public:
explicit SettingsPage(SettingsDialog *dialog); explicit SettingsPage(SettingsDialog *dialog);
void Init(QWidget *ui_widget);
// Return false to grey out the page's item in the list. // Return false to grey out the page's item in the list.
virtual bool IsEnabled() const { return true; } virtual bool IsEnabled() const { return true; }
// Load is called when the dialog is shown, Save when the user clicks OK, and
// Cancel when the user clicks on Cancel
virtual void Load() = 0; virtual void Load() = 0;
virtual void Save() = 0;
virtual void Cancel() {} void Accept();
void Reject();
void Apply();
// The dialog that this page belongs to. // The dialog that this page belongs to.
SettingsDialog *dialog() const { return dialog_; } SettingsDialog *dialog() const { return dialog_; }
void set_changed() { changed_ = true; }
protected:
virtual void showEvent(QShowEvent *e);
private:
virtual void Save() = 0;
virtual void Cancel() {}
signals: signals:
void NotificationPreview(OSD::Behaviour, QString, QString); void NotificationPreview(OSD::Behaviour, QString, QString);
private: private:
SettingsDialog *dialog_; SettingsDialog *dialog_;
QWidget *ui_widget_;
bool changed_;
QList<QPair<QCheckBox*, Qt::CheckState>> checkboxes_;
QList<QPair<QRadioButton*, bool>> radiobuttons_;
QList<QPair<QComboBox*, QString>> comboboxes_;
QList<QPair<QSpinBox*, int>> spinboxes_;
QList<QPair<QSlider*, int>> sliders_;
QList<QPair<QLineEdit*, QString>> lineedits_;
}; };
#endif // SETTINGSPAGE_H #endif // SETTINGSPAGE_H

View File

@ -174,6 +174,8 @@ 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
Init(ui_->layout_globalshortcutssettingspage->parentWidget());
} }
void GlobalShortcutsSettingsPage::Save() { void GlobalShortcutsSettingsPage::Save() {
@ -279,11 +281,17 @@ void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem *item) {
} }
void GlobalShortcutsSettingsPage::NoneClicked() { void GlobalShortcutsSettingsPage::NoneClicked() {
SetShortcut(current_id_, QKeySequence()); SetShortcut(current_id_, QKeySequence());
set_changed();
} }
void GlobalShortcutsSettingsPage::DefaultClicked() { void GlobalShortcutsSettingsPage::DefaultClicked() {
SetShortcut(current_id_, shortcuts_[current_id_].s.default_key); SetShortcut(current_id_, shortcuts_[current_id_].s.default_key);
set_changed();
} }
void GlobalShortcutsSettingsPage::ChangeClicked() { void GlobalShortcutsSettingsPage::ChangeClicked() {
@ -303,6 +311,8 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
ui_->radio_custom->setChecked(true); ui_->radio_custom->setChecked(true);
SetShortcut(current_id_, key); SetShortcut(current_id_, key);
set_changed();
} }
void GlobalShortcutsSettingsPage::X11Warning() { void GlobalShortcutsSettingsPage::X11Warning() {

View File

@ -77,6 +77,8 @@ void SubsonicSettingsPage::Load() {
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool()); ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
s.endGroup(); s.endGroup();
Init(ui_->layout_subsonicsettingspage->parentWidget());
} }
void SubsonicSettingsPage::Save() { void SubsonicSettingsPage::Save() {

View File

@ -105,15 +105,15 @@
<property name="title"> <property name="title">
<string>Preferences</string> <string>Preferences</string>
</property> </property>
<layout class="QFormLayout" name="layout_preferences"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="0"> <item>
<widget class="QCheckBox" name="checkbox_verify_certificate"> <widget class="QCheckBox" name="checkbox_verify_certificate">
<property name="text"> <property name="text">
<string>Verify server certificate</string> <string>Verify server certificate</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QCheckBox" name="checkbox_download_album_covers"> <widget class="QCheckBox" name="checkbox_download_album_covers">
<property name="text"> <property name="text">
<string>Download album covers</string> <string>Download album covers</string>

View File

@ -117,6 +117,8 @@ void TidalSettingsPage::Load() {
OAuthClicked(ui_->oauth->isChecked()); OAuthClicked(ui_->oauth->isChecked());
if (service_->authenticated()) ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn); if (service_->authenticated()) ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
Init(ui_->layout_tidalsettingspage->parentWidget());
} }
void TidalSettingsPage::Save() { void TidalSettingsPage::Save() {

View File

@ -35,17 +35,28 @@
class SettingsDialog; class SettingsDialog;
TranscoderSettingsPage::TranscoderSettingsPage(SettingsDialog* dialog) TranscoderSettingsPage::TranscoderSettingsPage(SettingsDialog *dialog)
: SettingsPage(dialog), ui_(new Ui_TranscoderSettingsPage) { : SettingsPage(dialog), ui_(new Ui_TranscoderSettingsPage) {
ui_->setupUi(this); ui_->setupUi(this);
setWindowIcon(IconLoader::Load("tools-wizard")); setWindowIcon(IconLoader::Load("tools-wizard"));
} }
TranscoderSettingsPage::~TranscoderSettingsPage() { TranscoderSettingsPage::~TranscoderSettingsPage() {
delete ui_; delete ui_;
} }
void TranscoderSettingsPage::showEvent(QShowEvent *e) {
set_changed();
QWidget::showEvent(e);
}
void TranscoderSettingsPage::Load() { void TranscoderSettingsPage::Load() {
ui_->transcoding_flac->Load(); ui_->transcoding_flac->Load();
ui_->transcoding_wavpack->Load(); ui_->transcoding_wavpack->Load();
ui_->transcoding_vorbis->Load(); ui_->transcoding_vorbis->Load();
@ -54,9 +65,14 @@ void TranscoderSettingsPage::Load() {
ui_->transcoding_aac->Load(); ui_->transcoding_aac->Load();
ui_->transcoding_asf->Load(); ui_->transcoding_asf->Load();
ui_->transcoding_mp3->Load(); ui_->transcoding_mp3->Load();
Init(ui_->layout_transcodersettingspage->parentWidget());
if (isVisible()) set_changed();
} }
void TranscoderSettingsPage::Save() { void TranscoderSettingsPage::Save() {
ui_->transcoding_flac->Save(); ui_->transcoding_flac->Save();
ui_->transcoding_wavpack->Save(); ui_->transcoding_wavpack->Save();
ui_->transcoding_vorbis->Save(); ui_->transcoding_vorbis->Save();
@ -65,4 +81,5 @@ void TranscoderSettingsPage::Save() {
ui_->transcoding_aac->Save(); ui_->transcoding_aac->Save();
ui_->transcoding_asf->Save(); ui_->transcoding_asf->Save();
ui_->transcoding_mp3->Save(); ui_->transcoding_mp3->Save();
} }

View File

@ -43,6 +43,9 @@ class TranscoderSettingsPage : public SettingsPage {
void Load(); void Load();
void Save(); void Save();
protected:
void showEvent(QShowEvent *e);
private: private:
Ui_TranscoderSettingsPage* ui_; Ui_TranscoderSettingsPage* ui_;
}; };

View File

@ -43,23 +43,27 @@ TranscoderOptionsAAC::~TranscoderOptionsAAC() {
} }
void TranscoderOptionsAAC::Load() { void TranscoderOptionsAAC::Load() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000); ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
ui_->profile->setCurrentIndex(s.value("profile", 2).toInt() - 1); ui_->profile->setCurrentIndex(s.value("profile", 2).toInt() - 1);
ui_->tns->setChecked(s.value("tns", false).toBool()); ui_->tns->setChecked(s.value("tns", false).toBool());
ui_->midside->setChecked(s.value("midside", true).toBool()); ui_->midside->setChecked(s.value("midside", true).toBool());
ui_->shortctl->setCurrentIndex(s.value("shortctl", 0).toInt()); ui_->shortctl->setCurrentIndex(s.value("shortctl", 0).toInt());
s.endGroup();
} }
void TranscoderOptionsAAC::Save() { void TranscoderOptionsAAC::Save() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000); s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.setValue("profile", ui_->profile->currentIndex() + 1); s.setValue("profile", ui_->profile->currentIndex() + 1);
s.setValue("tns", ui_->tns->isChecked()); s.setValue("tns", ui_->tns->isChecked());
s.setValue("midside", ui_->midside->isChecked()); s.setValue("midside", ui_->midside->isChecked());
s.setValue("shortctl", ui_->shortctl->currentIndex()); s.setValue("shortctl", ui_->shortctl->currentIndex());
s.endGroup();
} }

View File

@ -46,8 +46,8 @@ void TranscoderOptionsASF::Load() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000); ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
s.endGroup();
} }
@ -55,7 +55,7 @@ void TranscoderOptionsASF::Save() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000); s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.endGroup();
} }

View File

@ -75,21 +75,27 @@ TranscoderOptionsDialog::~TranscoderOptionsDialog() {
} }
void TranscoderOptionsDialog::showEvent(QShowEvent *e) { void TranscoderOptionsDialog::showEvent(QShowEvent *e) {
Q_UNUSED(e); Q_UNUSED(e);
if (options_) { if (options_) {
options_->Load(); options_->Load();
} }
} }
void TranscoderOptionsDialog::accept() { void TranscoderOptionsDialog::accept() {
if (options_) { if (options_) {
options_->Save(); options_->Save();
} }
QDialog::accept(); QDialog::accept();
} }
void TranscoderOptionsDialog::set_settings_postfix(const QString &settings_postfix) { void TranscoderOptionsDialog::set_settings_postfix(const QString &settings_postfix) {
if (options_) { if (options_) {
options_->settings_postfix_ = settings_postfix; options_->settings_postfix_ = settings_postfix;
} }
} }

View File

@ -43,15 +43,19 @@ TranscoderOptionsFLAC::~TranscoderOptionsFLAC() {
} }
void TranscoderOptionsFLAC::Load() { void TranscoderOptionsFLAC::Load() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->quality->setValue(s.value("quality", 5).toInt()); ui_->quality->setValue(s.value("quality", 5).toInt());
s.endGroup();
} }
void TranscoderOptionsFLAC::Save() { void TranscoderOptionsFLAC::Save() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.setValue("quality", ui_->quality->value()); s.setValue("quality", ui_->quality->value());
s.endGroup();
} }

View File

@ -56,7 +56,8 @@ void TranscoderOptionsMP3::Load() {
if (s.value("target", 1).toInt() == 0) { if (s.value("target", 1).toInt() == 0) {
ui_->target_quality->setChecked(true); ui_->target_quality->setChecked(true);
} else { }
else {
ui_->target_bitrate->setChecked(true); ui_->target_bitrate->setChecked(true);
} }
@ -66,6 +67,8 @@ void TranscoderOptionsMP3::Load() {
ui_->encoding_engine_quality->setCurrentIndex(s.value("encoding-engine-quality", 1).toInt()); ui_->encoding_engine_quality->setCurrentIndex(s.value("encoding-engine-quality", 1).toInt());
ui_->mono->setChecked(s.value("mono", false).toBool()); ui_->mono->setChecked(s.value("mono", false).toBool());
s.endGroup();
} }
void TranscoderOptionsMP3::Save() { void TranscoderOptionsMP3::Save() {
@ -80,6 +83,8 @@ void TranscoderOptionsMP3::Save() {
s.setValue("encoding-engine-quality", ui_->encoding_engine_quality->currentIndex()); s.setValue("encoding-engine-quality", ui_->encoding_engine_quality->currentIndex());
s.setValue("mono", ui_->mono->isChecked()); s.setValue("mono", ui_->mono->isChecked());
s.endGroup();
} }
void TranscoderOptionsMP3::QualitySliderChanged(int value) { void TranscoderOptionsMP3::QualitySliderChanged(int value) {

View File

@ -44,15 +44,19 @@ TranscoderOptionsOpus::~TranscoderOptionsOpus() {
} }
void TranscoderOptionsOpus::Load() { void TranscoderOptionsOpus::Load() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000); ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
s.endGroup();
} }
void TranscoderOptionsOpus::Save() { void TranscoderOptionsOpus::Save() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000); s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.endGroup();
} }

View File

@ -60,6 +60,8 @@ void TranscoderOptionsSpeex::Load() {
ui_->complexity->setValue(s.value("complexity", 3).toInt()); ui_->complexity->setValue(s.value("complexity", 3).toInt());
ui_->nframes->setValue(s.value("nframes", 1).toInt()); ui_->nframes->setValue(s.value("nframes", 1).toInt());
s.endGroup();
} }
void TranscoderOptionsSpeex::Save() { void TranscoderOptionsSpeex::Save() {
@ -77,4 +79,6 @@ void TranscoderOptionsSpeex::Save() {
s.setValue("complexity", ui_->complexity->value()); s.setValue("complexity", ui_->complexity->value());
s.setValue("nframes", ui_->nframes->value()); s.setValue("nframes", ui_->nframes->value());
s.endGroup();
} }

View File

@ -63,6 +63,8 @@ void TranscoderOptionsVorbis::Load() {
ui_->min_bitrate_slider->setValue(min_bitrate); ui_->min_bitrate_slider->setValue(min_bitrate);
ui_->bitrate_slider->setValue(bitrate); ui_->bitrate_slider->setValue(bitrate);
s.endGroup();
} }
void TranscoderOptionsVorbis::Save() { void TranscoderOptionsVorbis::Save() {
@ -85,4 +87,6 @@ void TranscoderOptionsVorbis::Save() {
s.setValue("min-bitrate", min_bitrate); s.setValue("min-bitrate", min_bitrate);
s.setValue("max-bitrate", max_bitrate); s.setValue("max-bitrate", max_bitrate);
s.endGroup();
} }

View File

@ -39,13 +39,17 @@ TranscoderOptionsWavPack::~TranscoderOptionsWavPack() {
} }
void TranscoderOptionsWavPack::Load() { void TranscoderOptionsWavPack::Load() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.endGroup(); s.endGroup();
} }
void TranscoderOptionsWavPack::Save() { void TranscoderOptionsWavPack::Save() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_); s.beginGroup(kSettingsGroup + settings_postfix_);
s.endGroup(); s.endGroup();
} }