2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SETTINGSPAGE_H
|
|
|
|
#define SETTINGSPAGE_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QWidget>
|
2020-05-25 23:56:54 +02:00
|
|
|
#include <QPair>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVariant>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
2020-11-08 02:02:48 +01:00
|
|
|
#include <QSettings>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
#include "osd/osdbase.h"
|
2020-10-12 17:20:18 +02:00
|
|
|
#include "core/logging.h"
|
2024-04-11 02:56:01 +02:00
|
|
|
#include "core/settings.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
class QCheckBox;
|
|
|
|
class QComboBox;
|
|
|
|
class QRadioButton;
|
|
|
|
class QSpinBox;
|
2024-02-19 23:07:27 +01:00
|
|
|
class QDoubleSpinBox;
|
2020-05-25 23:56:54 +02:00
|
|
|
class QSlider;
|
|
|
|
class QLineEdit;
|
|
|
|
class QShowEvent;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
class SettingsDialog;
|
|
|
|
|
|
|
|
class SettingsPage : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
public:
|
2021-06-20 19:04:08 +02:00
|
|
|
explicit SettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
void Init(QWidget *ui_widget);
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
// Return false to grey out the page's item in the list.
|
|
|
|
virtual bool IsEnabled() const { return true; }
|
|
|
|
|
|
|
|
virtual void Load() = 0;
|
2020-05-25 23:56:54 +02:00
|
|
|
|
|
|
|
void Accept();
|
|
|
|
void Reject();
|
|
|
|
void Apply();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// The dialog that this page belongs to.
|
|
|
|
SettingsDialog *dialog() const { return dialog_; }
|
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
void set_changed() { changed_ = true; }
|
|
|
|
|
2024-04-11 02:56:01 +02:00
|
|
|
static void ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
|
|
|
|
static void ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
|
|
|
static void ComboBoxLoadFromSettingsByIndex(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
2020-11-08 02:02:48 +01:00
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
private:
|
|
|
|
virtual void Save() = 0;
|
|
|
|
virtual void Cancel() {}
|
|
|
|
|
2024-02-19 23:07:27 +01:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
signals:
|
2023-04-09 20:23:42 +02:00
|
|
|
void NotificationPreview(const OSDBase::Behaviour, const QString&, const QString&);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-07 16:49:15 +02:00
|
|
|
private:
|
2018-02-27 18:06:05 +01:00
|
|
|
SettingsDialog *dialog_;
|
2020-05-25 23:56:54 +02:00
|
|
|
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_;
|
2024-03-17 21:56:39 +01:00
|
|
|
QList<QPair<QDoubleSpinBox*, double>> double_spinboxes_;
|
2020-05-25 23:56:54 +02:00
|
|
|
QList<QPair<QSlider*, int>> sliders_;
|
|
|
|
QList<QPair<QLineEdit*, QString>> lineedits_;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
#endif // SETTINGSPAGE_H
|