Gui: Preference Page for NotificationArea

=========================================

Configuration preference page for controlling the notification area (non-intrusive messages and widget).
This commit is contained in:
Abdullah Tahiri
2023-01-12 14:16:44 +01:00
committed by abdullahtahiriyo
parent eb7bf5d977
commit d43f4cd26b
5 changed files with 420 additions and 13 deletions

View File

@@ -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})

View File

@@ -0,0 +1,102 @@
/***************************************************************************
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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 <QMessageBox>
#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"

View File

@@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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 <memory>
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_DlgSettingsNotificationArea> ui;
};
} // namespace Dialog
} // namespace Gui
#endif // GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsNotificationArea</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsNotificationArea">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>356</height>
</rect>
</property>
<property name="windowTitle">
<string>Notification Area</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Non-Intrusive Notifications</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Minimum Duration:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Maximum Duration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefSpinBox" name="maxDuration">
<property name="toolTip">
<string>Duration during which the notification will be shown (unless mouse buttons are clicked)</string>
</property>
<property name="suffix">
<string>s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>120</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>NotificationTime</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefSpinBox" name="minDuration">
<property name="toolTip">
<string>Minimum duration during which the notification will be shown (unless notification clicked)</string>
</property>
<property name="suffix">
<string>s</string>
</property>
<property name="value">
<number>5</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>MinimumOnScreenTime</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Maximum Number of Notifications:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefSpinBox" name="maxNotifications">
<property name="toolTip">
<string>Maximum number of notifications that will be simultaneously present on the screen</string>
</property>
<property name="value">
<number>15</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>MaxOpenNotifications</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox11">
<property name="title">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="NotificationAreaEnabled">
<property name="toolTip">
<string>The Notification area will appear in the status bar</string>
</property>
<property name="text">
<string>Enable Notification Area</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>NotificationAreaEnabled</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="NonIntrusiveNotificationsEnabled">
<property name="toolTip">
<string>Non-intrusive notifications will appear next to the notification area in the status bar</string>
</property>
<property name="text">
<string>Enable non-intrusive notifications</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>NonIntrusiveNotificationsEnabled</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>63</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Message List</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="Gui::PrefSpinBox" name="maxWidgetMessages">
<property name="toolTip">
<string>Limit the number of messages that will be kept in the list. If 0 there is no limit.</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>MaxWidgetMessages</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Maximum Messages (0 = no limit):</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="autoRemoveUserNotifications">
<property name="toolTip">
<string>Removes the user notifications from the message list after the non-intrusive maximum duration has lapsed.</string>
</property>
<property name="text">
<string>Auto-remove User Notifications</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoRemoveUserNotifications</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>NotificationArea</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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<DlgGeneralImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsDocumentImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsSelection> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsCacheDirectory>( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsEditorImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsPythonConsole> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgReportViewImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsMacroImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsUnitsImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettings3DViewImp> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsNavigation> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsViewColor> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsLazyLoadedImp> ( QT_TRANSLATE_NOOP("QObject","Workbenches") );
new PrefPageProducer<DlgGeneralImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsDocumentImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsSelection> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsCacheDirectory> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsEditorImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsNotificationArea> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsPythonConsole> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgReportViewImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsMacroImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsUnitsImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettings3DViewImp> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsNavigation> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsViewColor> ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer<DlgSettingsLazyLoadedImp> ( QT_TRANSLATE_NOOP("QObject","Workbenches") );
// ADD YOUR CUSTOMIZE PAGES HERE
//