mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
use new dbus interface
Change-Id: I15d4e83d173c134a72865624bbd9f3ca6dcf26c2
This commit is contained in:
parent
2625b34ef6
commit
76f95a7368
@ -27,9 +27,9 @@ const QList<DockItem *> DockItemController::itemList() const
|
|||||||
|
|
||||||
DockItemController::DockItemController(QObject *parent)
|
DockItemController::DockItemController(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_entryManager(new DBusDockEntryManager(this))
|
m_dockInter(new DBusDock(this))
|
||||||
{
|
{
|
||||||
for (auto entry : m_entryManager->entries())
|
for (auto entry : m_dockInter->entries())
|
||||||
m_itemList.append(new AppItem(entry));
|
m_itemList.append(new AppItem(entry));
|
||||||
m_itemList.append(new PlaceholderItem);
|
m_itemList.append(new PlaceholderItem);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DOCKITEMCONTROLLER_H
|
#ifndef DOCKITEMCONTROLLER_H
|
||||||
#define DOCKITEMCONTROLLER_H
|
#define DOCKITEMCONTROLLER_H
|
||||||
|
|
||||||
#include "dbus/dbusdockentrymanager.h"
|
#include "dbus/dbusdock.h"
|
||||||
#include "item/dockitem.h"
|
#include "item/dockitem.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -25,7 +25,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QList<DockItem *> m_itemList;
|
QList<DockItem *> m_itemList;
|
||||||
|
|
||||||
DBusDockEntryManager *m_entryManager;
|
DBusDock *m_dockInter;
|
||||||
|
|
||||||
static DockItemController *INSTANCE;
|
static DockItemController *INSTANCE;
|
||||||
};
|
};
|
||||||
|
31
dbus/com.deepin.dde.daemon.Dock.xml
Normal file
31
dbus/com.deepin.dde.daemon.Dock.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<interface name="com.deepin.dde.daemon.Dock">
|
||||||
|
<method name="ActivateWindow">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="CloseWindow">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="GetEntryIDs">
|
||||||
|
<arg type="as" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="ReorderEntries">
|
||||||
|
<arg type="as" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="SetFrontendWindow">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<signal name="ServiceRestarted"></signal>
|
||||||
|
<signal name="EntryAdded">
|
||||||
|
<arg type="o"></arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="EntryRemoved">
|
||||||
|
<arg type="s"></arg>
|
||||||
|
</signal>
|
||||||
|
<property name="Entries" type="ao" access="read"></property>
|
||||||
|
<property name="HideMode" type="i" access="readwrite"></property>
|
||||||
|
<property name="DisplayMode" type="i" access="readwrite"></property>
|
||||||
|
<property name="Position" type="i" access="readwrite"></property>
|
||||||
|
<property name="ActiveWindow" type="u" access="read"></property>
|
||||||
|
<property name="HideState" type="i" access="read"></property>
|
||||||
|
</interface>
|
||||||
|
|
28
dbus/dbusdock.cpp
Normal file
28
dbus/dbusdock.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusDock -p dbusdock com.deepin.dde.daemon.Dock.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 "dbusdock.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of interface class DBusDock
|
||||||
|
*/
|
||||||
|
|
||||||
|
DBusDock::DBusDock(QObject *parent)
|
||||||
|
: QDBusAbstractInterface("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusDock::~DBusDock()
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
145
dbus/dbusdock.h
Normal file
145
dbus/dbusdock.h
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusDock -p dbusdock com.deepin.dde.daemon.Dock.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 DBUSDOCK_H_1465782143
|
||||||
|
#define DBUSDOCK_H_1465782143
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Proxy class for interface com.deepin.dde.daemon.Dock
|
||||||
|
*/
|
||||||
|
class DBusDock: 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.daemon.Dock")
|
||||||
|
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.daemon.Dock"; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusDock(QObject *parent = 0);
|
||||||
|
|
||||||
|
~DBusDock();
|
||||||
|
|
||||||
|
Q_PROPERTY(uint ActiveWindow READ activeWindow NOTIFY ActiveWindowChanged)
|
||||||
|
inline uint activeWindow() const
|
||||||
|
{ return qvariant_cast< uint >(property("ActiveWindow")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged)
|
||||||
|
inline int displayMode() const
|
||||||
|
{ return qvariant_cast< int >(property("DisplayMode")); }
|
||||||
|
inline void setDisplayMode(int value)
|
||||||
|
{ setProperty("DisplayMode", QVariant::fromValue(value)); }
|
||||||
|
|
||||||
|
Q_PROPERTY(QList<QDBusObjectPath> Entries READ entries NOTIFY EntriesChanged)
|
||||||
|
inline QList<QDBusObjectPath> entries() const
|
||||||
|
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Entries")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(int HideMode READ hideMode WRITE setHideMode NOTIFY HideModeChanged)
|
||||||
|
inline int hideMode() const
|
||||||
|
{ return qvariant_cast< int >(property("HideMode")); }
|
||||||
|
inline void setHideMode(int value)
|
||||||
|
{ setProperty("HideMode", QVariant::fromValue(value)); }
|
||||||
|
|
||||||
|
Q_PROPERTY(int HideState READ hideState NOTIFY HideStateChanged)
|
||||||
|
inline int hideState() const
|
||||||
|
{ return qvariant_cast< int >(property("HideState")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(int Position READ position WRITE setPosition NOTIFY PositionChanged)
|
||||||
|
inline int position() const
|
||||||
|
{ return qvariant_cast< int >(property("Position")); }
|
||||||
|
inline void setPosition(int value)
|
||||||
|
{ setProperty("Position", QVariant::fromValue(value)); }
|
||||||
|
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
inline QDBusPendingReply<> ActivateWindow(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ActivateWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> CloseWindow(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("CloseWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<QStringList> GetEntryIDs()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("GetEntryIDs"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> ReorderEntries(const QStringList &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ReorderEntries"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SetFrontendWindow(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SetFrontendWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void EntryAdded(const QDBusObjectPath &in0);
|
||||||
|
void EntryRemoved(const QString &in0);
|
||||||
|
void ServiceRestarted();
|
||||||
|
// begin property changed signals
|
||||||
|
void ActiveWindowChanged();
|
||||||
|
void DisplayModeChanged();
|
||||||
|
void EntriesChanged();
|
||||||
|
void HideModeChanged();
|
||||||
|
void HideStateChanged();
|
||||||
|
void PositionChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace com {
|
||||||
|
namespace deepin {
|
||||||
|
namespace dde {
|
||||||
|
namespace daemon {
|
||||||
|
typedef ::DBusDock Dock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
DBusDockEntry::DBusDockEntry(const QString &path, QObject *parent)
|
DBusDockEntry::DBusDockEntry(const QString &path, QObject *parent)
|
||||||
: QDBusAbstractInterface("com.deepin.daemon.Dock", path, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
: QDBusAbstractInterface("com.deepin.dde.daemon.Dock", path, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Dict>("Dict");
|
qRegisterMetaType<Dict>("Dict");
|
||||||
qDBusRegisterMetaType<Dict>();
|
qDBusRegisterMetaType<Dict>();
|
||||||
|
@ -35,7 +35,7 @@ class DBusDockEntry: public QDBusAbstractInterface
|
|||||||
if (3 != arguments.count())
|
if (3 != arguments.count())
|
||||||
return;
|
return;
|
||||||
QString interfaceName = msg.arguments().at(0).toString();
|
QString interfaceName = msg.arguments().at(0).toString();
|
||||||
if (interfaceName !="dde.dock.Entry")
|
if (interfaceName !="com.deepin.dde.daemon.Dock.Entry")
|
||||||
return;
|
return;
|
||||||
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||||
foreach(const QString &prop, changedProps.keys()) {
|
foreach(const QString &prop, changedProps.keys()) {
|
||||||
@ -50,7 +50,7 @@ class DBusDockEntry: public QDBusAbstractInterface
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
static inline const char *staticInterfaceName()
|
static inline const char *staticInterfaceName()
|
||||||
{ return "dde.dock.Entry"; }
|
{ return "com.deepin.dde.daemon.Dock.Entry"; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DBusDockEntry(const QString &path, QObject *parent = 0);
|
explicit DBusDockEntry(const QString &path, QObject *parent = 0);
|
||||||
|
@ -18,7 +18,8 @@ SOURCES += main.cpp \
|
|||||||
item/appitem.cpp \
|
item/appitem.cpp \
|
||||||
util/docksettings.cpp \
|
util/docksettings.cpp \
|
||||||
item/placeholderitem.cpp \
|
item/placeholderitem.cpp \
|
||||||
dbus/dbusclientmanager.cpp
|
dbus/dbusclientmanager.cpp \
|
||||||
|
dbus/dbusdock.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
window/mainwindow.h \
|
window/mainwindow.h \
|
||||||
@ -32,4 +33,5 @@ HEADERS += \
|
|||||||
item/appitem.h \
|
item/appitem.h \
|
||||||
util/docksettings.h \
|
util/docksettings.h \
|
||||||
item/placeholderitem.h \
|
item/placeholderitem.h \
|
||||||
dbus/dbusclientmanager.h
|
dbus/dbusclientmanager.h \
|
||||||
|
dbus/dbusdock.h
|
||||||
|
@ -4,14 +4,10 @@
|
|||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#define APP_STATUS_KEY "app-status"
|
|
||||||
#define APP_ICON_KEY "icon"
|
#define APP_ICON_KEY "icon"
|
||||||
#define APP_MENU_KEY "menu"
|
#define APP_MENU_KEY "menu"
|
||||||
#define APP_XIDS_KEY "app-xids"
|
#define APP_XIDS_KEY "app-xids"
|
||||||
|
|
||||||
#define APP_ACTIVE_STATUS "active"
|
|
||||||
#define APP_NORMAL_STATUS "normal"
|
|
||||||
|
|
||||||
#define APP_DRAG_THRESHOLD 20
|
#define APP_DRAG_THRESHOLD 20
|
||||||
|
|
||||||
DBusClientManager *AppItem::ClientInter = nullptr;
|
DBusClientManager *AppItem::ClientInter = nullptr;
|
||||||
@ -26,6 +22,8 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|||||||
|
|
||||||
m_data = m_itemEntry->data();
|
m_data = m_itemEntry->data();
|
||||||
|
|
||||||
|
qDebug() << m_data;
|
||||||
|
|
||||||
connect(m_itemEntry, static_cast<void (DBusDockEntry::*)(const QString&, const QString&)>(&DBusDockEntry::DataChanged), this, &AppItem::entryDataChanged);
|
connect(m_itemEntry, static_cast<void (DBusDockEntry::*)(const QString&, const QString&)>(&DBusDockEntry::DataChanged), this, &AppItem::entryDataChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,18 +44,18 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
// draw current active background
|
// // draw current active background
|
||||||
if (m_windows.contains(ActiveWindowId))
|
// if (m_windows.contains(ActiveWindowId))
|
||||||
{
|
// {
|
||||||
painter.fillRect(rect(), Qt::blue);
|
// painter.fillRect(rect(), Qt::blue);
|
||||||
} else if (m_data[APP_STATUS_KEY] == APP_ACTIVE_STATUS)
|
// } else if (m_data[APP_STATUS_KEY] == APP_ACTIVE_STATUS)
|
||||||
{
|
// {
|
||||||
// draw active background
|
// // draw active background
|
||||||
painter.fillRect(rect(), Qt::cyan);
|
// painter.fillRect(rect(), Qt::cyan);
|
||||||
} else {
|
// } else {
|
||||||
// draw normal background
|
// // draw normal background
|
||||||
painter.fillRect(rect(), Qt::gray);
|
// painter.fillRect(rect(), Qt::gray);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// draw icon
|
// draw icon
|
||||||
painter.fillRect(iconRect, Qt::yellow);
|
painter.fillRect(iconRect, Qt::yellow);
|
||||||
@ -126,9 +124,11 @@ void AppItem::initClientManager()
|
|||||||
|
|
||||||
void AppItem::entryDataChanged(const QString &key, const QString &value)
|
void AppItem::entryDataChanged(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
|
qDebug() << "data chanegd" << key << value;
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
m_data[key] = value;
|
m_data[key] = value;
|
||||||
|
|
||||||
if (key == APP_STATUS_KEY)
|
// if (key == APP_STATUS_KEY)
|
||||||
return update();
|
return update();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user