2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
*
|
|
|
|
* 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:10:03 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SETTINGSDIALOG_H
|
|
|
|
#define SETTINGSDIALOG_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QDialog>
|
2019-07-09 00:04:52 +02:00
|
|
|
#include <QStyledItemDelegate>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QStyleOptionViewItem>
|
|
|
|
#include <QStyleOption>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QMap>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QString>
|
2018-09-21 18:53:27 +02:00
|
|
|
#include <QSettings>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-02-09 02:29:35 +01:00
|
|
|
#include "engine/engine_fwd.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "widgets/osd.h"
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
class QMainWindow;
|
2020-02-09 02:29:35 +01:00
|
|
|
class QWidget;
|
|
|
|
class QModelIndex;
|
|
|
|
class QPainter;
|
2019-07-09 00:04:52 +02:00
|
|
|
class QTreeWidgetItem;
|
|
|
|
class QComboBox;
|
|
|
|
class QScrollArea;
|
|
|
|
class QAbstractButton;
|
2018-05-01 00:41:33 +02:00
|
|
|
class QShowEvent;
|
2020-04-06 22:02:32 +02:00
|
|
|
class QCloseEvent;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
class Application;
|
2018-06-28 01:15:32 +02:00
|
|
|
class Player;
|
|
|
|
class Appearance;
|
2018-02-27 18:06:05 +01:00
|
|
|
class CollectionDirectoryModel;
|
2018-05-01 00:41:33 +02:00
|
|
|
class GlobalShortcuts;
|
2018-02-27 18:06:05 +01:00
|
|
|
class SettingsPage;
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
class Ui_SettingsDialog;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
class SettingsItemDelegate : public QStyledItemDelegate {
|
|
|
|
public:
|
|
|
|
SettingsItemDelegate(QObject *parent);
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsDialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2019-03-22 23:19:24 +01:00
|
|
|
public:
|
2020-04-06 22:26:55 +02:00
|
|
|
SettingsDialog(Application *app, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
2018-02-27 18:06:05 +01:00
|
|
|
~SettingsDialog();
|
|
|
|
|
|
|
|
enum Page {
|
|
|
|
Page_Behaviour,
|
|
|
|
Page_Collection,
|
|
|
|
Page_Backend,
|
|
|
|
Page_Playback,
|
|
|
|
Page_Playlist,
|
|
|
|
Page_GlobalShortcuts,
|
|
|
|
Page_Appearance,
|
2019-12-22 12:09:05 +01:00
|
|
|
Page_Context,
|
2018-02-27 18:06:05 +01:00
|
|
|
Page_Notifications,
|
|
|
|
Page_Transcoding,
|
2018-12-23 18:54:27 +01:00
|
|
|
Page_Proxy,
|
|
|
|
Page_Scrobbler,
|
2019-06-19 02:22:11 +02:00
|
|
|
Page_Moodbar,
|
2020-02-25 01:08:03 +01:00
|
|
|
Page_Subsonic
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Role {
|
|
|
|
Role_IsSeparator = Qt::UserRole
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetGlobalShortcutManager(GlobalShortcuts *manager) { manager_ = manager; }
|
|
|
|
|
|
|
|
bool is_loading_settings() const { return loading_settings_; }
|
|
|
|
|
|
|
|
Application *app() const { return app_; }
|
2018-06-28 01:15:32 +02:00
|
|
|
Player *player() const { return player_; }
|
|
|
|
EngineBase *engine() const { return engine_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
CollectionDirectoryModel *collection_directory_model() const { return model_; }
|
|
|
|
GlobalShortcuts *global_shortcuts_manager() const { return manager_; }
|
|
|
|
Appearance *appearance() const { return appearance_; }
|
|
|
|
|
|
|
|
void OpenAtPage(Page page);
|
|
|
|
|
2019-06-19 02:22:11 +02:00
|
|
|
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);
|
2018-09-21 18:53:27 +02:00
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *e);
|
|
|
|
void closeEvent(QCloseEvent*);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-03-22 23:19:24 +01:00
|
|
|
private:
|
2018-02-27 18:06:05 +01:00
|
|
|
struct PageData {
|
|
|
|
QTreeWidgetItem *item_;
|
|
|
|
QScrollArea *scroll_area_;
|
|
|
|
SettingsPage *page_;
|
|
|
|
};
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
// QDialog
|
|
|
|
void accept();
|
|
|
|
void reject();
|
|
|
|
|
|
|
|
void LoadGeometry();
|
|
|
|
void SaveGeometry();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
QTreeWidgetItem *AddCategory(const QString &name);
|
|
|
|
void AddPage(Page id, SettingsPage *page, QTreeWidgetItem *parent = nullptr);
|
|
|
|
|
|
|
|
void Save();
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
signals:
|
|
|
|
void ReloadSettings();
|
|
|
|
void NotificationPreview(OSD::Behaviour, QString, QString);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void CurrentItemChanged(QTreeWidgetItem *item);
|
|
|
|
void DialogButtonClicked(QAbstractButton *button);
|
2019-03-22 23:19:24 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const char *kSettingsGroup;
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
QMainWindow *mainwindow_;
|
2018-02-27 18:06:05 +01:00
|
|
|
Application *app_;
|
2018-06-28 01:15:32 +02:00
|
|
|
Player *player_;
|
|
|
|
EngineBase *engine_;
|
2018-02-27 18:06:05 +01:00
|
|
|
CollectionDirectoryModel *model_;
|
|
|
|
GlobalShortcuts *manager_;
|
|
|
|
Appearance *appearance_;
|
|
|
|
|
|
|
|
Ui_SettingsDialog *ui_;
|
|
|
|
bool loading_settings_;
|
|
|
|
|
|
|
|
QMap<Page, PageData> pages_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SETTINGSDIALOG_H
|