1 /* 2 SPDX-FileCopyrightText: 2009 Marco Martin <notmart@gmail.com> 3 SPDX-FileCopyrightText: 2009 Matthieu Gallien <matthieu_gallien@yahoo.fr> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #pragma once 9 10 #include <Plasma/DataContainer> 11 #include <QDBusPendingCallWatcher> 12 #include <QMenu> 13 #include <QString> 14 15 #include "statusnotifieritem_interface.h" 16 17 class KIconLoader; 18 19 class DBusMenuImporter; 20 21 class StatusNotifierItemSource : public Plasma::DataContainer 22 { 23 Q_OBJECT 24 25 public: 26 StatusNotifierItemSource(const QString &service, QObject *parent); 27 ~StatusNotifierItemSource() override; 28 Plasma::Service *createService(); 29 30 void activate(int x, int y); 31 void secondaryActivate(int x, int y); 32 void scroll(int delta, const QString &direction); 33 void contextMenu(int x, int y); 34 void provideXdgActivationToken(const QString &token); 35 36 Q_SIGNALS: 37 void contextMenuReady(QMenu *menu); 38 void activateResult(bool success); 39 40 private Q_SLOTS: 41 void contextMenuReady(); 42 void refreshTitle(); 43 void refreshIcons(); 44 void refreshToolTip(); 45 void refreshMenu(); 46 void refresh(); 47 void performRefresh(); 48 void syncStatus(QString); 49 void refreshCallback(QDBusPendingCallWatcher *); 50 void activateCallback(QDBusPendingCallWatcher *); 51 52 private: 53 QPixmap KDbusImageStructToPixmap(const KDbusImageStruct &image) const; 54 QIcon imageVectorToPixmap(const KDbusImageVector &vector) const; 55 void overlayIcon(QIcon *icon, QIcon *overlay); 56 KIconLoader *iconLoader() const; 57 58 bool m_valid; 59 QString m_typeId; 60 QString m_name; 61 QTimer m_refreshTimer; 62 KIconLoader *m_customIconLoader; 63 DBusMenuImporter *m_menuImporter; 64 org::kde::StatusNotifierItem *m_statusNotifierItemInterface; 65 bool m_refreshing : 1; 66 bool m_needsReRefreshing : 1; 67 bool m_titleUpdate : 1; 68 bool m_iconUpdate : 1; 69 bool m_tooltipUpdate : 1; 70 bool m_statusUpdate : 1; 71 }; 72