Changeset View
Changeset View
Standalone View
Standalone View
kcms/notifications/kcm.h
Show All 17 Lines | |||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #pragma once | 21 | #pragma once | ||
22 | 22 | | |||
23 | #include <KQuickAddons/ManagedConfigModule> | 23 | #include <KQuickAddons/ManagedConfigModule> | ||
24 | 24 | | |||
25 | #include <QKeySequence> | 25 | #include <QKeySequence> | ||
26 | #include <QHash> | ||||
26 | 27 | | |||
27 | class QAction; | 28 | class QAction; | ||
28 | 29 | | |||
29 | class SourcesModel; | 30 | class SourcesModel; | ||
30 | class FilterProxyModel; | 31 | class FilterProxyModel; | ||
31 | 32 | | |||
32 | namespace NotificationManager { | 33 | namespace NotificationManager { | ||
33 | class Settings; | | |||
34 | class DoNotDisturbSettings; | 34 | class DoNotDisturbSettings; | ||
35 | class NotificationSettings; | 35 | class NotificationSettings; | ||
36 | class JobSettings; | 36 | class JobSettings; | ||
37 | class BadgeSettings; | 37 | class BadgeSettings; | ||
38 | class BehaviorSettings; | ||||
38 | } | 39 | } | ||
39 | 40 | | |||
40 | class KCMNotifications : public KQuickAddons::ManagedConfigModule | 41 | class KCMNotifications : public KQuickAddons::ManagedConfigModule | ||
41 | { | 42 | { | ||
42 | Q_OBJECT | 43 | Q_OBJECT | ||
43 | 44 | | |||
44 | Q_PROPERTY(SourcesModel *sourcesModel READ sourcesModel CONSTANT) | 45 | Q_PROPERTY(SourcesModel *sourcesModel READ sourcesModel CONSTANT) | ||
45 | Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT) | 46 | Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT) | ||
46 | 47 | | |||
47 | Q_PROPERTY(NotificationManager::Settings *settings READ settings CONSTANT) | | |||
48 | Q_PROPERTY(NotificationManager::DoNotDisturbSettings *dndSettings READ dndSettings CONSTANT) | 48 | Q_PROPERTY(NotificationManager::DoNotDisturbSettings *dndSettings READ dndSettings CONSTANT) | ||
49 | Q_PROPERTY(NotificationManager::NotificationSettings *notificationSettings READ notificationSettings CONSTANT) | 49 | Q_PROPERTY(NotificationManager::NotificationSettings *notificationSettings READ notificationSettings CONSTANT) | ||
50 | Q_PROPERTY(NotificationManager::JobSettings *jobSettings READ jobSettings CONSTANT) | 50 | Q_PROPERTY(NotificationManager::JobSettings *jobSettings READ jobSettings CONSTANT) | ||
51 | Q_PROPERTY(NotificationManager::BadgeSettings *badgeSettings READ badgeSettings CONSTANT) | 51 | Q_PROPERTY(NotificationManager::BadgeSettings *badgeSettings READ badgeSettings CONSTANT) | ||
52 | Q_PROPERTY(NotificationManager::BehaviorSettings *behaviorSettings READ behaviorSettings NOTIFY behaviorSettingsChanged) | ||||
52 | 53 | | |||
53 | Q_PROPERTY(QKeySequence toggleDoNotDisturbShortcut | 54 | Q_PROPERTY(QKeySequence toggleDoNotDisturbShortcut | ||
54 | READ toggleDoNotDisturbShortcut | 55 | READ toggleDoNotDisturbShortcut | ||
55 | WRITE setToggleDoNotDisturbShortcut | 56 | WRITE setToggleDoNotDisturbShortcut | ||
56 | NOTIFY toggleDoNotDisturbShortcutChanged) | 57 | NOTIFY toggleDoNotDisturbShortcutChanged) | ||
57 | 58 | | |||
58 | // So it can show the respective settings module right away | 59 | // So it can show the respective settings module right away | ||
59 | Q_PROPERTY(QString initialDesktopEntry READ initialDesktopEntry WRITE setInitialDesktopEntry NOTIFY initialDesktopEntryChanged) | 60 | Q_PROPERTY(QString initialDesktopEntry READ initialDesktopEntry WRITE setInitialDesktopEntry NOTIFY initialDesktopEntryChanged) | ||
60 | Q_PROPERTY(QString initialNotifyRcName READ initialNotifyRcName WRITE setInitialNotifyRcName NOTIFY initialNotifyRcNameChanged) | 61 | Q_PROPERTY(QString initialNotifyRcName READ initialNotifyRcName WRITE setInitialNotifyRcName NOTIFY initialNotifyRcNameChanged) | ||
61 | Q_PROPERTY(QString initialEventId READ initialEventId WRITE setInitialEventId NOTIFY initialEventIdChanged) | 62 | Q_PROPERTY(QString initialEventId READ initialEventId WRITE setInitialEventId NOTIFY initialEventIdChanged) | ||
62 | 63 | | |||
63 | public: | 64 | public: | ||
64 | KCMNotifications(QObject *parent, const QVariantList &args); | 65 | KCMNotifications(QObject *parent, const QVariantList &args); | ||
65 | ~KCMNotifications() override; | 66 | ~KCMNotifications() override; | ||
66 | 67 | | |||
67 | SourcesModel *sourcesModel() const; | 68 | SourcesModel *sourcesModel() const; | ||
68 | FilterProxyModel *filteredModel() const; | 69 | FilterProxyModel *filteredModel() const; | ||
69 | 70 | | |||
70 | NotificationManager::Settings *settings() const; | | |||
71 | NotificationManager::DoNotDisturbSettings *dndSettings() const; | 71 | NotificationManager::DoNotDisturbSettings *dndSettings() const; | ||
72 | NotificationManager::NotificationSettings *notificationSettings() const; | 72 | NotificationManager::NotificationSettings *notificationSettings() const; | ||
73 | NotificationManager::JobSettings *jobSettings() const; | 73 | NotificationManager::JobSettings *jobSettings() const; | ||
74 | NotificationManager::BadgeSettings *badgeSettings() const; | 74 | NotificationManager::BadgeSettings *badgeSettings() const; | ||
75 | NotificationManager::BehaviorSettings *behaviorSettings() const; | ||||
76 | Q_SIGNAL void behaviorSettingsChanged(); | ||||
75 | 77 | | |||
76 | QKeySequence toggleDoNotDisturbShortcut() const; | 78 | QKeySequence toggleDoNotDisturbShortcut() const; | ||
77 | void setToggleDoNotDisturbShortcut(const QKeySequence &shortcut); | 79 | void setToggleDoNotDisturbShortcut(const QKeySequence &shortcut); | ||
78 | Q_SIGNAL void toggleDoNotDisturbShortcutChanged(); | 80 | Q_SIGNAL void toggleDoNotDisturbShortcutChanged(); | ||
79 | 81 | | |||
80 | QString initialDesktopEntry() const; | 82 | QString initialDesktopEntry() const; | ||
81 | void setInitialDesktopEntry(const QString &desktopEntry); | 83 | void setInitialDesktopEntry(const QString &desktopEntry); | ||
82 | 84 | | |||
83 | QString initialNotifyRcName() const; | 85 | QString initialNotifyRcName() const; | ||
84 | void setInitialNotifyRcName(const QString ¬ifyRcName); | 86 | void setInitialNotifyRcName(const QString ¬ifyRcName); | ||
85 | 87 | | |||
86 | QString initialEventId() const; | 88 | QString initialEventId() const; | ||
87 | void setInitialEventId(const QString &eventId); | 89 | void setInitialEventId(const QString &eventId); | ||
88 | 90 | | |||
89 | Q_INVOKABLE void configureEvents(const QString ¬ifyRcName, const QString &eventId, QQuickItem *ctx = nullptr); | 91 | Q_INVOKABLE void configureEvents(const QString ¬ifyRcName, const QString &eventId, QQuickItem *ctx = nullptr); | ||
90 | 92 | | |||
93 | Q_INVOKABLE void setBehaviorSettingsToLoad(QString identifier); | ||||
ervin: Should be a const ref | |||||
94 | | ||||
91 | public Q_SLOTS: | 95 | public Q_SLOTS: | ||
92 | void load() override; | 96 | void load() override; | ||
93 | void save() override; | 97 | void save() override; | ||
94 | void defaults() override; | 98 | void defaults() override; | ||
95 | 99 | | |||
96 | signals: | 100 | signals: | ||
97 | void initialDesktopEntryChanged(); | 101 | void initialDesktopEntryChanged(); | ||
98 | void initialNotifyRcNameChanged(); | 102 | void initialNotifyRcNameChanged(); | ||
99 | void initialEventIdChanged(); | 103 | void initialEventIdChanged(); | ||
100 | 104 | | |||
101 | private: | 105 | private: | ||
102 | void processPendingDeletions(); | 106 | void processPendingDeletions(); | ||
107 | bool isSaveNeeded() const override; | ||||
108 | void createConnections(NotificationManager::BehaviorSettings* settings); | ||||
ervin: Space before * not after | |||||
103 | 109 | | |||
104 | SourcesModel *m_sourcesModel; | 110 | SourcesModel *m_sourcesModel; | ||
105 | FilterProxyModel *m_filteredModel; | 111 | FilterProxyModel *m_filteredModel; | ||
106 | 112 | | |||
107 | NotificationManager::Settings *m_settings; | | |||
108 | NotificationManager::DoNotDisturbSettings *m_dndSettings; | 113 | NotificationManager::DoNotDisturbSettings *m_dndSettings; | ||
109 | NotificationManager::NotificationSettings *m_notificationSettings; | 114 | NotificationManager::NotificationSettings *m_notificationSettings; | ||
110 | NotificationManager::JobSettings *m_jobSettings; | 115 | NotificationManager::JobSettings *m_jobSettings; | ||
111 | NotificationManager::BadgeSettings *m_badgeSettings; | 116 | NotificationManager::BadgeSettings *m_badgeSettings; | ||
117 | QHash<QString, NotificationManager::BehaviorSettings *> m_behaviorSettingsList; | ||||
118 | NotificationManager::BehaviorSettings *m_currentBehavior = nullptr; | ||||
112 | 119 | | |||
113 | QAction *m_toggleDoNotDisturbAction; | 120 | QAction *m_toggleDoNotDisturbAction; | ||
114 | QKeySequence m_toggleDoNotDisturbShortcut; | 121 | QKeySequence m_toggleDoNotDisturbShortcut; | ||
115 | bool m_toggleDoNotDisturbShortcutDirty = false; | 122 | bool m_toggleDoNotDisturbShortcutDirty = false; | ||
123 | bool m_firstLoad = true; | ||||
116 | 124 | | |||
117 | QString m_initialDesktopEntry; | 125 | QString m_initialDesktopEntry; | ||
118 | QString m_initialNotifyRcName; | 126 | QString m_initialNotifyRcName; | ||
119 | QString m_initialEventId; | 127 | QString m_initialEventId; | ||
120 | | ||||
121 | }; | 128 | }; |
Should be a const ref