Changeset View
Changeset View
Standalone View
Standalone View
plugins/sendnotifications/notificationslistener.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 84 | { | |||
---|---|---|---|---|---|
92 | KConfig config(filePath, KConfig::OpenFlag::SimpleConfig); | 92 | KConfig config(filePath, KConfig::OpenFlag::SimpleConfig); | ||
93 | KConfigGroup globalgroup(&config, QStringLiteral("Global")); | 93 | KConfigGroup globalgroup(&config, QStringLiteral("Global")); | ||
94 | mTranslatedAppName = globalgroup.readEntry(QStringLiteral("Name"), QStringLiteral("KDE Connect")); | 94 | mTranslatedAppName = globalgroup.readEntry(QStringLiteral("Name"), QStringLiteral("KDE Connect")); | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | void NotificationsListener::loadApplications() | 97 | void NotificationsListener::loadApplications() | ||
98 | { | 98 | { | ||
99 | applications.clear(); | 99 | applications.clear(); | ||
100 | QVariantList list = mPlugin->config()->getList(QStringLiteral("applications")); | 100 | const QVariantList list = mPlugin->config()->getList(QStringLiteral("applications")); | ||
101 | Q_FOREACH (const auto& a, list) { | 101 | for (const auto& a : list) { | ||
102 | NotifyingApplication app = a.value<NotifyingApplication>(); | 102 | NotifyingApplication app = a.value<NotifyingApplication>(); | ||
103 | if (!applications.contains(app.name)) | 103 | if (!applications.contains(app.name)) | ||
104 | applications.insert(app.name, app); | 104 | applications.insert(app.name, app); | ||
105 | } | 105 | } | ||
106 | //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Loaded" << applications.size() << " applications"; | 106 | //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Loaded" << applications.size() << " applications"; | ||
107 | } | 107 | } | ||
108 | 108 | | |||
109 | bool NotificationsListener::parseImageDataArgument(const QVariant& argument, | 109 | bool NotificationsListener::parseImageDataArgument(const QVariant& argument, | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 198 | if (!applications.contains(appName)) { | |||
199 | // new application -> add to config | 199 | // new application -> add to config | ||
200 | app.name = appName; | 200 | app.name = appName; | ||
201 | app.icon = appIcon; | 201 | app.icon = appIcon; | ||
202 | app.active = true; | 202 | app.active = true; | ||
203 | app.blacklistExpression = QRegularExpression(); | 203 | app.blacklistExpression = QRegularExpression(); | ||
204 | applications.insert(app.name, app); | 204 | applications.insert(app.name, app); | ||
205 | // update config: | 205 | // update config: | ||
206 | QVariantList list; | 206 | QVariantList list; | ||
207 | Q_FOREACH (const auto& a, applications) | 207 | for (const auto& a : qAsConst(applications)) | ||
208 | list << QVariant::fromValue<NotifyingApplication>(a); | 208 | list << QVariant::fromValue<NotifyingApplication>(a); | ||
209 | mPlugin->config()->setList(QStringLiteral("applications"), list); | 209 | mPlugin->config()->setList(QStringLiteral("applications"), list); | ||
210 | //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Added new application to config:" << app; | 210 | //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Added new application to config:" << app; | ||
211 | } else | 211 | } else | ||
212 | app = applications.value(appName); | 212 | app = applications.value(appName); | ||
213 | 213 | | |||
214 | if (!app.active) | 214 | if (!app.active) | ||
215 | return 0; | 215 | return 0; | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |