| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2023 Abdullah Tahiri <[email protected]> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#include <QMessageBox> |
| 25 |
|
| 26 |
|
| 27 |
#include <App/Application.h> |
| 28 |
#include <Base/Parameter.h> |
| 29 |
#include "DlgSettingsNotificationArea.h" |
| 30 |
#include "ui_DlgSettingsNotificationArea.h" |
| 31 |
|
| 32 |
|
| 33 |
using namespace Gui::Dialog; |
| 34 |
|
| 35 |
/* TRANSLATOR Gui::Dialog::DlgSettingsNotificationArea */ |
| 36 |
|
| 37 |
DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent) |
| 38 |
: PreferencePage(parent) |
| 39 |
, ui(new Ui_DlgSettingsNotificationArea) |
| 40 |
{ |
| 41 |
ui->setupUi(this); |
| 42 |
|
| 43 |
connect(ui->NotificationAreaEnabled, &QGroupBox::toggled, [this](int on) { |
| 44 |
bool enabled = on; |
| 45 |
|
| 46 |
if (enabled) { |
| 47 |
this->requireRestart(); |
| 48 |
} |
| 49 |
}); |
| 50 |
} |
| 51 |
|
| 52 |
DlgSettingsNotificationArea::~DlgSettingsNotificationArea() = default; |
| 53 |
|
| 54 |
void DlgSettingsNotificationArea::saveSettings() |
| 55 |
{ |
| 56 |
// must be done as very first because we create a new instance of NavigatorStyle |
| 57 |
// where we set some attributes afterwards |
| 58 |
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( |
| 59 |
"User parameter:BaseApp/Preferences/NotificationArea" |
| 60 |
); |
| 61 |
|
| 62 |
bool isNotificationAreaEnabled = ui->NotificationAreaEnabled->isChecked(); |
| 63 |
hGrp->SetBool("NotificationAreaEnabled", isNotificationAreaEnabled); |
| 64 |
bool isNonIntrusiveNotificationsEnabled = ui->NonIntrusiveNotificationsEnabled->isChecked(); |
| 65 |
hGrp->SetBool("NonIntrusiveNotificationsEnabled", isNonIntrusiveNotificationsEnabled); |
| 66 |
|
| 67 |
ui->maxDuration->onSave(); |
| 68 |
ui->minDuration->onSave(); |
| 69 |
ui->maxNotifications->onSave(); |
| 70 |
ui->maxWidgetMessages->onSave(); |
| 71 |
ui->autoRemoveUserNotifications->onSave(); |
| 72 |
ui->notificationWidth->onSave(); |
| 73 |
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onSave(); |
| 74 |
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onSave(); |
| 75 |
ui->developerErrorSubscriptionEnabled->onSave(); |
| 76 |
ui->developerWarningSubscriptionEnabled->onSave(); |
| 77 |
} |
| 78 |
|
| 79 |
void DlgSettingsNotificationArea::loadSettings() |
| 80 |
{ |
| 81 |
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( |
| 82 |
"User parameter:BaseApp/Preferences/NotificationArea" |
| 83 |
); |
| 84 |
|
| 85 |
bool isNotificationAreaEnabled = hGrp->GetBool("NotificationAreaEnabled", true); |
| 86 |
ui->NotificationAreaEnabled->setChecked(isNotificationAreaEnabled); |
| 87 |
|
| 88 |
bool isNonIntrusiveNotificationsEnabled = hGrp->GetBool("NonIntrusiveNotificationsEnabled", true); |
| 89 |
ui->NonIntrusiveNotificationsEnabled->setChecked(isNonIntrusiveNotificationsEnabled); |
| 90 |
|
| 91 |
ui->maxDuration->onRestore(); |
| 92 |
ui->minDuration->onRestore(); |
| 93 |
ui->maxNotifications->onRestore(); |
| 94 |
ui->maxWidgetMessages->onRestore(); |
| 95 |
ui->autoRemoveUserNotifications->onRestore(); |
| 96 |
ui->notificationWidth->onRestore(); |
| 97 |
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onRestore(); |
| 98 |
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onRestore(); |
| 99 |
ui->developerErrorSubscriptionEnabled->onRestore(); |
| 100 |
ui->developerWarningSubscriptionEnabled->onRestore(); |
| 101 |
} |
| 102 |
|
| 103 |
void DlgSettingsNotificationArea::changeEvent(QEvent* e) |
| 104 |
{ |
| 105 |
if (e->type() == QEvent::LanguageChange) { |
| 106 |
ui->retranslateUi(this); |
| 107 |
} |
| 108 |
QWidget::changeEvent(e); |
| 109 |
} |
| 110 |
|
| 111 |
#include "moc_DlgSettingsNotificationArea.cpp" |