strawberry-audio-player-win.../src/settings/settingspage.h

100 lines
2.8 KiB
C
Raw Normal View History

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"
#include <QObject>
2018-02-27 18:06:05 +01:00
#include <QWidget>
#include <QPair>
#include <QList>
#include <QVariant>
#include <QString>
#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"
#include "core/settings.h"
2018-02-27 18:06:05 +01:00
class QCheckBox;
class QComboBox;
class QRadioButton;
class QSpinBox;
class QDoubleSpinBox;
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
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;
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_; }
void set_changed() { changed_ = true; }
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);
private:
virtual void Save() = 0;
virtual void Cancel() {}
protected:
bool eventFilter(QObject *obj, QEvent *e) override;
2020-04-07 16:49:15 +02:00
signals:
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_;
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<QDoubleSpinBox*, double>> double_spinboxes_;
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