From 3b39296599bc8fdf80405bbc1ca8ffc929b84cb6 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:15:52 +0100 Subject: [PATCH] Improve Notification Area settings (#15207) * Initial UI mockup for notification area settings * First iteration of adapting the code to the Notification area settings UI reorg * Remove redundant code to enable/disable widgets * Reorganize notification area settings UI, improve settings and tooltips text * Auto-wrap tooltips, add tooltips for each group * Remove trailing space * Fix merge error * Further fixes from merge error --------- Co-authored-by: WandererFan --- .../DlgSettingsNotificationArea.cpp | 47 +- .../DlgSettingsNotificationArea.h | 3 - .../DlgSettingsNotificationArea.ui | 558 +++++++++--------- 3 files changed, 297 insertions(+), 311 deletions(-) diff --git a/src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp b/src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp index 025e6bcd82..53e91b3beb 100644 --- a/src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp +++ b/src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp @@ -26,6 +26,8 @@ #include #endif +#include +#include #include "DlgSettingsNotificationArea.h" #include "ui_DlgSettingsNotificationArea.h" @@ -40,10 +42,9 @@ DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent) { ui->setupUi(this); - adaptUiToAreaEnabledState(ui->NotificationAreaEnabled->isChecked()); - connect(ui->NotificationAreaEnabled, &QCheckBox::stateChanged, [this](int state) { - bool enabled = state == Qt::CheckState::Checked; - this->adaptUiToAreaEnabledState(enabled); + connect(ui->NotificationAreaEnabled, &QGroupBox::toggled, [this](int on) { + + bool enabled = on; if (enabled) { this->requireRestart(); @@ -55,8 +56,16 @@ DlgSettingsNotificationArea::~DlgSettingsNotificationArea() = default; void DlgSettingsNotificationArea::saveSettings() { - ui->NotificationAreaEnabled->onSave(); - ui->NonIntrusiveNotificationsEnabled->onSave(); + // must be done as very first because we create a new instance of NavigatorStyle + // where we set some attributes afterwards + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/NotificationArea"); + + bool isNotificationAreaEnabled = ui->NotificationAreaEnabled->isChecked(); + hGrp->SetBool("NotificationAreaEnabled", isNotificationAreaEnabled); + bool isNonIntrusiveNotificationsEnabled = ui->NotificationAreaEnabled->isChecked(); + hGrp->SetBool("NonIntrusiveNotificationsEnabled", isNonIntrusiveNotificationsEnabled); + ui->maxDuration->onSave(); ui->minDuration->onSave(); ui->maxNotifications->onSave(); @@ -71,8 +80,15 @@ void DlgSettingsNotificationArea::saveSettings() void DlgSettingsNotificationArea::loadSettings() { - ui->NotificationAreaEnabled->onRestore(); - ui->NonIntrusiveNotificationsEnabled->onRestore(); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/NotificationArea"); + + bool isNotificationAreaEnabled = hGrp->GetBool("NotificationAreaEnabled", true); + ui->NotificationAreaEnabled->setChecked(isNotificationAreaEnabled); + + bool isNonIntrusiveNotificationsEnabled = hGrp->GetBool("NonIntrusiveNotificationsEnabled", true); + ui->NonIntrusiveNotificationsEnabled->setChecked(isNonIntrusiveNotificationsEnabled); + ui->maxDuration->onRestore(); ui->minDuration->onRestore(); ui->maxNotifications->onRestore(); @@ -85,21 +101,6 @@ void DlgSettingsNotificationArea::loadSettings() ui->developerWarningSubscriptionEnabled->onRestore(); } -void DlgSettingsNotificationArea::adaptUiToAreaEnabledState(bool enabled) -{ - ui->NonIntrusiveNotificationsEnabled->setEnabled(enabled); - ui->maxDuration->setEnabled(enabled); - ui->minDuration->setEnabled(enabled); - ui->maxNotifications->setEnabled(enabled); - ui->maxWidgetMessages->setEnabled(enabled); - ui->autoRemoveUserNotifications->setEnabled(enabled); - ui->notificationWidth->setEnabled(enabled); - ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(enabled); - ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(enabled); - ui->developerErrorSubscriptionEnabled->setEnabled(enabled); - ui->developerWarningSubscriptionEnabled->setEnabled(enabled); -} - void DlgSettingsNotificationArea::changeEvent(QEvent* e) { if (e->type() == QEvent::LanguageChange) { diff --git a/src/Gui/PreferencePages/DlgSettingsNotificationArea.h b/src/Gui/PreferencePages/DlgSettingsNotificationArea.h index 94a675b2c1..ca96954ce1 100644 --- a/src/Gui/PreferencePages/DlgSettingsNotificationArea.h +++ b/src/Gui/PreferencePages/DlgSettingsNotificationArea.h @@ -49,9 +49,6 @@ public: protected: void changeEvent(QEvent *e) override; -private: - void adaptUiToAreaEnabledState(bool enabled); - private: std::unique_ptr ui; }; diff --git a/src/Gui/PreferencePages/DlgSettingsNotificationArea.ui b/src/Gui/PreferencePages/DlgSettingsNotificationArea.ui index 3e0ce0013e..9a800236dc 100644 --- a/src/Gui/PreferencePages/DlgSettingsNotificationArea.ui +++ b/src/Gui/PreferencePages/DlgSettingsNotificationArea.ui @@ -7,7 +7,7 @@ 0 0 654 - 375 + 557 @@ -15,311 +15,299 @@ - + + + <html><head/><body><p>If checked, show the notification area in the status bar: a button with the current notification count, which can expand the detailed notification list. Optionally, with additional pop-up notifications.</p></body></html> + - Settings + Enable notification area + + + true - - - - The Notification area will appear in the status bar - - - Enable Notification Area - - - true - - - NotificationAreaEnabled - - - NotificationArea - - - - - - - Non-intrusive notifications will appear next to the notification area in the status bar - - - Enable non-intrusive notifications - - - true - - - NonIntrusiveNotificationsEnabled - - - NotificationArea - - - - - - - - - - Additional data sources - - - - - - Errors intended for developers will appear in the notification area - - - Debug errors - - - false - - - DeveloperErrorSubscriptionEnabled - - - NotificationArea - - - - - - - Warnings intended for developers will appear in the notification area - - - Debug warnings - - - false - - - DeveloperWarningSubscriptionEnabled - - - NotificationArea - - - - - - - - - - Non-Intrusive Notifications - - - - - - Minimum Duration: - - - - - - - - - - Maximum Duration: - - - - - - - Duration during which the notification will be shown (unless mouse buttons are clicked) - - - s - - - 0 - - - 120 - - - 20 - - - NotificationTime - - - NotificationArea - - - - - - - Minimum duration during which the notification will be shown (unless notification clicked) - - - s - - - 5 - - - MinimumOnScreenTime - - - NotificationArea - - - - - - Maximum Number of Notifications: - - - - - + - Maximum number of notifications that will be simultaneously present on the screen + If checked, non-intrusive pop-up notifications will appear above the status bar, around the notification area. Pop-up notifications can be manually dismissed by clicking on them, and also automatically dismissed by specifying a maximum and minimum duration for them to be displayed. + +Additionally, pop-up notifications can be disabled. In this case the user can still use the notification area as a quick-access location to view notifications, without the distracton of an additional pop-up. - - 15 + + Enable pop-up notifications - - MaxOpenNotifications - - - NotificationArea - - - - - - - Notification width: - - - - - - - Width of the notification in pixels - - - px - - - 300 - - - 10000 - - - 800 - - - NotificiationWidth - - - NotificationArea - - - - - - - Any open non-intrusive notifications will disappear when another window is activated - - - Hide when other window is activated + + true true - - HideNonIntrusiveNotificationsWhenWindowDeactivated - - - NotificationArea - - - - - - - Prevent non-intrusive notifications from appearing when the FreeCAD Window is not the active window - - - Do not show when inactive - - - true - - - PreventNonIntrusiveNotificationsWhenWindowNotActive - - - NotificationArea - - - - - - - - - - Message List - - - - - - Limit the number of messages that will be kept in the list. If 0 there is no limit. - - - 10000 - - - 1000 - - - MaxWidgetMessages - - - NotificationArea - + + + + + Minimum duration: + + + + + + + + + + Maximum duration: + + + + + + + <html><head/><body><p>Maximum amount of time the notification will be shown (unless mouse buttons are clicked). It also controls when user notifications will be removed if the &quot;Auto-remove user notifications&quot; setting is checked.</p></body></html> + + + s + + + 0 + + + 120 + + + 20 + + + NotificationTime + + + NotificationArea + + + + + + + <html><head/><body><p>Minimum amount of time the notification will be shown (unless the notification bubble is dismissed by clicking on it).</p></body></html> + + + s + + + 5 + + + MinimumOnScreenTime + + + NotificationArea + + + + + + + Maximum concurrent notification count: + + + + + + + Maximum number of notifications that will be simultaneously present on the notification bubble. + + + 15 + + + MaxOpenNotifications + + + NotificationArea + + + + + + + Notification bubble width: + + + + + + + Width of the pop-up notification bubble in pixels. + + + px + + + + + + 300 + + + 10000 + + + 800 + + + NotificiationWidth + + + NotificationArea + + + + + + + Any open pop-up notifications will disappear when another window is activated. + + + Hide when other window is activated + + + true + + + HideNonIntrusiveNotificationsWhenWindowDeactivated + + + NotificationArea + + + + + + + Prevent pop-up notifications from appearing when the FreeCAD window is not the active window. + + + Do not show when window is inactive + + + true + + + PreventNonIntrusiveNotificationsWhenWindowNotActive + + + NotificationArea + + + + - - - Maximum Messages (0 = no limit): + + + Additional notification sources to show in the notification area. + + Additional data sources + + + + + + Errors intended for developers will appear in the notification area. + + + Debug errors + + + false + + + DeveloperErrorSubscriptionEnabled + + + NotificationArea + + + + + + + Warnings intended for developers will appear in the notification area. + + + Debug warnings + + + false + + + DeveloperWarningSubscriptionEnabled + + + NotificationArea + + + + - + - Removes the user notifications from the message list after the non-intrusive maximum duration has lapsed. + Controls the amount of notifications to show in the list. - - Auto-remove User Notifications - - - true - - - AutoRemoveUserNotifications - - - NotificationArea + + Notifications list + + + + + Limits the number of notifications that will be kept in the list. If 0, there is no limit. + + + 10000 + + + 1000 + + + MaxWidgetMessages + + + NotificationArea + + + + + + + Maximum notification count: + + + + + + + Removes the user notifications from the notifications list after the maximum duration for pop-up notifications has lapsed. + + + Auto-remove user notifications + + + true + + + AutoRemoveUserNotifications + + + NotificationArea + + + +