mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Add client manager interface
Change-Id: If18b5544e1e63afbf90d48469e18be651e852331
This commit is contained in:
parent
687336c4b8
commit
ee5641ab81
28
dbus/dbusclientmanager.cpp
Normal file
28
dbus/dbusclientmanager.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusClientManager -p dbusclientmanager dde-dock-ClientManager.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 "dbusclientmanager.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of interface class DBusClientManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
DBusClientManager::DBusClientManager(QObject *parent)
|
||||||
|
: QDBusAbstractInterface("com.deepin.daemon.Dock", "/dde/dock/ClientManager", staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusClientManager::~DBusClientManager()
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
89
dbus/dbusclientmanager.h
Normal file
89
dbus/dbusclientmanager.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -c DBusClientManager -p dbusclientmanager dde-dock-ClientManager.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 DBUSCLIENTMANAGER_H_1465195317
|
||||||
|
#define DBUSCLIENTMANAGER_H_1465195317
|
||||||
|
|
||||||
|
#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 dde.dock.ClientManager
|
||||||
|
*/
|
||||||
|
class DBusClientManager: 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 !="dde.dock.ClientManager")
|
||||||
|
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 "dde.dock.ClientManager"; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusClientManager(QObject *parent = 0);
|
||||||
|
|
||||||
|
~DBusClientManager();
|
||||||
|
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
inline QDBusPendingReply<bool> ActivateWindow(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ActivateWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<bool> CloseWindow(uint in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("CloseWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<uint> CurrentActiveWindow()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("CurrentActiveWindow"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void ActiveWindowChanged(uint activeWinId);
|
||||||
|
// begin property changed signals
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace dde {
|
||||||
|
namespace dock {
|
||||||
|
typedef ::DBusClientManager ClientManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
16
dbus/dde-dock-ClientManager.xml
Normal file
16
dbus/dde-dock-ClientManager.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<interface name="dde.dock.ClientManager">
|
||||||
|
<method name="ActivateWindow">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
<arg type="b" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="CloseWindow">
|
||||||
|
<arg type="u" direction="in"></arg>
|
||||||
|
<arg type="b" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="CurrentActiveWindow">
|
||||||
|
<arg type="u" direction="out"></arg>
|
||||||
|
</method>
|
||||||
|
<signal name="ActiveWindowChanged">
|
||||||
|
<arg type="u"></arg>
|
||||||
|
</signal>
|
||||||
|
</interface>
|
@ -17,7 +17,8 @@ SOURCES += main.cpp \
|
|||||||
dbus/dbusdisplay.cpp \
|
dbus/dbusdisplay.cpp \
|
||||||
item/appitem.cpp \
|
item/appitem.cpp \
|
||||||
util/docksettings.cpp \
|
util/docksettings.cpp \
|
||||||
item/placeholderitem.cpp
|
item/placeholderitem.cpp \
|
||||||
|
dbus/dbusclientmanager.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
window/mainwindow.h \
|
window/mainwindow.h \
|
||||||
@ -30,4 +31,5 @@ HEADERS += \
|
|||||||
dbus/dbusdisplay.h \
|
dbus/dbusdisplay.h \
|
||||||
item/appitem.h \
|
item/appitem.h \
|
||||||
util/docksettings.h \
|
util/docksettings.h \
|
||||||
item/placeholderitem.h
|
item/placeholderitem.h \
|
||||||
|
dbus/dbusclientmanager.h
|
||||||
|
@ -10,11 +10,14 @@
|
|||||||
#define APP_ACTIVE_STATUS "active"
|
#define APP_ACTIVE_STATUS "active"
|
||||||
#define APP_NORMAL_STATUS "normal"
|
#define APP_NORMAL_STATUS "normal"
|
||||||
|
|
||||||
|
DBusClientManager *AppItem::ClientInter = nullptr;
|
||||||
|
uint AppItem::ActiveWindowId = 0;
|
||||||
|
|
||||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||||
: DockItem(App, parent),
|
: DockItem(App, parent),
|
||||||
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
||||||
{
|
{
|
||||||
qDebug() << m_itemEntry->data();
|
initClientManager();
|
||||||
|
|
||||||
m_data = m_itemEntry->data();
|
m_data = m_itemEntry->data();
|
||||||
|
|
||||||
@ -35,11 +38,16 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
// draw active background
|
// draw current active background
|
||||||
if (m_data[APP_STATUS_KEY] == APP_ACTIVE_STATUS)
|
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);
|
painter.fillRect(rect(), Qt::cyan);
|
||||||
} else {
|
} else {
|
||||||
|
// draw normal background
|
||||||
painter.fillRect(rect(), Qt::gray);
|
painter.fillRect(rect(), Qt::gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +66,17 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
m_itemEntry->Activate();
|
m_itemEntry->Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppItem::initClientManager()
|
||||||
|
{
|
||||||
|
if (ClientInter)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ClientInter = new DBusClientManager(this);
|
||||||
|
connect(ClientInter, &DBusClientManager::ActiveWindowChanged, [&] (const uint wid) {
|
||||||
|
ActiveWindowId = wid;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void AppItem::entryDataChanged(const QString &key, const QString &value)
|
void AppItem::entryDataChanged(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
// update data
|
// update data
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "dockitem.h"
|
#include "dockitem.h"
|
||||||
#include "dbus/dbusdockentry.h"
|
#include "dbus/dbusdockentry.h"
|
||||||
|
#include "dbus/dbusclientmanager.h"
|
||||||
|
|
||||||
class AppItem : public DockItem
|
class AppItem : public DockItem
|
||||||
{
|
{
|
||||||
@ -15,13 +16,17 @@ private:
|
|||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e);
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e);
|
||||||
|
|
||||||
|
void initClientManager();
|
||||||
void entryDataChanged(const QString &key, const QString &value);
|
void entryDataChanged(const QString &key, const QString &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DBusDockEntry *m_itemEntry;
|
DBusDockEntry *m_itemEntry;
|
||||||
|
|
||||||
QMap<QString, QString> m_data;
|
QMap<QString, QString> m_data;
|
||||||
// QMap<uint, QString> m_windows;
|
QMap<uint, QString> m_windows;
|
||||||
|
|
||||||
|
static DBusClientManager *ClientInter;
|
||||||
|
static uint ActiveWindowId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPITEM_H
|
#endif // APPITEM_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user