mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add system tray plugin
Change-Id: Iba6e206e506ecfd50f8600fefd7b150e27117f97
This commit is contained in:
parent
1adeef359b
commit
d9d2faccca
@ -9,3 +9,5 @@ isEmpty(PREFIX)
|
|||||||
{
|
{
|
||||||
PREFIX = /usr
|
PREFIX = /usr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
virtual ~PluginsItemInterface() {}
|
virtual ~PluginsItemInterface() {}
|
||||||
|
|
||||||
// the unique plugin id
|
// the unique plugin id
|
||||||
virtual const QString pluginName() = 0;
|
virtual const QString pluginName() const = 0;
|
||||||
// init plugins
|
// init plugins
|
||||||
virtual void init(PluginProxyInterface *proxyInter) = 0;
|
virtual void init(PluginProxyInterface *proxyInter) = 0;
|
||||||
// dock display mode changed
|
// dock display mode changed
|
||||||
|
@ -17,7 +17,7 @@ DatetimePlugin::~DatetimePlugin()
|
|||||||
delete m_centeralWidget;
|
delete m_centeralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString DatetimePlugin::pluginName()
|
const QString DatetimePlugin::pluginName() const
|
||||||
{
|
{
|
||||||
return "datetime";
|
return "datetime";
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
explicit DatetimePlugin(QObject *parent = 0);
|
explicit DatetimePlugin(QObject *parent = 0);
|
||||||
~DatetimePlugin();
|
~DatetimePlugin();
|
||||||
|
|
||||||
const QString pluginName();
|
const QString pluginName() const;
|
||||||
ItemType pluginType(const QString &itemKey);
|
ItemType pluginType(const QString &itemKey);
|
||||||
void init(PluginProxyInterface *proxyInter);
|
void init(PluginProxyInterface *proxyInter);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
datetime \
|
datetime \
|
||||||
shutdown
|
shutdown \
|
||||||
|
system-tray
|
||||||
|
@ -8,7 +8,7 @@ ShutdownPlugin::ShutdownPlugin(QObject *parent)
|
|||||||
m_icon.addFile(":/icons/resources/icons/fashion.svg");
|
m_icon.addFile(":/icons/resources/icons/fashion.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ShutdownPlugin::pluginName()
|
const QString ShutdownPlugin::pluginName() const
|
||||||
{
|
{
|
||||||
return "shutdown";
|
return "shutdown";
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class ShutdownPlugin : public QObject, PluginsItemInterface
|
|||||||
public:
|
public:
|
||||||
explicit ShutdownPlugin(QObject *parent = 0);
|
explicit ShutdownPlugin(QObject *parent = 0);
|
||||||
|
|
||||||
const QString pluginName();
|
const QString pluginName() const;
|
||||||
void init(PluginProxyInterface *proxyInter);
|
void init(PluginProxyInterface *proxyInter);
|
||||||
|
|
||||||
ItemType pluginType(const QString &itemKey);
|
ItemType pluginType(const QString &itemKey);
|
||||||
|
31
plugins/system-tray/dbus/com.deepin.dde.TrayManager.xml
Normal file
31
plugins/system-tray/dbus/com.deepin.dde.TrayManager.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<interface name="com.deepin.dde.TrayManager">
|
||||||
|
<method name="EnableNotification">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
<arg type="b" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="GetName">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
<arg type="s" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="Manage">
|
||||||
|
<arg type="b" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="RetryManager"></method>
|
||||||
|
<method name="Unmanage">
|
||||||
|
<arg type="b" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<signal name="Removed">
|
||||||
|
<arg type="u"></arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="Added">
|
||||||
|
<arg type="u"></arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="Changed">
|
||||||
|
<arg type="u"></arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="Inited"></signal>
|
||||||
|
<property name="TrayIcons" type="au" access="read">
|
||||||
|
<annotation name="org.qtproject.QtDBus.QtTypeName" value="TrayList"/>
|
||||||
|
</property>
|
||||||
|
</interface>
|
||||||
|
|
31
plugins/system-tray/dbus/dbustraymanager.cpp
Normal file
31
plugins/system-tray/dbus/dbustraymanager.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusTrayManager -p dbustraymanager com.deepin.dde.TrayManager.xml
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||||
|
* before re-generating it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbustraymanager.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of interface class DBusTrayManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
DBusTrayManager::DBusTrayManager(QObject *parent)
|
||||||
|
: QDBusAbstractInterface("com.deepin.dde.TrayManager", "/com/deepin/dde/TrayManager", staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||||
|
{
|
||||||
|
qRegisterMetaType<TrayList>("TrayList");
|
||||||
|
qDBusRegisterMetaType<TrayList>();
|
||||||
|
|
||||||
|
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusTrayManager::~DBusTrayManager()
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
113
plugins/system-tray/dbus/dbustraymanager.h
Normal file
113
plugins/system-tray/dbus/dbustraymanager.h
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusTrayManager -p dbustraymanager com.deepin.dde.TrayManager.xml
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* Do not edit! All changes made to it will be lost.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DBUSTRAYMANAGER_H_1467094672
|
||||||
|
#define DBUSTRAYMANAGER_H_1467094672
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
|
||||||
|
typedef QList<quint32> TrayList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Proxy class for interface com.deepin.dde.TrayManager
|
||||||
|
*/
|
||||||
|
class DBusTrayManager: public QDBusAbstractInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_SLOT void __propertyChanged__(const QDBusMessage& msg)
|
||||||
|
{
|
||||||
|
QList<QVariant> arguments = msg.arguments();
|
||||||
|
if (3 != arguments.count())
|
||||||
|
return;
|
||||||
|
QString interfaceName = msg.arguments().at(0).toString();
|
||||||
|
if (interfaceName !="com.deepin.dde.TrayManager")
|
||||||
|
return;
|
||||||
|
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||||
|
foreach(const QString &prop, changedProps.keys()) {
|
||||||
|
const QMetaObject* self = metaObject();
|
||||||
|
for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) {
|
||||||
|
QMetaProperty p = self->property(i);
|
||||||
|
if (p.name() == prop) {
|
||||||
|
Q_EMIT p.notifySignal().invoke(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
static inline const char *staticInterfaceName()
|
||||||
|
{ return "com.deepin.dde.TrayManager"; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusTrayManager(QObject *parent = 0);
|
||||||
|
|
||||||
|
~DBusTrayManager();
|
||||||
|
|
||||||
|
Q_PROPERTY(TrayList TrayIcons READ trayIcons NOTIFY TrayIconsChanged)
|
||||||
|
inline TrayList trayIcons() const
|
||||||
|
{ return qvariant_cast< TrayList >(property("TrayIcons")); }
|
||||||
|
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
inline QDBusPendingReply<> EnableNotification(uint in0, bool in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("EnableNotification"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<QString> GetName(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("GetName"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<bool> Manage()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Manage"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> RetryManager()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("RetryManager"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<bool> Unmanage()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Unmanage"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void Added(uint in0);
|
||||||
|
void Changed(uint in0);
|
||||||
|
void Inited();
|
||||||
|
void Removed(uint in0);
|
||||||
|
// begin property changed signals
|
||||||
|
void TrayIconsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace com {
|
||||||
|
namespace deepin {
|
||||||
|
namespace dde {
|
||||||
|
typedef ::DBusTrayManager TrayManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
2
plugins/system-tray/system-tray.json
Normal file
2
plugins/system-tray/system-tray.json
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
21
plugins/system-tray/system-tray.pro
Normal file
21
plugins/system-tray/system-tray.pro
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
include(../../interfaces/interfaces.pri)
|
||||||
|
|
||||||
|
QT += widgets
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin c++11 link_pkgconfig
|
||||||
|
PKGCONFIG +=
|
||||||
|
|
||||||
|
TARGET = $$qtLibraryTarget(system-tray)
|
||||||
|
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
systemtrayplugin.h \
|
||||||
|
dbus/dbustraymanager.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
systemtrayplugin.cpp \
|
||||||
|
dbus/dbustraymanager.cpp
|
||||||
|
|
||||||
|
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||||
|
INSTALLS += target
|
18
plugins/system-tray/systemtrayplugin.cpp
Normal file
18
plugins/system-tray/systemtrayplugin.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "systemtrayplugin.h"
|
||||||
|
|
||||||
|
SystemTrayPlugin::SystemTrayPlugin(QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
m_trayInter(new DBusTrayManager(this))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString SystemTrayPlugin::pluginName() const
|
||||||
|
{
|
||||||
|
return "system-tray";
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemTrayPlugin::init(PluginProxyInterface *proxyInter)
|
||||||
|
{
|
||||||
|
m_proxyInter = proxyInter;
|
||||||
|
}
|
24
plugins/system-tray/systemtrayplugin.h
Normal file
24
plugins/system-tray/systemtrayplugin.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef SYSTEMTRAYPLUGIN_H
|
||||||
|
#define SYSTEMTRAYPLUGIN_H
|
||||||
|
|
||||||
|
#include "pluginsiteminterface.h"
|
||||||
|
|
||||||
|
#include "dbus/dbustraymanager.h"
|
||||||
|
|
||||||
|
class SystemTrayPlugin : public QObject, PluginsItemInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(PluginsItemInterface)
|
||||||
|
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "system-tray.json")
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SystemTrayPlugin(QObject *parent = 0);
|
||||||
|
|
||||||
|
const QString pluginName() const;
|
||||||
|
void init(PluginProxyInterface *proxyInter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DBusTrayManager *m_trayInter;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTEMTRAYPLUGIN_H
|
Loading…
x
Reference in New Issue
Block a user