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 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 127 | { | |||
116 | return m_filteredModel; | 128 | return m_filteredModel; | ||
117 | } | 129 | } | ||
118 | 130 | | |||
119 | NotificationManager::Settings *KCMNotifications::settings() const | 131 | NotificationManager::Settings *KCMNotifications::settings() const | ||
120 | { | 132 | { | ||
121 | return m_settings; | 133 | return m_settings; | ||
122 | } | 134 | } | ||
123 | 135 | | |||
136 | NotificationManager::DoNotDisturbSettings *KCMNotifications::dndSettings() const | ||||
137 | { | ||||
138 | return m_dndSettings; | ||||
139 | } | ||||
140 | | ||||
141 | NotificationManager::NotificationSettings *KCMNotifications::notificationSettings() const | ||||
142 | { | ||||
143 | return m_notificationSettings; | ||||
144 | } | ||||
145 | | ||||
146 | NotificationManager::JobSettings *KCMNotifications::jobSettings() const | ||||
147 | { | ||||
148 | return m_jobSettings; | ||||
149 | } | ||||
150 | | ||||
151 | NotificationManager::BadgeSettings *KCMNotifications::badgeSettings() const | ||||
152 | { | ||||
153 | return m_badgeSettings; | ||||
154 | } | ||||
155 | | ||||
124 | QKeySequence KCMNotifications::toggleDoNotDisturbShortcut() const | 156 | QKeySequence KCMNotifications::toggleDoNotDisturbShortcut() const | ||
125 | { | 157 | { | ||
126 | return m_toggleDoNotDisturbShortcut; | 158 | return m_toggleDoNotDisturbShortcut; | ||
127 | } | 159 | } | ||
128 | 160 | | |||
129 | void KCMNotifications::setToggleDoNotDisturbShortcut(const QKeySequence &shortcut) | 161 | void KCMNotifications::setToggleDoNotDisturbShortcut(const QKeySequence &shortcut) | ||
130 | { | 162 | { | ||
131 | if (m_toggleDoNotDisturbShortcut == shortcut) { | 163 | if (m_toggleDoNotDisturbShortcut == shortcut) { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 213 | { | |||
216 | w->setApplication(notifyRcName); | 248 | w->setApplication(notifyRcName); | ||
217 | w->selectEvent(eventId); | 249 | w->selectEvent(eventId); | ||
218 | 250 | | |||
219 | dialog->show(); | 251 | dialog->show(); | ||
220 | } | 252 | } | ||
221 | 253 | | |||
222 | void KCMNotifications::load() | 254 | void KCMNotifications::load() | ||
223 | { | 255 | { | ||
256 | ManagedConfigModule::load(); | ||||
224 | m_settings->load(); | 257 | m_settings->load(); | ||
225 | 258 | | |||
226 | const QKeySequence toggleDoNotDisturbShortcut = KGlobalAccel::self()->globalShortcut( | 259 | const QKeySequence toggleDoNotDisturbShortcut = KGlobalAccel::self()->globalShortcut( | ||
227 | m_toggleDoNotDisturbAction->property("componentName").toString(), | 260 | m_toggleDoNotDisturbAction->property("componentName").toString(), | ||
228 | m_toggleDoNotDisturbAction->objectName()).value(0); | 261 | m_toggleDoNotDisturbAction->objectName()).value(0); | ||
229 | 262 | | |||
230 | if (m_toggleDoNotDisturbShortcut != toggleDoNotDisturbShortcut) { | 263 | if (m_toggleDoNotDisturbShortcut != toggleDoNotDisturbShortcut) { | ||
231 | m_toggleDoNotDisturbShortcut = toggleDoNotDisturbShortcut; | 264 | m_toggleDoNotDisturbShortcut = toggleDoNotDisturbShortcut; | ||
232 | emit toggleDoNotDisturbShortcutChanged(); | 265 | emit toggleDoNotDisturbShortcutChanged(); | ||
233 | } | 266 | } | ||
234 | 267 | | |||
235 | m_toggleDoNotDisturbShortcutDirty = false; | 268 | m_toggleDoNotDisturbShortcutDirty = false; | ||
236 | setNeedsSave(false); | 269 | setNeedsSave(false); | ||
237 | } | 270 | } | ||
238 | 271 | | |||
239 | void KCMNotifications::save() | 272 | void KCMNotifications::save() | ||
240 | { | 273 | { | ||
274 | ManagedConfigModule::save(); | ||||
241 | m_settings->save(); | 275 | m_settings->save(); | ||
242 | 276 | | |||
243 | if (m_toggleDoNotDisturbShortcutDirty) { | 277 | if (m_toggleDoNotDisturbShortcutDirty) { | ||
244 | // KeySequenceItem will already have checked whether the shortcut is available | 278 | // KeySequenceItem will already have checked whether the shortcut is available | ||
245 | KGlobalAccel::self()->setShortcut(m_toggleDoNotDisturbAction, | 279 | KGlobalAccel::self()->setShortcut(m_toggleDoNotDisturbAction, | ||
246 | {m_toggleDoNotDisturbShortcut}, | 280 | {m_toggleDoNotDisturbShortcut}, | ||
247 | KGlobalAccel::NoAutoloading); | 281 | KGlobalAccel::NoAutoloading); | ||
248 | } | 282 | } | ||
249 | 283 | | |||
250 | setNeedsSave(false); | 284 | setNeedsSave(false); | ||
251 | } | 285 | } | ||
252 | 286 | | |||
253 | void KCMNotifications::defaults() | 287 | void KCMNotifications::defaults() | ||
254 | { | 288 | { | ||
289 | ManagedConfigModule::defaults(); | ||||
255 | m_settings->defaults(); | 290 | m_settings->defaults(); | ||
256 | 291 | | |||
257 | setToggleDoNotDisturbShortcut(QKeySequence()); | 292 | setToggleDoNotDisturbShortcut(QKeySequence()); | ||
258 | } | 293 | } | ||
259 | 294 | | |||
260 | #include "kcm.moc" | 295 | #include "kcm.moc" |