Changeset View
Changeset View
Standalone View
Standalone View
src/plasma/private/applet_p.cpp
Show First 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 186 | if (!q->isContainment()) { | |||
---|---|---|---|---|---|
196 | QObject::connect(q, &Applet::contextualActionsAboutToShow, a, [=]() { | 196 | QObject::connect(q, &Applet::contextualActionsAboutToShow, a, [=]() { | ||
197 | bool hasAlternatives = false; | 197 | bool hasAlternatives = false; | ||
198 | 198 | | |||
199 | const QStringList provides = KPluginMetaData::readStringList(q->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); | 199 | const QStringList provides = KPluginMetaData::readStringList(q->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); | ||
200 | if (!provides.isEmpty() && q->immutability() == Types::Mutable) { | 200 | if (!provides.isEmpty() && q->immutability() == Types::Mutable) { | ||
201 | auto filter = [&provides](const KPluginMetaData &md) -> bool | 201 | auto filter = [&provides](const KPluginMetaData &md) -> bool | ||
202 | { | 202 | { | ||
203 | const QStringList provided = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-Provides")); | 203 | const QStringList provided = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-Provides")); | ||
204 | foreach (const QString &p, provides) { | 204 | for (const QString &p : provides) { | ||
205 | if (provided.contains(p)) { | 205 | if (provided.contains(p)) { | ||
206 | return true; | 206 | return true; | ||
207 | } | 207 | } | ||
208 | } | 208 | } | ||
209 | return false; | 209 | return false; | ||
210 | }; | 210 | }; | ||
211 | QList<KPluginMetaData> applets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); | 211 | QList<KPluginMetaData> applets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); | ||
212 | 212 | | |||
Show All 28 Lines | |||||
241 | { | 241 | { | ||
242 | transient = destroyed; | 242 | transient = destroyed; | ||
243 | emit q->destroyedChanged(destroyed); | 243 | emit q->destroyedChanged(destroyed); | ||
244 | //when an applet gets transient, it's "systemimmutable" | 244 | //when an applet gets transient, it's "systemimmutable" | ||
245 | emit q->immutabilityChanged(q->immutability()); | 245 | emit q->immutabilityChanged(q->immutability()); | ||
246 | 246 | | |||
247 | Plasma::Containment *asContainment = qobject_cast<Plasma::Containment *>(q); | 247 | Plasma::Containment *asContainment = qobject_cast<Plasma::Containment *>(q); | ||
248 | if (asContainment) { | 248 | if (asContainment) { | ||
249 | foreach(Applet *a , asContainment->applets()) | 249 | const auto lstApplets = asContainment->applets(); | ||
250 | for (Applet *a : lstApplets) | ||||
250 | a->d->setDestroyed(destroyed); | 251 | a->d->setDestroyed(destroyed); | ||
251 | } | 252 | } | ||
252 | } | 253 | } | ||
253 | 254 | | |||
254 | void AppletPrivate::askDestroy() | 255 | void AppletPrivate::askDestroy() | ||
255 | { | 256 | { | ||
256 | if (q->immutability() != Types::Mutable || !started) { | 257 | if (q->immutability() != Types::Mutable || !started) { | ||
257 | return; //don't double delete | 258 | return; //don't double delete | ||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | 404 | { | |||
406 | } | 407 | } | ||
407 | } | 408 | } | ||
408 | 409 | | |||
409 | void AppletPrivate::updateShortcuts() | 410 | void AppletPrivate::updateShortcuts() | ||
410 | { | 411 | { | ||
411 | if (q->isContainment()) { | 412 | if (q->isContainment()) { | ||
412 | //a horrible hack to avoid clobbering corona settings | 413 | //a horrible hack to avoid clobbering corona settings | ||
413 | //we pull them out, then read, then put them back | 414 | //we pull them out, then read, then put them back | ||
414 | QList<QString> names; | | |||
415 | QList<QAction *> qactions; | 415 | QList<QAction *> qactions; | ||
416 | names << QStringLiteral("add sibling containment") << QStringLiteral("configure shortcuts") << QStringLiteral("lock widgets"); | 416 | const QList<QString> names = QList<QString>() << QStringLiteral("add sibling containment") << QStringLiteral("configure shortcuts") << QStringLiteral("lock widgets"); | ||
417 | foreach (const QString &name, names) { | 417 | for (const QString &name : names) { | ||
ahmadsamir: Nit-pick: initializer list instead of <<. | |||||
418 | QAction *a = actions->action(name); | 418 | QAction *a = actions->action(name); | ||
419 | actions->takeAction(a); //FIXME this is stupid, KActionCollection needs a takeAction(QString) method | 419 | actions->takeAction(a); //FIXME this is stupid, KActionCollection needs a takeAction(QString) method | ||
420 | qactions << a; | 420 | qactions << a; | ||
421 | } | 421 | } | ||
422 | 422 | | |||
423 | actions->readSettings(); | 423 | actions->readSettings(); | ||
424 | 424 | | |||
425 | for (int i = 0; i < names.size(); ++i) { | 425 | for (int i = 0; i < names.size(); ++i) { | ||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |
Nit-pick: initializer list instead of <<.