Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/systemtray.cpp
Show All 36 Lines | |||||
37 | #include <Plasma/ServiceJob> | 37 | #include <Plasma/ServiceJob> | ||
38 | 38 | | |||
39 | #include <KActionCollection> | 39 | #include <KActionCollection> | ||
40 | #include <KAcceleratorManager> | 40 | #include <KAcceleratorManager> | ||
41 | #include <KLocalizedString> | 41 | #include <KLocalizedString> | ||
42 | 42 | | |||
43 | #include <plasma_version.h> | 43 | #include <plasma_version.h> | ||
44 | 44 | | |||
45 | class PlasmoidModel: public QStandardItemModel | 45 | #include "entrymodel.h" | ||
46 | { | | |||
47 | public: | | |||
48 | explicit PlasmoidModel(QObject *parent = nullptr) | | |||
49 | : QStandardItemModel(parent) | | |||
50 | { | | |||
51 | } | | |||
52 | | ||||
53 | QHash<int, QByteArray> roleNames() const override { | | |||
54 | QHash<int, QByteArray> roles = QStandardItemModel::roleNames(); | | |||
55 | roles[Qt::UserRole+1] = "plugin"; | | |||
56 | return roles; | | |||
57 | } | | |||
58 | }; | | |||
59 | 46 | | |||
60 | SystemTray::SystemTray(QObject *parent, const QVariantList &args) | 47 | SystemTray::SystemTray(QObject *parent, const QVariantList &args) | ||
61 | : Plasma::Containment(parent, args), | 48 | : Plasma::Containment(parent, args), | ||
62 | m_availablePlasmoidsModel(nullptr) | 49 | m_entryModel(nullptr) | ||
63 | { | 50 | { | ||
64 | setHasConfigurationInterface(true); | 51 | setHasConfigurationInterface(true); | ||
65 | setContainmentType(Plasma::Types::CustomEmbeddedContainment); | 52 | setContainmentType(Plasma::Types::CustomEmbeddedContainment); | ||
66 | } | 53 | } | ||
67 | 54 | | |||
68 | SystemTray::~SystemTray() | 55 | SystemTray::~SystemTray() | ||
69 | { | 56 | { | ||
70 | } | 57 | } | ||
▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Line(s) | 346 | { | |||
437 | initDBusActivatables(); | 424 | initDBusActivatables(); | ||
438 | } | 425 | } | ||
439 | 426 | | |||
440 | QStringList SystemTray::defaultPlasmoids() const | 427 | QStringList SystemTray::defaultPlasmoids() const | ||
441 | { | 428 | { | ||
442 | return m_defaultPlasmoids; | 429 | return m_defaultPlasmoids; | ||
443 | } | 430 | } | ||
444 | 431 | | |||
445 | QAbstractItemModel* SystemTray::availablePlasmoids() | 432 | QAbstractListModel * SystemTray::entryModel() | ||
446 | { | 433 | { | ||
447 | if (!m_availablePlasmoidsModel) { | 434 | if (!m_entryModel) { | ||
448 | m_availablePlasmoidsModel = new PlasmoidModel(this); | 435 | m_entryModel = new EntryModel(this); | ||
449 | | ||||
450 | for (const KPluginInfo &info : qAsConst(m_systrayApplets)) { | | |||
451 | QString name = info.name(); | | |||
452 | const QString dbusactivation = info.property(QStringLiteral("X-Plasma-DBusActivationService")).toString(); | | |||
453 | | ||||
454 | if (!dbusactivation.isEmpty()) { | | |||
455 | name += i18n(" (Automatic load)"); | | |||
456 | } | 436 | } | ||
457 | QStandardItem *item = new QStandardItem(QIcon::fromTheme(info.icon()), name); | 437 | return m_entryModel; | ||
458 | item->setData(info.pluginName()); | | |||
459 | m_availablePlasmoidsModel->appendRow(item); | | |||
460 | } | | |||
461 | m_availablePlasmoidsModel->sort(0 /*column*/); | | |||
462 | } | | |||
463 | return m_availablePlasmoidsModel; | | |||
464 | } | 438 | } | ||
465 | 439 | | |||
440 | | ||||
466 | QStringList SystemTray::allowedPlasmoids() const | 441 | QStringList SystemTray::allowedPlasmoids() const | ||
467 | { | 442 | { | ||
468 | return m_allowedPlasmoids; | 443 | return m_allowedPlasmoids; | ||
469 | } | 444 | } | ||
470 | 445 | | |||
471 | void SystemTray::setAllowedPlasmoids(const QStringList &allowed) | 446 | void SystemTray::setAllowedPlasmoids(const QStringList &allowed) | ||
472 | { | 447 | { | ||
473 | if (allowed == m_allowedPlasmoids) { | 448 | if (allowed == m_allowedPlasmoids) { | ||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |