1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #include "gui/settings/settingsnotifications.h"
4
5 #include "3rd-party/boolinq/boolinq.h"
6 #include "gui/guiutilities.h"
7 #include "gui/notifications/notificationseditor.h"
8 #include "miscellaneous/application.h"
9 #include "miscellaneous/notificationfactory.h"
10 #include "miscellaneous/settings.h"
11
12 #include <QDir>
13
SettingsNotifications(Settings * settings,QWidget * parent)14 SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent) : SettingsPanel(settings, parent) {
15 m_ui.setupUi(this);
16
17 GuiUtilities::setLabelAsNotice(*m_ui.m_lblAvailableSounds, false);
18 GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
19
20 connect(m_ui.m_checkEnableNotifications, &QCheckBox::toggled, this, &SettingsNotifications::dirtifySettings);
21 connect(m_ui.m_editor, &NotificationsEditor::someNotificationChanged, this, &SettingsNotifications::dirtifySettings);
22 }
23
loadSettings()24 void SettingsNotifications::loadSettings() {
25 onBeginLoadSettings();
26
27 // Load fancy notification settings.
28 m_ui.m_checkEnableNotifications->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
29 m_ui.m_editor->loadNotifications(qApp->notifications()->allNotifications());
30
31 onEndLoadSettings();
32 }
33
saveSettings()34 void SettingsNotifications::saveSettings() {
35 onBeginSaveSettings();
36
37 // Save notifications.
38 settings()->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked());
39 qApp->notifications()->save(m_ui.m_editor->allNotifications(), settings());
40
41 onEndSaveSettings();
42 }
43