diff --git a/controller/dockitemcontroller.cpp b/controller/dockitemcontroller.cpp index 170dbd5ae..0da48e1ae 100644 --- a/controller/dockitemcontroller.cpp +++ b/controller/dockitemcontroller.cpp @@ -27,9 +27,9 @@ const QList DockItemController::itemList() const DockItemController::DockItemController(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 PlaceholderItem); } diff --git a/controller/dockitemcontroller.h b/controller/dockitemcontroller.h index ecaaf329a..2ec8f94d6 100644 --- a/controller/dockitemcontroller.h +++ b/controller/dockitemcontroller.h @@ -1,7 +1,7 @@ #ifndef DOCKITEMCONTROLLER_H #define DOCKITEMCONTROLLER_H -#include "dbus/dbusdockentrymanager.h" +#include "dbus/dbusdock.h" #include "item/dockitem.h" #include @@ -25,7 +25,7 @@ private: private: QList m_itemList; - DBusDockEntryManager *m_entryManager; + DBusDock *m_dockInter; static DockItemController *INSTANCE; }; diff --git a/dbus/com.deepin.dde.daemon.Dock.xml b/dbus/com.deepin.dde.daemon.Dock.xml new file mode 100644 index 000000000..dc10e442b --- /dev/null +++ b/dbus/com.deepin.dde.daemon.Dock.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbus/dbusdock.cpp b/dbus/dbusdock.cpp new file mode 100644 index 000000000..32e40b7a2 --- /dev/null +++ b/dbus/dbusdock.cpp @@ -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))); +} + diff --git a/dbus/dbusdock.h b/dbus/dbusdock.h new file mode 100644 index 000000000..d08ee9b12 --- /dev/null +++ b/dbus/dbusdock.h @@ -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 +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.deepin.dde.daemon.Dock + */ +class DBusDock: public QDBusAbstractInterface +{ + Q_OBJECT + + Q_SLOT void __propertyChanged__(const QDBusMessage& msg) + { + QList 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(arguments.at(1).value()); + 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 Entries READ entries NOTIFY EntriesChanged) + inline QList entries() const + { return qvariant_cast< QList >(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 argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("ActivateWindow"), argumentList); + } + + inline QDBusPendingReply<> CloseWindow(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("CloseWindow"), argumentList); + } + + inline QDBusPendingReply GetEntryIDs() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetEntryIDs"), argumentList); + } + + inline QDBusPendingReply<> ReorderEntries(const QStringList &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("ReorderEntries"), argumentList); + } + + inline QDBusPendingReply<> SetFrontendWindow(uint in0) + { + QList 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 diff --git a/dbus/dbusdockentry.cpp b/dbus/dbusdockentry.cpp index e688f28e8..bdd64f45f 100644 --- a/dbus/dbusdockentry.cpp +++ b/dbus/dbusdockentry.cpp @@ -16,7 +16,7 @@ */ 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"); qDBusRegisterMetaType(); diff --git a/dbus/dbusdockentry.h b/dbus/dbusdockentry.h index eb33391c4..8d6beb8f0 100644 --- a/dbus/dbusdockentry.h +++ b/dbus/dbusdockentry.h @@ -35,7 +35,7 @@ class DBusDockEntry: public QDBusAbstractInterface if (3 != arguments.count()) return; QString interfaceName = msg.arguments().at(0).toString(); - if (interfaceName !="dde.dock.Entry") + if (interfaceName !="com.deepin.dde.daemon.Dock.Entry") return; QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); foreach(const QString &prop, changedProps.keys()) { @@ -50,7 +50,7 @@ class DBusDockEntry: public QDBusAbstractInterface } public: static inline const char *staticInterfaceName() - { return "dde.dock.Entry"; } + { return "com.deepin.dde.daemon.Dock.Entry"; } public: explicit DBusDockEntry(const QString &path, QObject *parent = 0); diff --git a/dde-dock.pro b/dde-dock.pro index befd79231..053002e79 100644 --- a/dde-dock.pro +++ b/dde-dock.pro @@ -18,7 +18,8 @@ SOURCES += main.cpp \ item/appitem.cpp \ util/docksettings.cpp \ item/placeholderitem.cpp \ - dbus/dbusclientmanager.cpp + dbus/dbusclientmanager.cpp \ + dbus/dbusdock.cpp HEADERS += \ window/mainwindow.h \ @@ -32,4 +33,5 @@ HEADERS += \ item/appitem.h \ util/docksettings.h \ item/placeholderitem.h \ - dbus/dbusclientmanager.h + dbus/dbusclientmanager.h \ + dbus/dbusdock.h diff --git a/item/appitem.cpp b/item/appitem.cpp index 92de2b643..2072cbac5 100644 --- a/item/appitem.cpp +++ b/item/appitem.cpp @@ -4,14 +4,10 @@ #include #include -#define APP_STATUS_KEY "app-status" #define APP_ICON_KEY "icon" #define APP_MENU_KEY "menu" #define APP_XIDS_KEY "app-xids" -#define APP_ACTIVE_STATUS "active" -#define APP_NORMAL_STATUS "normal" - #define APP_DRAG_THRESHOLD 20 DBusClientManager *AppItem::ClientInter = nullptr; @@ -26,6 +22,8 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent) m_data = m_itemEntry->data(); + qDebug() << m_data; + connect(m_itemEntry, static_cast(&DBusDockEntry::DataChanged), this, &AppItem::entryDataChanged); } @@ -46,18 +44,18 @@ void AppItem::paintEvent(QPaintEvent *e) QPainter painter(this); - // draw current active background - if (m_windows.contains(ActiveWindowId)) - { - painter.fillRect(rect(), Qt::blue); - } else if (m_data[APP_STATUS_KEY] == APP_ACTIVE_STATUS) - { - // draw active background - painter.fillRect(rect(), Qt::cyan); - } else { - // draw normal background - painter.fillRect(rect(), Qt::gray); - } +// // draw current active background +// if (m_windows.contains(ActiveWindowId)) +// { +// painter.fillRect(rect(), Qt::blue); +// } else if (m_data[APP_STATUS_KEY] == APP_ACTIVE_STATUS) +// { +// // draw active background +// painter.fillRect(rect(), Qt::cyan); +// } else { +// // draw normal background +// painter.fillRect(rect(), Qt::gray); +// } // draw icon painter.fillRect(iconRect, Qt::yellow); @@ -126,9 +124,11 @@ void AppItem::initClientManager() void AppItem::entryDataChanged(const QString &key, const QString &value) { + qDebug() << "data chanegd" << key << value; + // update data m_data[key] = value; - if (key == APP_STATUS_KEY) +// if (key == APP_STATUS_KEY) return update(); }