-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set plugin visible Log:
- Loading branch information
wangfei
committed
Jul 5, 2024
1 parent
b92b515
commit 6ea1f29
Showing
7 changed files
with
174 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
//SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "dockdbusproxy.h" | ||
|
||
#include <QDBusConnection> | ||
#include <QDBusInterface> | ||
#include <QDBusMetaType> | ||
|
||
const static QString DockService = "org.deepin.dde.Dock1"; | ||
const static QString DockPath = "/org/deepin/dde/Dock1"; | ||
const static QString DockInterface = "org.deepin.dde.Dock1"; | ||
|
||
const static QString PropertiesInterface = "org.freedesktop.DBus.Properties"; | ||
const static QString PropertiesChanged = "PropertiesChanged"; | ||
|
||
QDBusArgument &operator<<(QDBusArgument &arg, const DockItemInfo &info) | ||
{ | ||
arg.beginStructure(); | ||
arg << info.name << info.displayName << info.itemKey << info.settingKey << info.dcc_icon << info.visible; | ||
arg.endStructure(); | ||
return arg; | ||
} | ||
|
||
const QDBusArgument &operator>>(const QDBusArgument &arg, DockItemInfo &info) | ||
{ | ||
arg.beginStructure(); | ||
arg >> info.name >> info.displayName >> info.itemKey >> info.settingKey >> info.dcc_icon >> info.visible; | ||
arg.endStructure(); | ||
return arg; | ||
} | ||
|
||
DockDBusProxy::DockDBusProxy(QObject *parent) | ||
: QObject(parent) | ||
, m_dockInter(new QDBusInterface(DockService, DockPath, DockInterface, QDBusConnection::sessionBus(), this)) | ||
{ | ||
QDBusConnection::sessionBus().connect(DockService, DockPath, DockInterface, "pluginVisibleChanged", this, SLOT(pluginVisibleChanged(const QString &, bool))); | ||
|
||
registerDockItemType(); | ||
} | ||
|
||
void DockDBusProxy::registerDockItemType() | ||
{ | ||
static bool isRegister = false; | ||
if (isRegister) | ||
return; | ||
|
||
qRegisterMetaType<DockItemInfo>("DockItemInfo"); | ||
qDBusRegisterMetaType<DockItemInfo>(); | ||
qRegisterMetaType<DockItemInfos>("DockItemInfos"); | ||
qDBusRegisterMetaType<DockItemInfos>(); | ||
isRegister = true; | ||
} | ||
|
||
QDBusPendingReply<DockItemInfos> DockDBusProxy::plugins() | ||
{ | ||
QDBusPendingReply<DockItemInfos> reply = m_dockInter->asyncCall(QStringLiteral("plugins")); | ||
reply.waitForFinished(); | ||
return reply; | ||
} | ||
|
||
QDBusPendingReply<> DockDBusProxy::setItemOnDock(const QString settingKey, const QString &itemKey, bool visible) | ||
{ | ||
QList<QVariant> argumengList; | ||
argumengList << settingKey << itemKey << QVariant::fromValue(visible); | ||
return m_dockInter->asyncCallWithArgumentList("setItemOnDock", argumengList); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
//SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef DOCKDBUSPROXY_H | ||
#define DOCKDBUSPROXY_H | ||
|
||
#include <QObject> | ||
#include <QDBusPendingReply> | ||
|
||
class QDBusInterface; | ||
class QDBusMessage; | ||
|
||
struct DockItemInfo | ||
{ | ||
QString name; | ||
QString displayName; | ||
QString itemKey; | ||
QString settingKey; | ||
QString dcc_icon; | ||
bool visible; | ||
}; | ||
|
||
QDBusArgument &operator<<(QDBusArgument &arg, const DockItemInfo &info); | ||
const QDBusArgument &operator>>(const QDBusArgument &arg, DockItemInfo &info); | ||
|
||
Q_DECLARE_METATYPE(DockItemInfo) | ||
|
||
typedef QList<DockItemInfo> DockItemInfos; | ||
|
||
Q_DECLARE_METATYPE(DockItemInfos) | ||
|
||
class DockDBusProxy : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DockDBusProxy(QObject *parent = nullptr); | ||
|
||
static void registerDockItemType(); | ||
|
||
public Q_SLOTS: | ||
QDBusPendingReply<DockItemInfos> plugins(); | ||
QDBusPendingReply<> setItemOnDock(const QString settingKey, const QString &itemKey, bool visible); | ||
|
||
Q_SIGNALS: | ||
void pluginVisibleChanged(const QString &itemKey, bool visible) const; | ||
|
||
private: | ||
QDBusInterface *m_dockInter; | ||
}; | ||
|
||
#endif // DOCKDBUSPROXY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters