diff --git a/.gitignore b/.gitignore index 6e8348670..898502a54 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ build*/ *.pro.user* +*.DS_Store diff --git a/dde-dock-systray-plugin/dde-dock-systray-plugin.pro b/dde-dock-systray-plugin/dde-dock-systray-plugin.pro new file mode 100755 index 000000000..2caf95c91 --- /dev/null +++ b/dde-dock-systray-plugin/dde-dock-systray-plugin.pro @@ -0,0 +1,21 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-06-29T20:08:12 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +INCLUDEPATH += ../dde-dock/src/ +CONFIG += plugin c++11 + +TARGET = $$qtLibraryTarget(dock-systray-plugin) +TEMPLATE = lib + +SOURCES += systrayplugin.cpp \ + docktrayitem.cpp + +HEADERS += systrayplugin.h \ + docktrayitem.h diff --git a/dde-dock-systray-plugin/docktrayitem.cpp b/dde-dock-systray-plugin/docktrayitem.cpp new file mode 100755 index 000000000..1ca67d967 --- /dev/null +++ b/dde-dock-systray-plugin/docktrayitem.cpp @@ -0,0 +1,73 @@ +#include + +#include "docktrayitem.h" + +static DockTrayItem * fromWinId(WId winId, QWidget *parent) +{ + DockTrayItem *item = new DockTrayItem(parent); + + QWindow *win = QWindow::fromWinId(winId); + QWidget *child = QWidget::createWindowContainer(win, item); + + QHBoxLayout *layout = new QHBoxLayout(item); + layout->addWidget(child); + item->setLayout(layout); + + return item; +} + +DockTrayItem::DockTrayItem(QWidget *parent) + : AbstractDockItem(parent) +{ + +} + +DockTrayItem::~DockTrayItem() +{ + +} + +void DockTrayItem::setTitle(const QString &) +{ + +} + +void DockTrayItem::setIcon(const QString &, int) +{ + +} + +void DockTrayItem::setMoveable(bool) +{ + +} + +bool DockTrayItem::moveable() +{ + return false; +} + +void DockTrayItem::setActived(bool) +{ + +} + +bool DockTrayItem::actived() +{ + return false; +} + +void DockTrayItem::setIndex(int value) +{ + m_itemIndex = value; +} + +int DockTrayItem::index() +{ + return m_itemIndex; +} + +QWidget * DockTrayItem::getContents() +{ + return NULL; +} diff --git a/dde-dock-systray-plugin/docktrayitem.h b/dde-dock-systray-plugin/docktrayitem.h new file mode 100755 index 000000000..a64d32a03 --- /dev/null +++ b/dde-dock-systray-plugin/docktrayitem.h @@ -0,0 +1,31 @@ +#ifndef DOCKTRAYITEM_H +#define DOCKTRAYITEM_H + +#include + +#include "abstractdockitem.h" + +class DockTrayItem : public AbstractDockItem +{ + Q_OBJECT + + enum Style { Simple, Composite }; +public: + explicit DockTrayItem(QWidget *parent = 0); + ~DockTrayItem(); + + static DockTrayItem* fromWinId(WId winId, QWidget *parent=0); + + void setTitle(const QString &title) Q_DECL_OVERRIDE; + void setIcon(const QString &iconPath, int size = 42) Q_DECL_OVERRIDE; + void setMoveable(bool value) Q_DECL_OVERRIDE; + bool moveable() Q_DECL_OVERRIDE; + void setActived(bool value) Q_DECL_OVERRIDE; + bool actived() Q_DECL_OVERRIDE; + void setIndex(int value) Q_DECL_OVERRIDE; + int index() Q_DECL_OVERRIDE; + + QWidget * getContents() Q_DECL_OVERRIDE; +}; + +#endif // DOCKTRAYITEM_H diff --git a/dde-dock-systray-plugin/main.cpp b/dde-dock-systray-plugin/main.cpp new file mode 100644 index 000000000..af6e392c9 --- /dev/null +++ b/dde-dock-systray-plugin/main.cpp @@ -0,0 +1,11 @@ +#include "systrayplugin.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + SystrayPlugin w; + w.show(); + + return a.exec(); +} diff --git a/dde-dock-systray-plugin/systray.json b/dde-dock-systray-plugin/systray.json new file mode 100644 index 000000000..e69de29bb diff --git a/dde-dock-systray-plugin/systrayplugin.cpp b/dde-dock-systray-plugin/systrayplugin.cpp new file mode 100755 index 000000000..d2654ccdc --- /dev/null +++ b/dde-dock-systray-plugin/systrayplugin.cpp @@ -0,0 +1,33 @@ +#include "systrayplugin.h" + +SystrayPlugin::~SystrayPlugin() +{ + this->clearItems(); +} + +QList SystrayPlugin::items() +{ + //clear m_items. + this->clearItems(); + + // get xids of trayicons. + QList winIds; + winIds << 79691780 << 65011722; + + // generate items. + WId winId; + foreach (winId, winIds) { + m_items << DockTrayItem::fromWinId(winId); + } + + return m_items; +} + +void SystrayPlugin::clearItems() +{ + AbstractDockItem *item; + foreach (item, m_items) { + item->deleteLater(); + } + m_items.clear(); +} diff --git a/dde-dock-systray-plugin/systrayplugin.h b/dde-dock-systray-plugin/systrayplugin.h new file mode 100755 index 000000000..bf5627f47 --- /dev/null +++ b/dde-dock-systray-plugin/systrayplugin.h @@ -0,0 +1,24 @@ +#ifndef SYSTRAYPLUGIN_H +#define SYSTRAYPLUGIN_H + +#include "docktrayitem.h" +#include "dockplugininterface.h" + +class SystrayPlugin : public QObject, DockPluginInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.deepin.Dock.PluginInterface" FILE "systray.json") + Q_INTERFACES(DockPluginInterface) + +public: + ~SystrayPlugin(); + + QList items() Q_DECL_OVERRIDE; + +private: + QList m_items; + + void clearItems(); +}; + +#endif // SYSTRAYPLUGIN_H diff --git a/dde-dock/src/abstractdockitem.h b/dde-dock/src/abstractdockitem.h index bec11d7eb..2581afe85 100644 --- a/dde-dock/src/abstractdockitem.h +++ b/dde-dock/src/abstractdockitem.h @@ -11,7 +11,7 @@ class AbstractDockItem : public QFrame Q_OBJECT public: explicit AbstractDockItem(QWidget *parent = 0); - virtual ~AbstractDockItem() = 0; + virtual ~AbstractDockItem(){} virtual QWidget * getContents() = 0; diff --git a/dde-dock/src/dockplugininterface.h b/dde-dock/src/dockplugininterface.h old mode 100644 new mode 100755 index 69301d526..4aee9aaa4 --- a/dde-dock/src/dockplugininterface.h +++ b/dde-dock/src/dockplugininterface.h @@ -4,12 +4,11 @@ #include #include "abstractdockitem.h" -class DockPluginInterface : public QObject +class DockPluginInterface { - Q_OBJECT public: virtual ~DockPluginInterface() {} - virtual QList items(){} + virtual QList items() = 0; }; QT_BEGIN_NAMESPACE