diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 1a1630508b..e9b487058f 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -327,6 +327,7 @@ SET(Gui_UIC_SRCS DlgSettingsImage.ui DlgSettingsLazyLoaded.ui DlgSettingsMacro.ui + DlgSettingsNotificationArea.ui DlgSettingsPythonConsole.ui DlgCheckableMessageBox.ui DlgToolbars.ui @@ -568,6 +569,7 @@ SET(Dialog_Settings_CPP_SRCS DlgSettingsImageImp.cpp DlgSettingsLazyLoadedImp.cpp DlgSettingsMacroImp.cpp + DlgSettingsNotificationArea.cpp DlgSettingsPythonConsole.cpp ) SET(Dialog_Settings_HPP_SRCS @@ -587,6 +589,7 @@ SET(Dialog_Settings_HPP_SRCS DlgSettingsImageImp.h DlgSettingsLazyLoadedImp.h DlgSettingsMacroImp.h + DlgSettingsNotificationArea.h DlgSettingsPythonConsole.h ) SET(Dialog_Settings_SRCS @@ -608,6 +611,7 @@ SET(Dialog_Settings_SRCS DlgSettingsImage.ui DlgSettingsLazyLoaded.ui DlgSettingsMacro.ui + DlgSettingsNotificationArea.ui DlgSettingsPythonConsole.ui ) SOURCE_GROUP("Dialog\\Settings" FILES ${Dialog_Settings_SRCS}) diff --git a/src/Gui/DlgSettingsNotificationArea.cpp b/src/Gui/DlgSettingsNotificationArea.cpp new file mode 100644 index 0000000000..cc1daec243 --- /dev/null +++ b/src/Gui/DlgSettingsNotificationArea.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + * Copyright (c) 2023 Abdullah Tahiri * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" + +#ifndef _PreComp_ +# include +#endif + +#include "DlgSettingsNotificationArea.h" +#include "ui_DlgSettingsNotificationArea.h" + + +using namespace Gui::Dialog; + +/* TRANSLATOR Gui::Dialog::DlgSettingsNotificationArea */ + +DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent) + : PreferencePage(parent) + , ui(new Ui_DlgSettingsNotificationArea) +{ + ui->setupUi(this); + + connect(ui->NotificationAreaEnabled, &QCheckBox::stateChanged, [this](int state) { + if(state == Qt::CheckState::Checked) { + ui->NonIntrusiveNotificationsEnabled->setEnabled(true); + ui->maxDuration->setEnabled(true); + ui->maxDuration->setEnabled(true); + ui->minDuration->setEnabled(true); + ui->maxNotifications->setEnabled(true); + ui->maxWidgetMessages->setEnabled(true); + ui->autoRemoveUserNotifications->setEnabled(true); + QMessageBox::information(this, tr("Notification Area"), + tr("Activation of the Notification Area only takes effect after an application restart.")); + } + else { + ui->NonIntrusiveNotificationsEnabled->setEnabled(false); + ui->maxDuration->setEnabled(false); + ui->maxDuration->setEnabled(false); + ui->minDuration->setEnabled(false); + ui->maxNotifications->setEnabled(false); + ui->maxWidgetMessages->setEnabled(false); + ui->autoRemoveUserNotifications->setEnabled(false); + // N.B: Deactivation is handled by the Notification Area itself, as it listens to all its configuration parameters. + } + }); +} + +DlgSettingsNotificationArea::~DlgSettingsNotificationArea() +{ +} + +void DlgSettingsNotificationArea::saveSettings() +{ + ui->NotificationAreaEnabled->onSave(); + ui->NonIntrusiveNotificationsEnabled->onSave(); + ui->maxDuration->onSave(); + ui->minDuration->onSave(); + ui->maxNotifications->onSave(); + ui->maxWidgetMessages->onSave(); + ui->autoRemoveUserNotifications->onSave(); +} + +void DlgSettingsNotificationArea::loadSettings() +{ + ui->NotificationAreaEnabled->onRestore(); + ui->NonIntrusiveNotificationsEnabled->onRestore(); + ui->maxDuration->onRestore(); + ui->minDuration->onRestore(); + ui->maxNotifications->onRestore(); + ui->maxWidgetMessages->onRestore(); + ui->autoRemoveUserNotifications->onRestore(); +} + +void DlgSettingsNotificationArea::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + QWidget::changeEvent(e); +} + +#include "moc_DlgSettingsNotificationArea.cpp" diff --git a/src/Gui/DlgSettingsNotificationArea.h b/src/Gui/DlgSettingsNotificationArea.h new file mode 100644 index 0000000000..4aac834a3b --- /dev/null +++ b/src/Gui/DlgSettingsNotificationArea.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (c) 2023 Abdullah Tahiri * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H +#define GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H + +#include "PropertyPage.h" +#include + +namespace Gui { +namespace Dialog { +class Ui_DlgSettingsNotificationArea; + +/** + * The DlgSettingsNotificationArea class implements a preference page to change settings + * for the Notification Area. + */ +class DlgSettingsNotificationArea : public PreferencePage +{ + Q_OBJECT + +public: + explicit DlgSettingsNotificationArea(QWidget* parent = nullptr); + ~DlgSettingsNotificationArea() override; + + void saveSettings() override; + void loadSettings() override; + +protected: + void changeEvent(QEvent *e) override; + +private: + std::unique_ptr ui; +}; + +} // namespace Dialog +} // namespace Gui + +#endif // GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H diff --git a/src/Gui/DlgSettingsNotificationArea.ui b/src/Gui/DlgSettingsNotificationArea.ui new file mode 100644 index 0000000000..d430c5ee94 --- /dev/null +++ b/src/Gui/DlgSettingsNotificationArea.ui @@ -0,0 +1,240 @@ + + + Gui::Dialog::DlgSettingsNotificationArea + + + + 0 + 0 + 654 + 356 + + + + Notification Area + + + + + + 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 + + + 15 + + + MaxOpenNotifications + + + NotificationArea + + + + + + + + + + Settings + + + + + + 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 + + + + + + + + + + Qt::Vertical + + + + 20 + 63 + + + + + + + + Message List + + + + + + Limit the number of messages that will be kept in the list. If 0 there is no limit. + + + 10000 + + + 1000 + + + MaxWidgetMessages + + + NotificationArea + + + + + + + Maximum Messages (0 = no limit): + + + + + + + Removes the user notifications from the message list after the non-intrusive maximum duration has lapsed. + + + Auto-remove User Notifications + + + true + + + AutoRemoveUserNotifications + + + NotificationArea + + + + + + + + + + + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp index ac2b8ae313..8e84edf1e2 100644 --- a/src/Gui/resource.cpp +++ b/src/Gui/resource.cpp @@ -36,6 +36,7 @@ #include "DlgSettingsViewColor.h" #include "DlgGeneralImp.h" #include "DlgEditorImp.h" +#include "DlgSettingsNotificationArea.h" #include "DlgSettingsPythonConsole.h" #include "DlgSettingsMacroImp.h" #include "DlgSettingsUnitsImp.h" @@ -66,19 +67,20 @@ WidgetFactorySupplier::WidgetFactorySupplier() // ADD YOUR PREFERENCE PAGES HERE // // - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); - new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Workbenches") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Workbenches") ); // ADD YOUR CUSTOMIZE PAGES HERE //