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: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"
|
2020-08-09 01:37:00 +02:00
|
|
|
#include "osd/osdbase.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
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;
|
2021-01-26 19:13:29 +01:00
|
|
|
class GlobalShortcutsManager;
|
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 {
|
2020-04-07 16:49:15 +02:00
|
|
|
public:
|
|
|
|
explicit SettingsItemDelegate(QObject *parent);
|
2021-01-26 16:48:04 +01:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsDialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2019-03-22 23:19:24 +01:00
|
|
|
public:
|
2020-08-09 01:37:00 +02:00
|
|
|
explicit SettingsDialog(Application *app, OSDBase *osd, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~SettingsDialog() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
enum Page {
|
|
|
|
Page_Behaviour,
|
|
|
|
Page_Collection,
|
|
|
|
Page_Backend,
|
|
|
|
Page_Playback,
|
|
|
|
Page_Playlist,
|
2020-05-08 20:25:02 +02:00
|
|
|
Page_Scrobbler,
|
2020-05-09 01:48:08 +02:00
|
|
|
Page_Covers,
|
2020-05-08 18:35:36 +02:00
|
|
|
Page_Lyrics,
|
2018-02-27 18:06:05 +01:00
|
|
|
Page_Transcoding,
|
2018-12-23 18:54:27 +01:00
|
|
|
Page_Proxy,
|
2020-05-08 20:25:02 +02:00
|
|
|
Page_Appearance,
|
|
|
|
Page_Context,
|
|
|
|
Page_Notifications,
|
|
|
|
Page_GlobalShortcuts,
|
2019-06-19 02:22:11 +02:00
|
|
|
Page_Moodbar,
|
2020-04-13 19:04:06 +02:00
|
|
|
Page_Subsonic,
|
|
|
|
Page_Tidal,
|
2020-09-17 17:50:17 +02:00
|
|
|
Page_Qobuz,
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Role {
|
|
|
|
Role_IsSeparator = Qt::UserRole
|
|
|
|
};
|
|
|
|
|
2021-01-26 19:13:29 +01:00
|
|
|
void SetGlobalShortcutManager(GlobalShortcutsManager *manager) { manager_ = manager; }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
bool is_loading_settings() const { return loading_settings_; }
|
|
|
|
|
|
|
|
Application *app() const { return app_; }
|
2020-08-09 01:37:00 +02:00
|
|
|
OSDBase *osd() const { return osd_; }
|
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_; }
|
2021-01-26 19:13:29 +01:00
|
|
|
GlobalShortcutsManager *global_shortcuts_manager() const { return manager_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
Appearance *appearance() const { return appearance_; }
|
|
|
|
|
|
|
|
void OpenAtPage(Page page);
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
protected:
|
2020-06-15 21:55:05 +02:00
|
|
|
void showEvent(QShowEvent *e) override;
|
|
|
|
void closeEvent(QCloseEvent*) override;
|
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
|
2020-06-15 21:55:05 +02:00
|
|
|
void accept() override;
|
|
|
|
void reject() override;
|
2020-04-06 22:02:32 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
void Apply();
|
2018-02-27 18:06:05 +01:00
|
|
|
void Save();
|
|
|
|
|
2020-04-06 22:02:32 +02:00
|
|
|
signals:
|
|
|
|
void ReloadSettings();
|
2020-08-09 01:37:00 +02:00
|
|
|
void NotificationPreview(OSDBase::Behaviour, QString, QString);
|
2020-04-06 22:02:32 +02:00
|
|
|
|
|
|
|
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_;
|
2020-08-09 01:37:00 +02:00
|
|
|
OSDBase *osd_;
|
2018-06-28 01:15:32 +02:00
|
|
|
Player *player_;
|
|
|
|
EngineBase *engine_;
|
2018-02-27 18:06:05 +01:00
|
|
|
CollectionDirectoryModel *model_;
|
2021-01-26 19:13:29 +01:00
|
|
|
GlobalShortcutsManager *manager_;
|
2018-02-27 18:06:05 +01:00
|
|
|
Appearance *appearance_;
|
|
|
|
|
|
|
|
Ui_SettingsDialog *ui_;
|
|
|
|
bool loading_settings_;
|
|
|
|
|
|
|
|
QMap<Page, PageData> pages_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SETTINGSDIALOG_H
|