mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-30 00:55:33 +01:00
Move ComboBoxLoadFromSettings function to settingspage
This commit is contained in:
parent
91db4f1934
commit
c9c3fb396a
@ -85,7 +85,7 @@ void QobuzSettingsPage::Load() {
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->format, "format", 27);
|
||||
ComboBoxLoadFromSettings(s, ui_->format, "format", 27);
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
|
@ -371,20 +371,3 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
|
||||
|
||||
}
|
||||
|
||||
void SettingsDialog::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value) {
|
||||
|
||||
QString value = s.value(setting, default_value).toString();
|
||||
int i = combobox->findData(value);
|
||||
if (i == -1) i = combobox->findData(default_value);
|
||||
combobox->setCurrentIndex(i);
|
||||
|
||||
}
|
||||
|
||||
void SettingsDialog::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value) {
|
||||
|
||||
int value = s.value(setting, default_value).toInt();
|
||||
int i = combobox->findData(value);
|
||||
if (i == -1) i = combobox->findData(default_value);
|
||||
combobox->setCurrentIndex(i);
|
||||
|
||||
}
|
||||
|
@ -111,9 +111,6 @@ class SettingsDialog : public QDialog {
|
||||
|
||||
void OpenAtPage(Page page);
|
||||
|
||||
void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
|
||||
void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QRadioButton>
|
||||
#include <QSlider>
|
||||
#include <QLineEdit>
|
||||
#include <QSettings>
|
||||
#include <QShowEvent>
|
||||
|
||||
#include "core/logging.h"
|
||||
@ -127,3 +128,22 @@ void SettingsPage::Apply() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value) {
|
||||
|
||||
QString value = s.value(setting, default_value).toString();
|
||||
int i = combobox->findData(value);
|
||||
if (i == -1) i = combobox->findData(default_value);
|
||||
combobox->setCurrentIndex(i);
|
||||
|
||||
}
|
||||
|
||||
void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value) {
|
||||
|
||||
int value = s.value(setting, default_value).toInt();
|
||||
int i = combobox->findData(value);
|
||||
if (i == -1) i = combobox->findData(default_value);
|
||||
combobox->setCurrentIndex(i);
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
|
||||
#include "osd/osdbase.h"
|
||||
#include "core/logging.h"
|
||||
@ -65,6 +66,9 @@ class SettingsPage : public QWidget {
|
||||
|
||||
void set_changed() { changed_ = true; }
|
||||
|
||||
void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
|
||||
void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
||||
|
||||
private:
|
||||
virtual void Save() = 0;
|
||||
virtual void Cancel() {}
|
||||
|
@ -97,14 +97,14 @@ void TidalSettingsPage::Load() {
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->quality, "quality", "LOSSLESS");
|
||||
ComboBoxLoadFromSettings(s, ui_->quality, "quality", "LOSSLESS");
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 10).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value("fetchalbums", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->coversize, "coversize", "640x640");
|
||||
ComboBoxLoadFromSettings(s, ui_->coversize, "coversize", "640x640");
|
||||
|
||||
StreamUrlMethod stream_url = static_cast<StreamUrlMethod>(s.value("streamurl").toInt());
|
||||
int i = ui_->streamurl->findData(stream_url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user