mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
systray plugin prototype
This commit is contained in:
parent
197de01630
commit
e14891dea1
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@
|
|||||||
|
|
||||||
build*/
|
build*/
|
||||||
*.pro.user*
|
*.pro.user*
|
||||||
|
*.DS_Store
|
||||||
|
21
dde-dock-systray-plugin/dde-dock-systray-plugin.pro
Executable file
21
dde-dock-systray-plugin/dde-dock-systray-plugin.pro
Executable file
@ -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
|
73
dde-dock-systray-plugin/docktrayitem.cpp
Executable file
73
dde-dock-systray-plugin/docktrayitem.cpp
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
31
dde-dock-systray-plugin/docktrayitem.h
Executable file
31
dde-dock-systray-plugin/docktrayitem.h
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef DOCKTRAYITEM_H
|
||||||
|
#define DOCKTRAYITEM_H
|
||||||
|
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
|
#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
|
11
dde-dock-systray-plugin/main.cpp
Normal file
11
dde-dock-systray-plugin/main.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "systrayplugin.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
SystrayPlugin w;
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
0
dde-dock-systray-plugin/systray.json
Normal file
0
dde-dock-systray-plugin/systray.json
Normal file
33
dde-dock-systray-plugin/systrayplugin.cpp
Executable file
33
dde-dock-systray-plugin/systrayplugin.cpp
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#include "systrayplugin.h"
|
||||||
|
|
||||||
|
SystrayPlugin::~SystrayPlugin()
|
||||||
|
{
|
||||||
|
this->clearItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<AbstractDockItem*> SystrayPlugin::items()
|
||||||
|
{
|
||||||
|
//clear m_items.
|
||||||
|
this->clearItems();
|
||||||
|
|
||||||
|
// get xids of trayicons.
|
||||||
|
QList<WId> 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();
|
||||||
|
}
|
24
dde-dock-systray-plugin/systrayplugin.h
Executable file
24
dde-dock-systray-plugin/systrayplugin.h
Executable file
@ -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<AbstractDockItem*> items() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<AbstractDockItem*> m_items;
|
||||||
|
|
||||||
|
void clearItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTRAYPLUGIN_H
|
@ -11,7 +11,7 @@ class AbstractDockItem : public QFrame
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AbstractDockItem(QWidget *parent = 0);
|
explicit AbstractDockItem(QWidget *parent = 0);
|
||||||
virtual ~AbstractDockItem() = 0;
|
virtual ~AbstractDockItem(){}
|
||||||
|
|
||||||
virtual QWidget * getContents() = 0;
|
virtual QWidget * getContents() = 0;
|
||||||
|
|
||||||
|
5
dde-dock/src/dockplugininterface.h
Normal file → Executable file
5
dde-dock/src/dockplugininterface.h
Normal file → Executable file
@ -4,12 +4,11 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "abstractdockitem.h"
|
#include "abstractdockitem.h"
|
||||||
|
|
||||||
class DockPluginInterface : public QObject
|
class DockPluginInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
virtual ~DockPluginInterface() {}
|
virtual ~DockPluginInterface() {}
|
||||||
virtual QList<AbstractDockItem*> items(){}
|
virtual QList<AbstractDockItem*> items() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user