diff --git a/dde-dock-systray-plugin/com.deepin.dde.TrayManager.xml b/dde-dock-systray-plugin/com.deepin.dde.TrayManager.xml new file mode 100644 index 000000000..1c5139f6e --- /dev/null +++ b/dde-dock-systray-plugin/com.deepin.dde.TrayManager.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dde-dock-systray-plugin/dbustraymanager.cpp b/dde-dock-systray-plugin/dbustraymanager.cpp new file mode 100644 index 000000000..b0d533151 --- /dev/null +++ b/dde-dock-systray-plugin/dbustraymanager.cpp @@ -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(); +} + +TrayManager::~TrayManager() +{ +} + diff --git a/dde-dock-systray-plugin/dbustraymanager.h b/dde-dock-systray-plugin/dbustraymanager.h new file mode 100644 index 000000000..54deddffd --- /dev/null +++ b/dde-dock-systray-plugin/dbustraymanager.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +typedef QList 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 argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("EnableNotification"), argumentList); + } + + inline QDBusPendingReply GetName(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("GetName"), argumentList); + } + + inline QDBusPendingReply Manage() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("Manage"), argumentList); + } + + inline QDBusPendingReply<> RequireManageTrayIcons() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("RequireManageTrayIcons"), argumentList); + } + + inline QDBusPendingReply<> RetryManager() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("RetryManager"), argumentList); + } + + inline QDBusPendingReply Unmanage() + { + QList 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 diff --git a/dde-dock-systray-plugin/dde-dock-systray-plugin.pro b/dde-dock-systray-plugin/dde-dock-systray-plugin.pro old mode 100755 new mode 100644 index 2caf95c91..35362a047 --- a/dde-dock-systray-plugin/dde-dock-systray-plugin.pro +++ b/dde-dock-systray-plugin/dde-dock-systray-plugin.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui +QT += core gui dbus greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -15,7 +15,10 @@ TARGET = $$qtLibraryTarget(dock-systray-plugin) TEMPLATE = lib SOURCES += systrayplugin.cpp \ - docktrayitem.cpp + docktrayitem.cpp \ + dbustraymanager.cpp HEADERS += systrayplugin.h \ - docktrayitem.h + docktrayitem.h \ + ../dde-dock/src/abstractdockitem.h \ + dbustraymanager.h diff --git a/dde-dock-systray-plugin/docktrayitem.cpp b/dde-dock-systray-plugin/docktrayitem.cpp old mode 100755 new mode 100644 index 1ca67d967..a7ff20137 --- a/dde-dock-systray-plugin/docktrayitem.cpp +++ b/dde-dock-systray-plugin/docktrayitem.cpp @@ -2,7 +2,7 @@ #include "docktrayitem.h" -static DockTrayItem * fromWinId(WId winId, QWidget *parent) +DockTrayItem * DockTrayItem::fromWinId(WId winId, QWidget *parent) { DockTrayItem *item = new DockTrayItem(parent); @@ -19,7 +19,7 @@ static DockTrayItem * fromWinId(WId winId, QWidget *parent) DockTrayItem::DockTrayItem(QWidget *parent) : AbstractDockItem(parent) { - + setFixedSize(32, 32); } DockTrayItem::~DockTrayItem() diff --git a/dde-dock-systray-plugin/docktrayitem.h b/dde-dock-systray-plugin/docktrayitem.h old mode 100755 new mode 100644 diff --git a/dde-dock-systray-plugin/systray.json b/dde-dock-systray-plugin/systray.json index e69de29bb..0967ef424 100644 --- a/dde-dock-systray-plugin/systray.json +++ b/dde-dock-systray-plugin/systray.json @@ -0,0 +1 @@ +{} diff --git a/dde-dock-systray-plugin/systrayplugin.cpp b/dde-dock-systray-plugin/systrayplugin.cpp old mode 100755 new mode 100644 index d2654ccdc..041423e7a --- a/dde-dock-systray-plugin/systrayplugin.cpp +++ b/dde-dock-systray-plugin/systrayplugin.cpp @@ -1,4 +1,7 @@ +#include + #include "systrayplugin.h" +#include "abstractdockitem.h" SystrayPlugin::~SystrayPlugin() { @@ -11,12 +14,23 @@ QList SystrayPlugin::items() this->clearItems(); // 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 trayIcons = m_dbusTrayManager->trayIcons(); + qDebug() << "Found trayicons: " << trayIcons; + QList winIds; - winIds << 79691780 << 65011722; + foreach (QVariant trayIcon, trayIcons) { + winIds << trayIcon.toUInt(); + } // generate items. - WId winId; - foreach (winId, winIds) { + foreach (WId winId, winIds) { m_items << DockTrayItem::fromWinId(winId); } @@ -25,8 +39,7 @@ QList SystrayPlugin::items() void SystrayPlugin::clearItems() { - AbstractDockItem *item; - foreach (item, m_items) { + foreach (AbstractDockItem * item, m_items) { item->deleteLater(); } m_items.clear(); diff --git a/dde-dock-systray-plugin/systrayplugin.h b/dde-dock-systray-plugin/systrayplugin.h old mode 100755 new mode 100644 index bf5627f47..d51e2197a --- a/dde-dock-systray-plugin/systrayplugin.h +++ b/dde-dock-systray-plugin/systrayplugin.h @@ -1,8 +1,12 @@ #ifndef SYSTRAYPLUGIN_H #define SYSTRAYPLUGIN_H +#include + #include "docktrayitem.h" #include "dockplugininterface.h" +#include "abstractdockitem.h" +#include "dbustraymanager.h" class SystrayPlugin : public QObject, DockPluginInterface { @@ -17,6 +21,7 @@ public: private: QList m_items; + com::deepin::dde::TrayManager *m_dbusTrayManager = 0; void clearItems(); }; diff --git a/dde-dock/dde-dock.pro b/dde-dock/dde-dock.pro index af84544bf..f607b493f 100644 --- a/dde-dock/dde-dock.pro +++ b/dde-dock/dde-dock.pro @@ -24,7 +24,8 @@ SOURCES += \ src/Widgets/screenmask.cpp \ src/Widgets/windowpreview.cpp \ src/Panel/panel.cpp \ - src/Widgets/appitem.cpp + src/Widgets/appitem.cpp \ + src/systraymanager.cpp HEADERS += \ src/abstractdockitem.h \ @@ -39,7 +40,8 @@ HEADERS += \ src/Widgets/screenmask.h \ src/Widgets/windowpreview.h \ src/Panel/panel.h \ - src/Widgets/appitem.h + src/Widgets/appitem.h \ + src/systraymanager.h RESOURCES += \ images.qrc \ diff --git a/dde-dock/src/Panel/panel.cpp b/dde-dock/src/Panel/panel.cpp index ec702e035..23c5a7149 100644 --- a/dde-dock/src/Panel/panel.cpp +++ b/dde-dock/src/Panel/panel.cpp @@ -1,4 +1,5 @@ #include "panel.h" +#include "systraymanager.h" Panel::Panel(QWidget *parent) : QLabel(parent),parentWidget(parent) @@ -23,14 +24,15 @@ Panel::Panel(QWidget *parent) connect(leftLayout,SIGNAL(dragStarted()),this,SLOT(slotDragStarted())); 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->setSortDirection(DockLayout::RightToLeft); rightLayout->resize(300,50); 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) diff --git a/dde-dock/src/systraymanager.cpp b/dde-dock/src/systraymanager.cpp new file mode 100644 index 000000000..36f9d50ff --- /dev/null +++ b/dde-dock/src/systraymanager.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +#include "systraymanager.h" + +SystrayManager::SystrayManager(QObject *parent) + : QObject(parent), + m_plugin(0) +{ + this->loadPlugin(); +} + +QList 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(plugin); + } else { + qWarning() << "Failed to load systray plugin."; + qWarning() << loader.errorString(); + } +} diff --git a/dde-dock/src/systraymanager.h b/dde-dock/src/systraymanager.h new file mode 100644 index 000000000..5d38e738a --- /dev/null +++ b/dde-dock/src/systraymanager.h @@ -0,0 +1,21 @@ +#ifndef SYSTRAYMANAGER_H +#define SYSTRAYMANAGER_H + +#include +#include "dockplugininterface.h" + +class SystrayManager : public QObject +{ + Q_OBJECT +public: + explicit SystrayManager(QObject *parent = 0); + + QList trayIcons(); + +private: + DockPluginInterface *m_plugin; + + void loadPlugin(); +}; + +#endif // SYSTRAYMANAGER_H