Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/systemtray.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | void SystemTray::init() | 72 | void SystemTray::init() | ||
73 | { | 73 | { | ||
74 | Containment::init(); | 74 | Containment::init(); | ||
75 | 75 | | |||
76 | for (const auto &info: Plasma::PluginLoader::self()->listAppletMetaData(QString())) { | 76 | for (const auto &info: Plasma::PluginLoader::self()->listAppletMetaData(QString())) { | ||
77 | if (!info.isValid() || info.value(QStringLiteral("X-Plasma-NotificationArea")) != "true") { | 77 | if (!info.isValid() || info.value(QStringLiteral("X-Plasma-NotificationArea")) != "true") { | ||
78 | continue; | 78 | continue; | ||
79 | } | 79 | } | ||
80 | m_systrayApplets[info.pluginId()] = KPluginInfo(info); | 80 | m_systrayApplets[info.pluginId()] = info; | ||
81 | 81 | | |||
82 | if (info.isEnabledByDefault()) { | 82 | if (info.isEnabledByDefault()) { | ||
83 | m_defaultPlasmoids += info.pluginId(); | 83 | m_defaultPlasmoids += info.pluginId(); | ||
84 | } | 84 | } | ||
85 | const QString dbusactivation = info.value(QStringLiteral("X-Plasma-DBusActivationService")); | 85 | const QString dbusactivation = info.value(QStringLiteral("X-Plasma-DBusActivationService")); | ||
86 | if (!dbusactivation.isEmpty()) { | 86 | if (!dbusactivation.isEmpty()) { | ||
87 | qCDebug(SYSTEM_TRAY) << "ST Found DBus-able Applet: " << info.pluginId() << dbusactivation; | 87 | qCDebug(SYSTEM_TRAY) << "ST Found DBus-able Applet: " << info.pluginId() << dbusactivation; | ||
88 | QRegExp rx(dbusactivation); | 88 | QRegExp rx(dbusactivation); | ||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Line(s) | 389 | for (const QString &group : groups) { | |||
391 | QString plugin = appletConfig.readEntry("plugin"); | 391 | QString plugin = appletConfig.readEntry("plugin"); | ||
392 | if (!plugin.isEmpty()) { | 392 | if (!plugin.isEmpty()) { | ||
393 | m_knownPlugins[plugin] = group.toInt(); | 393 | m_knownPlugins[plugin] = group.toInt(); | ||
394 | } | 394 | } | ||
395 | } | 395 | } | ||
396 | 396 | | |||
397 | QStringList ownApplets; | 397 | QStringList ownApplets; | ||
398 | 398 | | |||
399 | QMap<QString, KPluginInfo> sortedApplets; | 399 | QMap<QString, KPluginMetaData> sortedApplets; | ||
400 | for (auto it = m_systrayApplets.constBegin(); it != m_systrayApplets.constEnd(); ++it) { | 400 | for (auto it = m_systrayApplets.constBegin(); it != m_systrayApplets.constEnd(); ++it) { | ||
401 | const KPluginInfo &info = it.value(); | 401 | const KPluginMetaData &info = it.value(); | ||
402 | if (m_allowedPlasmoids.contains(info.pluginName()) && ! | 402 | if (m_allowedPlasmoids.contains(info.pluginId()) && ! | ||
403 | m_dbusActivatableTasks.contains(info.pluginName())) { | 403 | m_dbusActivatableTasks.contains(info.pluginId())) { | ||
404 | //FIXME | 404 | //FIXME | ||
405 | // if we already have a plugin with this exact name in it, then check if it is the | 405 | // if we already have a plugin with this exact name in it, then check if it is the | ||
406 | // same plugin and skip it if it is indeed already listed | 406 | // same plugin and skip it if it is indeed already listed | ||
407 | if (sortedApplets.contains(info.name())) { | 407 | if (sortedApplets.contains(info.name())) { | ||
408 | bool dupe = false; | 408 | bool dupe = false; | ||
409 | // it is possible (though poor form) to have multiple applets | 409 | // it is possible (though poor form) to have multiple applets | ||
410 | // with the same visible name but different plugins, so we hve to check all values | 410 | // with the same visible name but different plugins, so we hve to check all values | ||
411 | const auto infos = sortedApplets.values(info.name()); | 411 | const auto infos = sortedApplets.values(info.name()); | ||
412 | for (const KPluginInfo &existingInfo : infos) { | 412 | for (const KPluginMetaData &existingInfo : infos) { | ||
413 | if (existingInfo.pluginName() == info.pluginName()) { | 413 | if (existingInfo.pluginId() == info.pluginId()) { | ||
414 | dupe = true; | 414 | dupe = true; | ||
415 | break; | 415 | break; | ||
416 | } | 416 | } | ||
417 | } | 417 | } | ||
418 | 418 | | |||
419 | if (dupe) { | 419 | if (dupe) { | ||
420 | continue; | 420 | continue; | ||
421 | } | 421 | } | ||
422 | } | 422 | } | ||
423 | 423 | | |||
424 | // insertMulti because it is possible (though poor form) to have multiple applets | 424 | // insertMulti because it is possible (though poor form) to have multiple applets | ||
425 | // with the same visible name but different plugins | 425 | // with the same visible name but different plugins | ||
426 | sortedApplets.insertMulti(info.name(), info); | 426 | sortedApplets.insertMulti(info.name(), info); | ||
427 | } | 427 | } | ||
428 | } | 428 | } | ||
429 | 429 | | |||
430 | for (const KPluginInfo &info : qAsConst(sortedApplets)) { | 430 | for (const KPluginMetaData &info : qAsConst(sortedApplets)) { | ||
431 | qCDebug(SYSTEM_TRAY) << " Adding applet: " << info.name(); | 431 | qCDebug(SYSTEM_TRAY) << " Adding applet: " << info.name(); | ||
432 | if (m_allowedPlasmoids.contains(info.pluginName())) { | 432 | if (m_allowedPlasmoids.contains(info.pluginId())) { | ||
433 | newTask(info.pluginName()); | 433 | newTask(info.pluginId()); | ||
434 | } | 434 | } | ||
435 | } | 435 | } | ||
436 | 436 | | |||
437 | initDBusActivatables(); | 437 | initDBusActivatables(); | ||
438 | } | 438 | } | ||
439 | 439 | | |||
440 | QStringList SystemTray::defaultPlasmoids() const | 440 | QStringList SystemTray::defaultPlasmoids() const | ||
441 | { | 441 | { | ||
442 | return m_defaultPlasmoids; | 442 | return m_defaultPlasmoids; | ||
443 | } | 443 | } | ||
444 | 444 | | |||
445 | QAbstractItemModel* SystemTray::availablePlasmoids() | 445 | QAbstractItemModel* SystemTray::availablePlasmoids() | ||
446 | { | 446 | { | ||
447 | if (!m_availablePlasmoidsModel) { | 447 | if (!m_availablePlasmoidsModel) { | ||
448 | m_availablePlasmoidsModel = new PlasmoidModel(this); | 448 | m_availablePlasmoidsModel = new PlasmoidModel(this); | ||
449 | 449 | | |||
450 | for (const KPluginInfo &info : qAsConst(m_systrayApplets)) { | 450 | for (const KPluginMetaData &info : qAsConst(m_systrayApplets)) { | ||
451 | QString name = info.name(); | 451 | QString name = info.name(); | ||
452 | const QString dbusactivation = info.property(QStringLiteral("X-Plasma-DBusActivationService")).toString(); | 452 | const QString dbusactivation = info.rawData().value(QStringLiteral("X-Plasma-DBusActivationService")).toString(); | ||
453 | 453 | | |||
454 | if (!dbusactivation.isEmpty()) { | 454 | if (!dbusactivation.isEmpty()) { | ||
455 | name += i18n(" (Automatic load)"); | 455 | name += i18n(" (Automatic load)"); | ||
456 | } | 456 | } | ||
457 | QStandardItem *item = new QStandardItem(QIcon::fromTheme(info.icon()), name); | 457 | QStandardItem *item = new QStandardItem(QIcon::fromTheme(info.iconName()), name); | ||
458 | item->setData(info.pluginName()); | 458 | item->setData(info.pluginId()); | ||
459 | m_availablePlasmoidsModel->appendRow(item); | 459 | m_availablePlasmoidsModel->appendRow(item); | ||
460 | } | 460 | } | ||
461 | m_availablePlasmoidsModel->sort(0 /*column*/); | 461 | m_availablePlasmoidsModel->sort(0 /*column*/); | ||
462 | } | 462 | } | ||
463 | return m_availablePlasmoidsModel; | 463 | return m_availablePlasmoidsModel; | ||
464 | } | 464 | } | ||
465 | 465 | | |||
466 | QStringList SystemTray::allowedPlasmoids() const | 466 | QStringList SystemTray::allowedPlasmoids() const | ||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |