Commit 5a1d7405 authored by Cyril Rossi's avatar Cyril Rossi

KCM Notification port to ManagedConfigModule

Summary: Require D26047 At least, the properties of Notification tab in the KCM is handled properly.

Reviewers: #plasma, ervin, bport, mart, davidedmundson, meven

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26048
parent f256a0df
......@@ -45,14 +45,22 @@
#include "filterproxymodel.h"
#include <notificationmanager/settings.h>
#include <notificationmanager/donotdisturbsettings.h>
#include <notificationmanager/notificationsettings.h>
#include <notificationmanager/jobsettings.h>
#include <notificationmanager/badgesettings.h>
K_PLUGIN_FACTORY_WITH_JSON(KCMNotificationsFactory, "kcm_notifications.json", registerPlugin<KCMNotifications>();)
KCMNotifications::KCMNotifications(QObject *parent, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, args)
: KQuickAddons::ManagedConfigModule(parent, args)
, m_sourcesModel(new SourcesModel(this))
, m_filteredModel(new FilterProxyModel(this))
, m_settings(new NotificationManager::Settings(this))
, m_dndSettings(new NotificationManager::DoNotDisturbSettings(this))
, m_notificationSettings(new NotificationManager::NotificationSettings(this))
, m_jobSettings(new NotificationManager::JobSettings(this))
, m_badgeSettings(new NotificationManager::BadgeSettings(this))
, m_toggleDoNotDisturbAction(new QAction(this))
{
......@@ -61,6 +69,10 @@ KCMNotifications::KCMNotifications(QObject *parent, const QVariantList &args)
QStringLiteral("Cannot create instances of SourcesModel"));
qmlRegisterType<FilterProxyModel>();
qmlRegisterType<QKeySequence>();
qmlRegisterType<NotificationManager::DoNotDisturbSettings>();
qmlRegisterType<NotificationManager::NotificationSettings>();
qmlRegisterType<NotificationManager::JobSettings>();
qmlRegisterType<NotificationManager::BadgeSettings>();
qmlProtectModule(uri, 1);
KAboutData *about = new KAboutData(QStringLiteral("kcm_notifications"), i18n("Notifications"),
......@@ -121,6 +133,26 @@ NotificationManager::Settings *KCMNotifications::settings() const
return m_settings;
}
NotificationManager::DoNotDisturbSettings *KCMNotifications::dndSettings() const
{
return m_dndSettings;
}
NotificationManager::NotificationSettings *KCMNotifications::notificationSettings() const
{
return m_notificationSettings;
}
NotificationManager::JobSettings *KCMNotifications::jobSettings() const
{
return m_jobSettings;
}
NotificationManager::BadgeSettings *KCMNotifications::badgeSettings() const
{
return m_badgeSettings;
}
QKeySequence KCMNotifications::toggleDoNotDisturbShortcut() const
{
return m_toggleDoNotDisturbShortcut;
......@@ -221,6 +253,7 @@ void KCMNotifications::configureEvents(const QString &notifyRcName, const QStrin
void KCMNotifications::load()
{
ManagedConfigModule::load();
m_settings->load();
const QKeySequence toggleDoNotDisturbShortcut = KGlobalAccel::self()->globalShortcut(
......@@ -238,6 +271,7 @@ void KCMNotifications::load()
void KCMNotifications::save()
{
ManagedConfigModule::save();
m_settings->save();
if (m_toggleDoNotDisturbShortcutDirty) {
......@@ -252,6 +286,7 @@ void KCMNotifications::save()
void KCMNotifications::defaults()
{
ManagedConfigModule::defaults();
m_settings->defaults();
setToggleDoNotDisturbShortcut(QKeySequence());
......
......@@ -20,7 +20,7 @@
#pragma once
#include <KQuickAddons/ConfigModule>
#include <KQuickAddons/ManagedConfigModule>
#include <QKeySequence>
......@@ -31,9 +31,13 @@ class FilterProxyModel;
namespace NotificationManager {
class Settings;
class DoNotDisturbSettings;
class NotificationSettings;
class JobSettings;
class BadgeSettings;
}
class KCMNotifications : public KQuickAddons::ConfigModule
class KCMNotifications : public KQuickAddons::ManagedConfigModule
{
Q_OBJECT
......@@ -41,6 +45,10 @@ class KCMNotifications : public KQuickAddons::ConfigModule
Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT)
Q_PROPERTY(NotificationManager::Settings *settings READ settings CONSTANT)
Q_PROPERTY(NotificationManager::DoNotDisturbSettings *dndSettings READ dndSettings CONSTANT)
Q_PROPERTY(NotificationManager::NotificationSettings *notificationSettings READ notificationSettings CONSTANT)
Q_PROPERTY(NotificationManager::JobSettings *jobSettings READ jobSettings CONSTANT)
Q_PROPERTY(NotificationManager::BadgeSettings *badgeSettings READ badgeSettings CONSTANT)
Q_PROPERTY(QKeySequence toggleDoNotDisturbShortcut
READ toggleDoNotDisturbShortcut
......@@ -60,6 +68,10 @@ public:
FilterProxyModel *filteredModel() const;
NotificationManager::Settings *settings() const;
NotificationManager::DoNotDisturbSettings *dndSettings() const;
NotificationManager::NotificationSettings *notificationSettings() const;
NotificationManager::JobSettings *jobSettings() const;
NotificationManager::BadgeSettings *badgeSettings() const;
QKeySequence toggleDoNotDisturbShortcut() const;
void setToggleDoNotDisturbShortcut(const QKeySequence &shortcut);
......@@ -93,6 +105,10 @@ private:
FilterProxyModel *m_filteredModel;
NotificationManager::Settings *m_settings;
NotificationManager::DoNotDisturbSettings *m_dndSettings;
NotificationManager::NotificationSettings *m_notificationSettings;
NotificationManager::JobSettings *m_jobSettings;
NotificationManager::BadgeSettings *m_badgeSettings;
QAction *m_toggleDoNotDisturbAction;
QKeySequence m_toggleDoNotDisturbShortcut;
......
......@@ -30,7 +30,7 @@ Kirigami.Page {
ScreenPositionSelector {
anchors.horizontalCenter: parent.horizontalCenter
selectedPosition: kcm.settings.popupPosition
onSelectedPositionChanged: kcm.settings.popupPosition = selectedPosition
selectedPosition: kcm.notificationSettings.popupPosition
onSelectedPositionChanged: kcm.notificationSettings.popupPosition = selectedPosition
}
}
......@@ -30,7 +30,7 @@ import org.kde.notificationmanager 1.0 as NotificationManager
KCM.SimpleKCM {
id: root
KCM.ConfigModule.quickHelp: i18n("This module lets you manage application and system notifications.")
KCM.ConfigModule.buttons: KCM.ConfigModule.Help | KCM.ConfigModule.Apply
// Sidebar on SourcesPage is 1/3 of the width at a minimum of 12, so assume 3 * 12 = 36 as preferred
implicitWidth: Kirigami.Units.gridUnit * 36
......@@ -83,16 +83,16 @@ KCM.SimpleKCM {
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Do Not Disturb mode:")
text: i18nc("Do not disturb when screens are mirrored", "Enable when screens are mirrored")
checked: kcm.settings.inhibitNotificationsWhenScreensMirrored
onClicked: kcm.settings.inhibitNotificationsWhenScreensMirrored = checked
enabled: root.notificationsAvailable
checked: kcm.dndSettings.whenScreensMirrored
onClicked: kcm.dndSettings.whenScreensMirrored = checked
enabled: root.notificationsAvailable && !kcm.dndSettings.isImmutable("WhenScreensMirrored")
}
QtControls.CheckBox {
text: i18n("Show critical notifications")
checked: kcm.settings.criticalPopupsInDoNotDisturbMode
onClicked: kcm.settings.criticalPopupsInDoNotDisturbMode = checked
enabled: root.notificationsAvailable
checked: kcm.notificationSettings.criticalInDndMode
onClicked: kcm.notificationSettings.criticalInDndMode = checked
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("CriticalInDndMode")
}
RowLayout {
......@@ -115,9 +115,9 @@ KCM.SimpleKCM {
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Critical notifications:")
text: i18n("Always keep on top")
checked: kcm.settings.keepCriticalAlwaysOnTop
onClicked: kcm.settings.keepCriticalAlwaysOnTop = checked
enabled: root.notificationsAvailable
checked: kcm.notificationSettings.criticalAlwaysOnTop
onClicked: kcm.notificationSettings.criticalAlwaysOnTop = checked
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("CriticalAlwaysOnTop")
}
Item {
......@@ -127,16 +127,16 @@ KCM.SimpleKCM {
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Low priority notifications:")
text: i18n("Show popup")
checked: kcm.settings.lowPriorityPopups
onClicked: kcm.settings.lowPriorityPopups = checked
enabled: root.notificationsAvailable
checked: kcm.notificationSettings.lowPriorityPopups
onClicked: kcm.notificationSettings.lowPriorityPopups = checked
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("LowPriorityPopups")
}
QtControls.CheckBox {
text: i18n("Show in history")
checked: kcm.settings.lowPriorityHistory
onClicked: kcm.settings.lowPriorityHistory = checked
enabled: root.notificationsAvailable
checked: kcm.notificationSettings.lowPriorityHistory
onClicked: kcm.notificationSettings.lowPriorityHistory = checked
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("LowPriorityHistory")
}
QtControls.ButtonGroup {
......@@ -152,20 +152,20 @@ KCM.SimpleKCM {
id: positionCloseToWidget
Kirigami.FormData.label: i18n("Popup:")
text: i18nc("Popup position near notification plasmoid", "Show near notification icon") // "widget"
checked: kcm.settings.popupPosition === NotificationManager.Settings.CloseToWidget
checked: kcm.notificationSettings.popupPosition === NotificationManager.Settings.CloseToWidget
// Force binding re-evaluation when user returns from position selector
+ kcm.currentIndex * 0
onClicked: kcm.settings.popupPosition = NotificationManager.Settings.CloseToWidget
enabled: root.notificationsAvailable
onClicked: kcm.notificationSettings.popupPosition = NotificationManager.Settings.CloseToWidget
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("PopupPosition")
}
RowLayout {
spacing: 0
enabled: root.notificationsAvailable
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("PopupPosition")
QtControls.RadioButton {
id: positionCustomPosition
checked: kcm.settings.popupPosition !== NotificationManager.Settings.CloseToWidget
checked: kcm.notificationSettings.popupPosition !== NotificationManager.Settings.CloseToWidget
+ kcm.currentIndex * 0
activeFocusOnTab: false
......@@ -203,8 +203,8 @@ KCM.SimpleKCM {
from: 1000 // 1 second
to: 120000 // 2 minutes
stepSize: 1000
value: kcm.settings.popupTimeout
enabled: root.notificationsAvailable
value: kcm.notificationSettings.popupTimeout
enabled: root.notificationsAvailable && !kcm.notificationSettings.isImmutable("PopupTimeout")
editable: true
valueFromText: function(text, locale) {
return parseInt(text) * 1000;
......@@ -212,7 +212,7 @@ KCM.SimpleKCM {
textFromValue: function(value, locale) {
return i18np("%1 second", "%1 seconds", Math.round(value / 1000));
}
onValueModified: kcm.settings.popupTimeout = value
onValueModified: kcm.notificationSettings.popupTimeout = value
}
}
......@@ -223,15 +223,17 @@ KCM.SimpleKCM {
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Application progress:")
text: i18n("Show in task manager")
checked: kcm.settings.jobsInTaskManager
onClicked: kcm.settings.jobsInTaskManager = checked
checked: kcm.jobSettings.inTaskManager
onClicked: kcm.jobSettings.inTaskManager = checked
enabled: !kcm.jobSettings.isImmutable("InTaskManager")
}
QtControls.CheckBox {
id: applicationJobsEnabledCheck
text: i18nc("Show application jobs in notification widget", "Show in notifications")
checked: kcm.settings.jobsInNotifications
onClicked: kcm.settings.jobsInNotifications = checked
checked: kcm.jobSettings.inNotifications
onClicked: kcm.jobSettings.inNotifications = checked
enabled: !kcm.jobSettings.isImmutable("InNotifications")
}
RowLayout { // just for indentation
......@@ -239,9 +241,9 @@ KCM.SimpleKCM {
Layout.leftMargin: mirrored ? 0 : indicator.width
Layout.rightMargin: mirrored ? indicator.width : 0
text: i18nc("Keep application job popup open for entire duration of job", "Keep popup open during progress")
enabled: applicationJobsEnabledCheck.checked
checked: kcm.settings.permanentJobPopups
onClicked: kcm.settings.permanentJobPopups = checked
enabled: applicationJobsEnabledCheck.checked && !kcm.jobSettings.isImmutable("PermanentPopups")
checked: kcm.jobSettings.permanentPopups
onClicked: kcm.jobSettings.permanentPopups = checked
}
}
......@@ -252,8 +254,9 @@ KCM.SimpleKCM {
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Notification badges:")
text: i18n("Show in task manager")
checked: kcm.settings.badgesInTaskManager
onClicked: kcm.settings.badgesInTaskManager = checked
checked: kcm.badgeSettings.inTaskManager
onClicked: kcm.badgeSettings.inTaskManager = checked
enabled: !kcm.badgeSettings.isImmutable("InTaskManager")
}
Kirigami.Separator {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment