Changeset View
Changeset View
Standalone View
Standalone View
kcms/notifications/kcm.cpp
Show All 39 Lines | |||||
40 | #include <KPluginFactory> | 40 | #include <KPluginFactory> | ||
41 | 41 | | |||
42 | #include <algorithm> | 42 | #include <algorithm> | ||
43 | 43 | | |||
44 | #include "sourcesmodel.h" | 44 | #include "sourcesmodel.h" | ||
45 | #include "filterproxymodel.h" | 45 | #include "filterproxymodel.h" | ||
46 | 46 | | |||
47 | #include <notificationmanager/settings.h> | 47 | #include <notificationmanager/settings.h> | ||
48 | #include <notificationmanager/donotdisturbsettings.h> | ||||
49 | #include <notificationmanager/notificationsettings.h> | ||||
50 | #include <notificationmanager/jobsettings.h> | ||||
51 | #include <notificationmanager/badgesettings.h> | ||||
48 | 52 | | |||
49 | K_PLUGIN_FACTORY_WITH_JSON(KCMNotificationsFactory, "kcm_notifications.json", registerPlugin<KCMNotifications>();) | 53 | K_PLUGIN_FACTORY_WITH_JSON(KCMNotificationsFactory, "kcm_notifications.json", registerPlugin<KCMNotifications>();) | ||
50 | 54 | | |||
51 | KCMNotifications::KCMNotifications(QObject *parent, const QVariantList &args) | 55 | KCMNotifications::KCMNotifications(QObject *parent, const QVariantList &args) | ||
52 | : KQuickAddons::ConfigModule(parent, args) | 56 | : KQuickAddons::ManagedConfigModule(parent, args) | ||
53 | , m_sourcesModel(new SourcesModel(this)) | 57 | , m_sourcesModel(new SourcesModel(this)) | ||
54 | , m_filteredModel(new FilterProxyModel(this)) | 58 | , m_filteredModel(new FilterProxyModel(this)) | ||
55 | , m_settings(new NotificationManager::Settings(this)) | 59 | , m_settings(new NotificationManager::Settings(this)) | ||
60 | , m_dndSettings(new NotificationManager::DoNotDisturbSettings(this)) | ||||
61 | , m_notificationSettings(new NotificationManager::NotificationSettings(this)) | ||||
62 | , m_jobSettings(new NotificationManager::JobSettings(this)) | ||||
63 | , m_badgeSettings(new NotificationManager::BadgeSettings(this)) | ||||
56 | , m_toggleDoNotDisturbAction(new QAction(this)) | 64 | , m_toggleDoNotDisturbAction(new QAction(this)) | ||
57 | { | 65 | { | ||
58 | 66 | | |||
59 | const char uri[] = "org.kde.private.kcms.notifications"; | 67 | const char uri[] = "org.kde.private.kcms.notifications"; | ||
60 | qmlRegisterUncreatableType<SourcesModel>(uri, 1, 0, "SourcesModel", | 68 | qmlRegisterUncreatableType<SourcesModel>(uri, 1, 0, "SourcesModel", | ||
61 | QStringLiteral("Cannot create instances of SourcesModel")); | 69 | QStringLiteral("Cannot create instances of SourcesModel")); | ||
62 | qmlRegisterType<FilterProxyModel>(); | 70 | qmlRegisterType<FilterProxyModel>(); | ||
63 | qmlRegisterType<QKeySequence>(); | 71 | qmlRegisterType<QKeySequence>(); | ||
72 | qmlRegisterType<NotificationManager::DoNotDisturbSettings>(); | ||||
73 | qmlRegisterType<NotificationManager::NotificationSettings>(); | ||||
74 | qmlRegisterType<NotificationManager::JobSettings>(); | ||||
75 | qmlRegisterType<NotificationManager::BadgeSettings>(); | ||||
64 | qmlProtectModule(uri, 1); | 76 | qmlProtectModule(uri, 1); | ||
65 | 77 | | |||
66 | KAboutData *about = new KAboutData(QStringLiteral("kcm_notifications"), i18n("Notifications"), | 78 | KAboutData *about = new KAboutData(QStringLiteral("kcm_notifications"), i18n("Notifications"), | ||
67 | QStringLiteral("5.0"), QString(), KAboutLicense::GPL); | 79 | QStringLiteral("5.0"), QString(), KAboutLicense::GPL); | ||
68 | about->addAuthor(i18n("Kai Uwe Broulik"), QString(), QStringLiteral("kde@privat.broulik.de")); | 80 | about->addAuthor(i18n("Kai Uwe Broulik"), QString(), QStringLiteral("kde@privat.broulik.de")); | ||
69 | setAboutData(about); | 81 | setAboutData(about); | ||
70 | 82 | | |||
71 | m_filteredModel->setSourceModel(m_sourcesModel); | 83 | m_filteredModel->setSourceModel(m_sourcesModel); | ||
Show All 22 Lines | |||||
94 | QCommandLineOption eventIdOption(QStringLiteral("event-id"), QString(), QStringLiteral("event-id")); | 106 | QCommandLineOption eventIdOption(QStringLiteral("event-id"), QString(), QStringLiteral("event-id")); | ||
95 | parser.addOption(eventIdOption); | 107 | parser.addOption(eventIdOption); | ||
96 | 108 | | |||
97 | parser.parse(stringArgs); | 109 | parser.parse(stringArgs); | ||
98 | 110 | | |||
99 | setInitialDesktopEntry(parser.value(desktopEntryOption)); | 111 | setInitialDesktopEntry(parser.value(desktopEntryOption)); | ||
100 | setInitialNotifyRcName(parser.value(notifyRcNameOption)); | 112 | setInitialNotifyRcName(parser.value(notifyRcNameOption)); | ||
101 | setInitialEventId(parser.value(eventIdOption)); | 113 | setInitialEventId(parser.value(eventIdOption)); | ||
114 | | ||||
115 | registerSettings(m_dndSettings); | ||||
ervin: Not necessary anymore | |||||
116 | registerSettings(m_notificationSettings); | ||||
117 | registerSettings(m_jobSettings); | ||||
118 | registerSettings(m_badgeSettings); | ||||
102 | } | 119 | } | ||
103 | 120 | | |||
104 | KCMNotifications::~KCMNotifications() | 121 | KCMNotifications::~KCMNotifications() | ||
105 | { | 122 | { | ||
106 | 123 | | |||
107 | } | 124 | } | ||
108 | 125 | | |||
109 | SourcesModel *KCMNotifications::sourcesModel() const | 126 | SourcesModel *KCMNotifications::sourcesModel() const | ||
110 | { | 127 | { | ||
111 | return m_sourcesModel; | 128 | return m_sourcesModel; | ||
112 | } | 129 | } | ||
113 | 130 | | |||
114 | FilterProxyModel *KCMNotifications::filteredModel() const | 131 | FilterProxyModel *KCMNotifications::filteredModel() const | ||
115 | { | 132 | { | ||
116 | return m_filteredModel; | 133 | return m_filteredModel; | ||
117 | } | 134 | } | ||
118 | 135 | | |||
119 | NotificationManager::Settings *KCMNotifications::settings() const | 136 | NotificationManager::Settings *KCMNotifications::settings() const | ||
120 | { | 137 | { | ||
121 | return m_settings; | 138 | return m_settings; | ||
122 | } | 139 | } | ||
123 | 140 | | |||
141 | NotificationManager::DoNotDisturbSettings *KCMNotifications::dndSettings() const | ||||
142 | { | ||||
143 | return m_dndSettings; | ||||
144 | } | ||||
145 | | ||||
146 | NotificationManager::NotificationSettings *KCMNotifications::notificationSettings() const | ||||
147 | { | ||||
148 | return m_notificationSettings; | ||||
149 | } | ||||
150 | | ||||
151 | NotificationManager::JobSettings *KCMNotifications::jobSettings() const | ||||
152 | { | ||||
153 | return m_jobSettings; | ||||
154 | } | ||||
155 | | ||||
156 | NotificationManager::BadgeSettings *KCMNotifications::badgeSettings() const | ||||
157 | { | ||||
158 | return m_badgeSettings; | ||||
159 | } | ||||
160 | | ||||
124 | QKeySequence KCMNotifications::toggleDoNotDisturbShortcut() const | 161 | QKeySequence KCMNotifications::toggleDoNotDisturbShortcut() const | ||
125 | { | 162 | { | ||
126 | return m_toggleDoNotDisturbShortcut; | 163 | return m_toggleDoNotDisturbShortcut; | ||
127 | } | 164 | } | ||
128 | 165 | | |||
129 | void KCMNotifications::setToggleDoNotDisturbShortcut(const QKeySequence &shortcut) | 166 | void KCMNotifications::setToggleDoNotDisturbShortcut(const QKeySequence &shortcut) | ||
130 | { | 167 | { | ||
131 | if (m_toggleDoNotDisturbShortcut == shortcut) { | 168 | if (m_toggleDoNotDisturbShortcut == shortcut) { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 218 | { | |||
216 | w->setApplication(notifyRcName); | 253 | w->setApplication(notifyRcName); | ||
217 | w->selectEvent(eventId); | 254 | w->selectEvent(eventId); | ||
218 | 255 | | |||
219 | dialog->show(); | 256 | dialog->show(); | ||
220 | } | 257 | } | ||
221 | 258 | | |||
222 | void KCMNotifications::load() | 259 | void KCMNotifications::load() | ||
223 | { | 260 | { | ||
261 | ManagedConfigModule::load(); | ||||
224 | m_settings->load(); | 262 | m_settings->load(); | ||
225 | 263 | | |||
226 | const QKeySequence toggleDoNotDisturbShortcut = KGlobalAccel::self()->globalShortcut( | 264 | const QKeySequence toggleDoNotDisturbShortcut = KGlobalAccel::self()->globalShortcut( | ||
227 | m_toggleDoNotDisturbAction->property("componentName").toString(), | 265 | m_toggleDoNotDisturbAction->property("componentName").toString(), | ||
228 | m_toggleDoNotDisturbAction->objectName()).value(0); | 266 | m_toggleDoNotDisturbAction->objectName()).value(0); | ||
229 | 267 | | |||
230 | if (m_toggleDoNotDisturbShortcut != toggleDoNotDisturbShortcut) { | 268 | if (m_toggleDoNotDisturbShortcut != toggleDoNotDisturbShortcut) { | ||
231 | m_toggleDoNotDisturbShortcut = toggleDoNotDisturbShortcut; | 269 | m_toggleDoNotDisturbShortcut = toggleDoNotDisturbShortcut; | ||
232 | emit toggleDoNotDisturbShortcutChanged(); | 270 | emit toggleDoNotDisturbShortcutChanged(); | ||
233 | } | 271 | } | ||
234 | 272 | | |||
235 | m_toggleDoNotDisturbShortcutDirty = false; | 273 | m_toggleDoNotDisturbShortcutDirty = false; | ||
236 | setNeedsSave(false); | 274 | setNeedsSave(false); | ||
237 | } | 275 | } | ||
238 | 276 | | |||
239 | void KCMNotifications::save() | 277 | void KCMNotifications::save() | ||
240 | { | 278 | { | ||
279 | ManagedConfigModule::save(); | ||||
241 | m_settings->save(); | 280 | m_settings->save(); | ||
242 | 281 | | |||
243 | if (m_toggleDoNotDisturbShortcutDirty) { | 282 | if (m_toggleDoNotDisturbShortcutDirty) { | ||
244 | // KeySequenceItem will already have checked whether the shortcut is available | 283 | // KeySequenceItem will already have checked whether the shortcut is available | ||
245 | KGlobalAccel::self()->setShortcut(m_toggleDoNotDisturbAction, | 284 | KGlobalAccel::self()->setShortcut(m_toggleDoNotDisturbAction, | ||
246 | {m_toggleDoNotDisturbShortcut}, | 285 | {m_toggleDoNotDisturbShortcut}, | ||
247 | KGlobalAccel::NoAutoloading); | 286 | KGlobalAccel::NoAutoloading); | ||
248 | } | 287 | } | ||
249 | 288 | | |||
250 | setNeedsSave(false); | 289 | setNeedsSave(false); | ||
251 | } | 290 | } | ||
252 | 291 | | |||
253 | void KCMNotifications::defaults() | 292 | void KCMNotifications::defaults() | ||
254 | { | 293 | { | ||
294 | ManagedConfigModule::defaults(); | ||||
255 | m_settings->defaults(); | 295 | m_settings->defaults(); | ||
256 | 296 | | |||
257 | setToggleDoNotDisturbShortcut(QKeySequence()); | 297 | setToggleDoNotDisturbShortcut(QKeySequence()); | ||
258 | } | 298 | } | ||
259 | 299 | | |||
260 | #include "kcm.moc" | 300 | #include "kcm.moc" |
Not necessary anymore