From 8b7c5d8585d82a81a3d562bb377ab53ed01e680a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 5 Jun 2020 23:46:07 +0200 Subject: [PATCH] Fix saving OSD pretty settings --- src/settings/notificationssettingspage.cpp | 23 +++++++++++++++++++++- src/settings/notificationssettingspage.h | 2 ++ src/widgets/osdpretty.cpp | 1 + src/widgets/osdpretty.h | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index d1f07b641..77041a858 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -60,6 +60,7 @@ const char *NotificationsSettingsPage::kSettingsGroup = "Notifications"; NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_NotificationsSettingsPage), pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) { + ui_->setupUi(this); setWindowIcon(IconLoader::Load("help-hint")); @@ -121,6 +122,8 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog) ui_->notifications_exp_chooser1->setIcon(IconLoader::Load("list-add")); ui_->notifications_exp_chooser2->setIcon(IconLoader::Load("list-add")); + connect(pretty_popup_, SIGNAL(PositionChanged()), SLOT(PrettyOSDChanged())); + } NotificationsSettingsPage::~NotificationsSettingsPage() { @@ -236,11 +239,16 @@ void NotificationsSettingsPage::Save() { } void NotificationsSettingsPage::PrettyOpacityChanged(int value) { + pretty_popup_->set_background_opacity(qreal(value) / 100.0); + set_changed(); + } void NotificationsSettingsPage::UpdatePopupVisible() { + pretty_popup_->setVisible(isVisible() && ui_->notifications_pretty->isChecked()); + } void NotificationsSettingsPage::PrettyColorPresetChanged(int index) { @@ -262,6 +270,8 @@ void NotificationsSettingsPage::PrettyColorPresetChanged(int index) { break; } + set_changed(); + } void NotificationsSettingsPage::ChooseBgColor() { @@ -273,6 +283,8 @@ void NotificationsSettingsPage::ChooseBgColor() { pretty_popup_->set_background_color(color.rgb()); ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole); + set_changed(); + } void NotificationsSettingsPage::ChooseFgColor() { @@ -283,13 +295,18 @@ void NotificationsSettingsPage::ChooseFgColor() { pretty_popup_->set_foreground_color(color.rgb()); + set_changed(); + } void NotificationsSettingsPage::ChooseFont() { bool ok; QFont font = QFontDialog::getFont(&ok, pretty_popup_->font(), this); - if (ok) pretty_popup_->set_font(font); + if (ok) { + pretty_popup_->set_font(font); + set_changed(); + } } @@ -355,3 +372,7 @@ void NotificationsSettingsPage::NotificationTypeChanged() { ui_->notifications_disable_duration->setEnabled(pretty); } + +void NotificationsSettingsPage::PrettyOSDChanged() { + set_changed(); +} diff --git a/src/settings/notificationssettingspage.h b/src/settings/notificationssettingspage.h index 7a208ca84..7378023da 100644 --- a/src/settings/notificationssettingspage.h +++ b/src/settings/notificationssettingspage.h @@ -67,6 +67,8 @@ class NotificationsSettingsPage : public SettingsPage { void UpdatePopupVisible(); + void PrettyOSDChanged(); + private: Ui_NotificationsSettingsPage *ui_; OSDPretty *pretty_popup_; diff --git a/src/widgets/osdpretty.cpp b/src/widgets/osdpretty.cpp index 6773dc9fa..2384168ce 100644 --- a/src/widgets/osdpretty.cpp +++ b/src/widgets/osdpretty.cpp @@ -491,6 +491,7 @@ void OSDPretty::mouseReleaseEvent(QMouseEvent *) { popup_screen_ = current_screen(); popup_screen_name_ = current_screen()->name(); popup_pos_ = current_pos(); + emit PositionChanged(); } } diff --git a/src/widgets/osdpretty.h b/src/widgets/osdpretty.h index aee726d75..60ec1f55c 100644 --- a/src/widgets/osdpretty.h +++ b/src/widgets/osdpretty.h @@ -107,6 +107,9 @@ class OSDPretty : public QWidget { bool toggle_mode() const { return toggle_mode_; } void set_toggle_mode(bool toggle_mode) { toggle_mode_ = toggle_mode; } + signals: + void PositionChanged(); + public slots: void ReloadSettings();