mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
merge with dock-systray-plugin
This commit is contained in:
parent
eb730d09b6
commit
d340b25b8e
30
dde-dock-systray-plugin/com.deepin.dde.TrayManager.xml
Normal file
30
dde-dock-systray-plugin/com.deepin.dde.TrayManager.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<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="RequireManageTrayIcons"></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>
|
||||||
|
<property name="TrayIcons" type="au" access="read">
|
||||||
|
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QUintList"/>
|
||||||
|
</property>
|
||||||
|
</interface>
|
27
dde-dock-systray-plugin/dbustraymanager.cpp
Normal file
27
dde-dock-systray-plugin/dbustraymanager.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c TrayManager -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 TrayManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
TrayManager::TrayManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
|
||||||
|
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
|
||||||
|
{
|
||||||
|
qDBusRegisterMetaType<QUintList>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TrayManager::~TrayManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
99
dde-dock-systray-plugin/dbustraymanager.h
Normal file
99
dde-dock-systray-plugin/dbustraymanager.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c TrayManager -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_1435726109
|
||||||
|
#define DBUSTRAYMANAGER_H_1435726109
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
#include <QDBusMetaType>
|
||||||
|
|
||||||
|
typedef QList<uint> QUintList;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QUintList)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Proxy class for interface com.deepin.dde.TrayManager
|
||||||
|
*/
|
||||||
|
class TrayManager: public QDBusAbstractInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static inline const char *staticInterfaceName()
|
||||||
|
{ return "com.deepin.dde.TrayManager"; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
TrayManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
|
||||||
|
|
||||||
|
~TrayManager();
|
||||||
|
|
||||||
|
Q_PROPERTY(QUintList TrayIcons READ trayIcons)
|
||||||
|
inline QUintList trayIcons() const
|
||||||
|
{ return qvariant_cast< QUintList >(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<> RequireManageTrayIcons()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("RequireManageTrayIcons"), 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 Removed(uint in0);
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace com {
|
||||||
|
namespace deepin {
|
||||||
|
namespace dde {
|
||||||
|
typedef ::TrayManager TrayManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
9
dde-dock-systray-plugin/dde-dock-systray-plugin.pro
Executable file → Normal file
9
dde-dock-systray-plugin/dde-dock-systray-plugin.pro
Executable file → Normal file
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui
|
QT += core gui dbus
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
@ -15,7 +15,10 @@ TARGET = $$qtLibraryTarget(dock-systray-plugin)
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|
||||||
SOURCES += systrayplugin.cpp \
|
SOURCES += systrayplugin.cpp \
|
||||||
docktrayitem.cpp
|
docktrayitem.cpp \
|
||||||
|
dbustraymanager.cpp
|
||||||
|
|
||||||
HEADERS += systrayplugin.h \
|
HEADERS += systrayplugin.h \
|
||||||
docktrayitem.h
|
docktrayitem.h \
|
||||||
|
../dde-dock/src/abstractdockitem.h \
|
||||||
|
dbustraymanager.h
|
||||||
|
4
dde-dock-systray-plugin/docktrayitem.cpp
Executable file → Normal file
4
dde-dock-systray-plugin/docktrayitem.cpp
Executable file → Normal file
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "docktrayitem.h"
|
#include "docktrayitem.h"
|
||||||
|
|
||||||
static DockTrayItem * fromWinId(WId winId, QWidget *parent)
|
DockTrayItem * DockTrayItem::fromWinId(WId winId, QWidget *parent)
|
||||||
{
|
{
|
||||||
DockTrayItem *item = new DockTrayItem(parent);
|
DockTrayItem *item = new DockTrayItem(parent);
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ static DockTrayItem * fromWinId(WId winId, QWidget *parent)
|
|||||||
DockTrayItem::DockTrayItem(QWidget *parent)
|
DockTrayItem::DockTrayItem(QWidget *parent)
|
||||||
: AbstractDockItem(parent)
|
: AbstractDockItem(parent)
|
||||||
{
|
{
|
||||||
|
setFixedSize(32, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
DockTrayItem::~DockTrayItem()
|
DockTrayItem::~DockTrayItem()
|
||||||
|
0
dde-dock-systray-plugin/docktrayitem.h
Executable file → Normal file
0
dde-dock-systray-plugin/docktrayitem.h
Executable file → Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
23
dde-dock-systray-plugin/systrayplugin.cpp
Executable file → Normal file
23
dde-dock-systray-plugin/systrayplugin.cpp
Executable file → Normal file
@ -1,4 +1,7 @@
|
|||||||
|
#include <QtDBus/QDBusConnection>
|
||||||
|
|
||||||
#include "systrayplugin.h"
|
#include "systrayplugin.h"
|
||||||
|
#include "abstractdockitem.h"
|
||||||
|
|
||||||
SystrayPlugin::~SystrayPlugin()
|
SystrayPlugin::~SystrayPlugin()
|
||||||
{
|
{
|
||||||
@ -11,12 +14,23 @@ QList<AbstractDockItem*> SystrayPlugin::items()
|
|||||||
this->clearItems();
|
this->clearItems();
|
||||||
|
|
||||||
// get xids of trayicons.
|
// get xids of trayicons.
|
||||||
|
if (!m_dbusTrayManager) {
|
||||||
|
m_dbusTrayManager = new com::deepin::dde::TrayManager("com.deepin.dde.TrayManager",
|
||||||
|
"/com/deepin/dde/TrayManager",
|
||||||
|
QDBusConnection::sessionBus(),
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<uint> trayIcons = m_dbusTrayManager->trayIcons();
|
||||||
|
qDebug() << "Found trayicons: " << trayIcons;
|
||||||
|
|
||||||
QList<WId> winIds;
|
QList<WId> winIds;
|
||||||
winIds << 79691780 << 65011722;
|
foreach (QVariant trayIcon, trayIcons) {
|
||||||
|
winIds << trayIcon.toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
// generate items.
|
// generate items.
|
||||||
WId winId;
|
foreach (WId winId, winIds) {
|
||||||
foreach (winId, winIds) {
|
|
||||||
m_items << DockTrayItem::fromWinId(winId);
|
m_items << DockTrayItem::fromWinId(winId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,8 +39,7 @@ QList<AbstractDockItem*> SystrayPlugin::items()
|
|||||||
|
|
||||||
void SystrayPlugin::clearItems()
|
void SystrayPlugin::clearItems()
|
||||||
{
|
{
|
||||||
AbstractDockItem *item;
|
foreach (AbstractDockItem * item, m_items) {
|
||||||
foreach (item, m_items) {
|
|
||||||
item->deleteLater();
|
item->deleteLater();
|
||||||
}
|
}
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
|
5
dde-dock-systray-plugin/systrayplugin.h
Executable file → Normal file
5
dde-dock-systray-plugin/systrayplugin.h
Executable file → Normal file
@ -1,8 +1,12 @@
|
|||||||
#ifndef SYSTRAYPLUGIN_H
|
#ifndef SYSTRAYPLUGIN_H
|
||||||
#define SYSTRAYPLUGIN_H
|
#define SYSTRAYPLUGIN_H
|
||||||
|
|
||||||
|
#include <QtPlugin>
|
||||||
|
|
||||||
#include "docktrayitem.h"
|
#include "docktrayitem.h"
|
||||||
#include "dockplugininterface.h"
|
#include "dockplugininterface.h"
|
||||||
|
#include "abstractdockitem.h"
|
||||||
|
#include "dbustraymanager.h"
|
||||||
|
|
||||||
class SystrayPlugin : public QObject, DockPluginInterface
|
class SystrayPlugin : public QObject, DockPluginInterface
|
||||||
{
|
{
|
||||||
@ -17,6 +21,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<AbstractDockItem*> m_items;
|
QList<AbstractDockItem*> m_items;
|
||||||
|
com::deepin::dde::TrayManager *m_dbusTrayManager = 0;
|
||||||
|
|
||||||
void clearItems();
|
void clearItems();
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,8 @@ SOURCES += \
|
|||||||
src/Widgets/screenmask.cpp \
|
src/Widgets/screenmask.cpp \
|
||||||
src/Widgets/windowpreview.cpp \
|
src/Widgets/windowpreview.cpp \
|
||||||
src/Panel/panel.cpp \
|
src/Panel/panel.cpp \
|
||||||
src/Widgets/appitem.cpp
|
src/Widgets/appitem.cpp \
|
||||||
|
src/systraymanager.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/abstractdockitem.h \
|
src/abstractdockitem.h \
|
||||||
@ -39,7 +40,8 @@ HEADERS += \
|
|||||||
src/Widgets/screenmask.h \
|
src/Widgets/screenmask.h \
|
||||||
src/Widgets/windowpreview.h \
|
src/Widgets/windowpreview.h \
|
||||||
src/Panel/panel.h \
|
src/Panel/panel.h \
|
||||||
src/Widgets/appitem.h
|
src/Widgets/appitem.h \
|
||||||
|
src/systraymanager.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
images.qrc \
|
images.qrc \
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
|
#include "systraymanager.h"
|
||||||
|
|
||||||
Panel::Panel(QWidget *parent)
|
Panel::Panel(QWidget *parent)
|
||||||
: QLabel(parent),parentWidget(parent)
|
: QLabel(parent),parentWidget(parent)
|
||||||
@ -23,14 +24,15 @@ Panel::Panel(QWidget *parent)
|
|||||||
connect(leftLayout,SIGNAL(dragStarted()),this,SLOT(slotDragStarted()));
|
connect(leftLayout,SIGNAL(dragStarted()),this,SLOT(slotDragStarted()));
|
||||||
connect(leftLayout,SIGNAL(itemDropped()),this,SLOT(slotItemDropped()));
|
connect(leftLayout,SIGNAL(itemDropped()),this,SLOT(slotItemDropped()));
|
||||||
|
|
||||||
AppItem * b6 = new AppItem("App","../Resources/images/display-im6.q16.png");
|
|
||||||
AppItem * b7 = new AppItem("App","../Resources/images/eog.png");
|
|
||||||
rightLayout = new DockLayout(this);
|
rightLayout = new DockLayout(this);
|
||||||
rightLayout->setSortDirection(DockLayout::RightToLeft);
|
rightLayout->setSortDirection(DockLayout::RightToLeft);
|
||||||
rightLayout->resize(300,50);
|
rightLayout->resize(300,50);
|
||||||
rightLayout->move(0,0);
|
rightLayout->move(0,0);
|
||||||
rightLayout->addItem(b6);
|
|
||||||
rightLayout->addItem(b7);
|
SystrayManager *manager = new SystrayManager();
|
||||||
|
foreach (AbstractDockItem *item, manager->trayIcons()) {
|
||||||
|
rightLayout->addItem(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel::resize(const QSize &size)
|
void Panel::resize(const QSize &size)
|
||||||
|
29
dde-dock/src/systraymanager.cpp
Normal file
29
dde-dock/src/systraymanager.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <QDir>
|
||||||
|
#include <QPluginLoader>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "systraymanager.h"
|
||||||
|
|
||||||
|
SystrayManager::SystrayManager(QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
m_plugin(0)
|
||||||
|
{
|
||||||
|
this->loadPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<AbstractDockItem*> SystrayManager::trayIcons()
|
||||||
|
{
|
||||||
|
return m_plugin->items();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystrayManager::loadPlugin()
|
||||||
|
{
|
||||||
|
QPluginLoader loader("/home/hualet/project/linuxdeepin/dde-workspace-2015/dde-dock-systray-plugin/build/libdock-systray-plugin.so");
|
||||||
|
QObject *plugin = loader.instance();
|
||||||
|
if (plugin) {
|
||||||
|
m_plugin = qobject_cast<DockPluginInterface*>(plugin);
|
||||||
|
} else {
|
||||||
|
qWarning() << "Failed to load systray plugin.";
|
||||||
|
qWarning() << loader.errorString();
|
||||||
|
}
|
||||||
|
}
|
21
dde-dock/src/systraymanager.h
Normal file
21
dde-dock/src/systraymanager.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef SYSTRAYMANAGER_H
|
||||||
|
#define SYSTRAYMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "dockplugininterface.h"
|
||||||
|
|
||||||
|
class SystrayManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SystrayManager(QObject *parent = 0);
|
||||||
|
|
||||||
|
QList<AbstractDockItem*> trayIcons();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DockPluginInterface *m_plugin;
|
||||||
|
|
||||||
|
void loadPlugin();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTRAYMANAGER_H
|
Loading…
x
Reference in New Issue
Block a user