This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
systemtray.h
125 lines (100 loc) · 4.7 KB
/
systemtray.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
* Copyright (C) 2015 Marco Martin <[email protected]> *
*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef SYSTEMTRAY_H
#define SYSTEMTRAY_H
#include <QAbstractItemModel>
#include <Plasma/Containment>
class QDBusPendingCallWatcher;
class QDBusConnection;
class QQuickItem;
class PlasmoidModel;
class SystemTray : public Plasma::Containment
{
Q_OBJECT
Q_PROPERTY(QAbstractItemModel* availablePlasmoids READ availablePlasmoids CONSTANT)
Q_PROPERTY(QStringList allowedPlasmoids READ allowedPlasmoids WRITE setAllowedPlasmoids NOTIFY allowedPlasmoidsChanged)
Q_PROPERTY(QStringList defaultPlasmoids READ defaultPlasmoids CONSTANT)
public:
SystemTray( QObject *parent, const QVariantList &args );
~SystemTray() override;
void init() override;
void restoreContents(KConfigGroup &group) Q_DECL_OVERRIDE;
void restorePlasmoids();
QStringList defaultPlasmoids() const;
QAbstractItemModel* availablePlasmoids();
QStringList allowedPlasmoids() const;
void setAllowedPlasmoids(const QStringList &allowed);
//Creates an applet *if not already existing*
void newTask(const QString &task);
//cleans all instances of a given applet
void cleanupTask(const QString &task);
//Invokable utilities
/**
* Given an AppletInterface pointer, shows a proper context menu for it
*/
Q_INVOKABLE void showPlasmoidMenu(QQuickItem *appletInterface, int x, int y);
/**
* Returns the "X-Plasma-NotificationAreaCategory"
* of the plasmoid metadata
*/
Q_INVOKABLE QString plasmoidCategory(QQuickItem *appletInterface) const;
/**
* Shows the context menu for a statusnotifieritem
*/
Q_INVOKABLE void showStatusNotifierContextMenu(KJob *job, QQuickItem *statusNotifierIcon);
/**
* Find out global coordinates for a popup given local MouseArea
* coordinates
*/
Q_INVOKABLE QPointF popupPosition(QQuickItem* visualParent, int x, int y);
/**
* Reparent the item "before" with the same parent as the item "after",
* then restack it before it, using QQuickITem::stackBefore.
* used to quickly reorder icons in the systray (or hidden popup)
* @see QQuickITem::stackBefore
*/
Q_INVOKABLE void reorderItemBefore(QQuickItem* before, QQuickItem* after);
/**
* Reparent the item "after" with the same parent as the item "before",
* then restack it after it, using QQuickITem::stackAfter.
* used to quickly reorder icons in the systray (or hidden popup)
* @see QQuickITem::stackAfter
*/
Q_INVOKABLE void reorderItemAfter(QQuickItem* after, QQuickItem* before);
Q_INVOKABLE bool isSystemTrayApplet(const QString &appletId);
private Q_SLOTS:
void serviceNameFetchFinished(QDBusPendingCallWatcher* watcher, const QDBusConnection &connection);
void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
private:
void serviceRegistered(const QString &service);
void serviceUnregistered(const QString &service);
Q_SIGNALS:
void allowedPlasmoidsChanged();
private:
void initDBusActivatables();
QStringList m_defaultPlasmoids;
QHash<QString /*plugin name*/, KPluginInfo> m_systrayApplets;
QHash<QString /*plugin name*/, QString /*DBus Service*/> m_dbusActivatableTasks;
QStringList m_allowedPlasmoids;
PlasmoidModel *m_availablePlasmoidsModel;
QHash<QString, int> m_knownPlugins;
QHash<QString, int> m_dbusServiceCounts;
};
#endif