Use virtual functions for OSD
This commit is contained in:
@@ -46,8 +46,8 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/iconloader.h"
|
||||
#include "widgets/osd.h"
|
||||
#include "widgets/osdpretty.h"
|
||||
#include "osd/osdbase.h"
|
||||
#include "osd/osdpretty.h"
|
||||
#include "settingspage.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "notificationssettingspage.h"
|
||||
@@ -109,9 +109,9 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
|
||||
connect(ui_->notifications_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(QAction*)));
|
||||
connect(ui_->notifications_disable_duration, SIGNAL(toggled(bool)), ui_->notifications_duration, SLOT(setDisabled(bool)));
|
||||
|
||||
if (!OSD::SupportsNativeNotifications())
|
||||
if (!dialog->osd()->SupportsNativeNotifications())
|
||||
ui_->notifications_native->setEnabled(false);
|
||||
if (!OSD::SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false);
|
||||
if (!dialog->osd()->SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false);
|
||||
|
||||
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(UpdatePopupVisible()));
|
||||
|
||||
@@ -143,28 +143,28 @@ void NotificationsSettingsPage::Load() {
|
||||
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(OSD::kSettingsGroup);
|
||||
OSD::Behaviour osd_behaviour = OSD::Behaviour(s.value("Behaviour", OSD::Native).toInt());
|
||||
s.beginGroup(OSDBase::kSettingsGroup);
|
||||
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour(s.value("Behaviour", OSDBase::Native).toInt());
|
||||
switch (osd_behaviour) {
|
||||
case OSD::Native:
|
||||
if (OSD::SupportsNativeNotifications()) {
|
||||
case OSDBase::Native:
|
||||
if (dialog()->osd()->SupportsNativeNotifications()) {
|
||||
ui_->notifications_native->setChecked(true);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case OSD::Pretty:
|
||||
case OSDBase::Pretty:
|
||||
ui_->notifications_pretty->setChecked(true);
|
||||
break;
|
||||
|
||||
case OSD::TrayPopup:
|
||||
if (OSD::SupportsTrayPopups()) {
|
||||
case OSDBase::TrayPopup:
|
||||
if (dialog()->osd()->SupportsTrayPopups()) {
|
||||
ui_->notifications_tray->setChecked(true);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case OSD::Disabled:
|
||||
case OSDBase::Disabled:
|
||||
default:
|
||||
ui_->notifications_none->setChecked(true);
|
||||
break;
|
||||
@@ -207,13 +207,13 @@ void NotificationsSettingsPage::Save() {
|
||||
|
||||
QSettings s;
|
||||
|
||||
OSD::Behaviour osd_behaviour = OSD::Disabled;
|
||||
if (ui_->notifications_none->isChecked()) osd_behaviour = OSD::Disabled;
|
||||
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSD::Native;
|
||||
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSD::TrayPopup;
|
||||
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSD::Pretty;
|
||||
OSDBase::Behaviour osd_behaviour = OSDBase::Disabled;
|
||||
if (ui_->notifications_none->isChecked()) osd_behaviour = OSDBase::Disabled;
|
||||
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSDBase::Native;
|
||||
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSDBase::TrayPopup;
|
||||
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSDBase::Pretty;
|
||||
|
||||
s.beginGroup(OSD::kSettingsGroup);
|
||||
s.beginGroup(OSDBase::kSettingsGroup);
|
||||
s.setValue("Behaviour", int(osd_behaviour));
|
||||
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
|
||||
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
|
||||
@@ -324,15 +324,15 @@ void NotificationsSettingsPage::NotificationCustomTextChanged(bool enabled) {
|
||||
|
||||
void NotificationsSettingsPage::PrepareNotificationPreview() {
|
||||
|
||||
OSD::Behaviour notificationType = OSD::Disabled;
|
||||
OSDBase::Behaviour notificationType = OSDBase::Disabled;
|
||||
if (ui_->notifications_native->isChecked()) {
|
||||
notificationType = OSD::Native;
|
||||
notificationType = OSDBase::Native;
|
||||
}
|
||||
else if (ui_->notifications_pretty->isChecked()) {
|
||||
notificationType = OSD::Pretty;
|
||||
notificationType = OSDBase::Pretty;
|
||||
}
|
||||
else if (ui_->notifications_tray->isChecked()) {
|
||||
notificationType = OSD::TrayPopup;
|
||||
notificationType = OSDBase::TrayPopup;
|
||||
}
|
||||
|
||||
// If user changes timeout or other options, that won't be reflected in the preview
|
||||
|
||||
@@ -112,10 +112,11 @@ void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
|
||||
}
|
||||
|
||||
SettingsDialog::SettingsDialog(Application *app, QMainWindow *mainwindow, QWidget *parent)
|
||||
SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *mainwindow, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
mainwindow_(mainwindow),
|
||||
app_(app),
|
||||
osd_(osd),
|
||||
player_(app_->player()),
|
||||
engine_(app_->player()->engine()),
|
||||
model_(app_->collection_model()->directory_model()),
|
||||
@@ -278,7 +279,7 @@ void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *paren
|
||||
if (!parent) parent = ui_->list->invisibleRootItem();
|
||||
|
||||
// Connect page's signals to the settings dialog's signals
|
||||
connect(page, SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)), SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
|
||||
connect(page, SIGNAL(NotificationPreview(OSDBase::Behaviour, QString, QString)), SIGNAL(NotificationPreview(OSDBase::Behaviour, QString, QString)));
|
||||
|
||||
// Create the list item
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "engine/engine_fwd.h"
|
||||
#include "widgets/osd.h"
|
||||
#include "osd/osdbase.h"
|
||||
|
||||
class QMainWindow;
|
||||
class QWidget;
|
||||
@@ -69,7 +69,7 @@ class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(Application *app, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
explicit SettingsDialog(Application *app, OSDBase *osd, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
~SettingsDialog() override;
|
||||
|
||||
enum Page {
|
||||
@@ -101,6 +101,7 @@ class SettingsDialog : public QDialog {
|
||||
bool is_loading_settings() const { return loading_settings_; }
|
||||
|
||||
Application *app() const { return app_; }
|
||||
OSDBase *osd() const { return osd_; }
|
||||
Player *player() const { return player_; }
|
||||
EngineBase *engine() const { return engine_; }
|
||||
CollectionDirectoryModel *collection_directory_model() const { return model_; }
|
||||
@@ -138,7 +139,7 @@ class SettingsDialog : public QDialog {
|
||||
|
||||
signals:
|
||||
void ReloadSettings();
|
||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||
void NotificationPreview(OSDBase::Behaviour, QString, QString);
|
||||
|
||||
private slots:
|
||||
void CurrentItemChanged(QTreeWidgetItem *item);
|
||||
@@ -149,6 +150,7 @@ class SettingsDialog : public QDialog {
|
||||
|
||||
QMainWindow *mainwindow_;
|
||||
Application *app_;
|
||||
OSDBase *osd_;
|
||||
Player *player_;
|
||||
EngineBase *engine_;
|
||||
CollectionDirectoryModel *model_;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "widgets/osd.h"
|
||||
#include "osd/osdbase.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
@@ -72,7 +72,7 @@ class SettingsPage : public QWidget {
|
||||
virtual void Cancel() {}
|
||||
|
||||
signals:
|
||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||
void NotificationPreview(OSDBase::Behaviour, QString, QString);
|
||||
|
||||
private:
|
||||
SettingsDialog *dialog_;
|
||||
|
||||
Reference in New Issue
Block a user