From e4385042ebe62dcb60055e538e9555f43d5394b8 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Fri, 3 Aug 2018 01:53:21 +0200 Subject: [PATCH] Show icons in plugin list Summary: Show the plugin's icons in the list Depends on D14567 {F6172885} Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D14571 --- app/qml/PluginItem.qml | 1 + core/device.cpp | 7 +++++++ core/device.h | 1 + core/kdeconnectplugin.cpp | 7 +++++++ core/kdeconnectplugin.h | 2 ++ core/pluginloader.cpp | 2 +- declarativeplugin/qml/PluginChecker.qml | 14 ++++++++++++-- plugins/lockdevice/kdeconnect_lockdevice.json | 2 +- .../remotecontrol/kdeconnect_remotecontrol.json | 2 +- 9 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/qml/PluginItem.qml b/app/qml/PluginItem.qml index d47019086..f73649bf0 100644 --- a/app/qml/PluginItem.qml +++ b/app/qml/PluginItem.qml @@ -35,6 +35,7 @@ Kirigami.BasicListItem device: deviceView.currentDevice } visible: checker.available + icon: checker.iconName onClicked: { if (component === "" || !interfaceFactory) return; diff --git a/core/device.cpp b/core/device.cpp index 5cd095d94..8f5805e84 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -547,3 +547,10 @@ QString Device::encryptionInfo() const return result; } +QString Device::pluginIconName(const QString& pluginName) +{ + if (hasPlugin(pluginName)) { + return d->m_plugins[pluginName]->iconName(); + } + return QString(); +} diff --git a/core/device.h b/core/device.h index 0621e2912..0c79b2a3d 100644 --- a/core/device.h +++ b/core/device.h @@ -120,6 +120,7 @@ public Q_SLOTS: Q_SCRIPTABLE void rejectPairing(); Q_SCRIPTABLE bool hasPairingRequests() const; + Q_SCRIPTABLE QString pluginIconName(const QString& pluginName); private Q_SLOTS: void privateReceivedPacket(const NetworkPacket& np); void linkDestroyed(QObject* o); diff --git a/core/kdeconnectplugin.cpp b/core/kdeconnectplugin.cpp index 582c1fea3..e5bc39284 100644 --- a/core/kdeconnectplugin.cpp +++ b/core/kdeconnectplugin.cpp @@ -28,6 +28,7 @@ struct KdeConnectPluginPrivate QString m_pluginName; QSet m_outgoingCapabilties; KdeConnectPluginConfig* m_config; + QString iconName; }; KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args) @@ -38,6 +39,7 @@ KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args) d->m_pluginName = args.at(1).toString(); d->m_outgoingCapabilties = args.at(2).toStringList().toSet(); d->m_config = nullptr; + d->iconName = args.at(3).toString(); } KdeConnectPluginConfig* KdeConnectPlugin::config() const @@ -80,3 +82,8 @@ QString KdeConnectPlugin::dbusPath() const { return {}; } + +QString KdeConnectPlugin::iconName() const +{ + return d->iconName; +} diff --git a/core/kdeconnectplugin.h b/core/kdeconnectplugin.h index 169a4ddca..2dac69a7c 100644 --- a/core/kdeconnectplugin.h +++ b/core/kdeconnectplugin.h @@ -49,6 +49,8 @@ public: virtual QString dbusPath() const; + QString iconName() const; + public Q_SLOTS: /** * Returns true if it has handled the packet in some way diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp index f29ca7306..39636bfff 100644 --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -76,7 +76,7 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin QVariant deviceVariant = QVariant::fromValue(device); - ret = factory->create(device, QVariantList() << deviceVariant << pluginName << outgoingInterfaces); + ret = factory->create(device, QVariantList() << deviceVariant << pluginName << outgoingInterfaces << service.iconName()); if (!ret) { qCDebug(KDECONNECT_CORE) << "Error loading plugin"; return ret; diff --git a/declarativeplugin/qml/PluginChecker.qml b/declarativeplugin/qml/PluginChecker.qml index dfd1114e7..93f12c055 100644 --- a/declarativeplugin/qml/PluginChecker.qml +++ b/declarativeplugin/qml/PluginChecker.qml @@ -29,6 +29,7 @@ QtObject { property alias device: conn.target property string pluginName: "" property bool available: false + property string iconName: "" readonly property Connections connection: Connections { id: conn @@ -38,13 +39,22 @@ QtObject { Component.onCompleted: pluginsChanged() readonly property var v: DBusAsyncResponse { - id: response + id: availableResponse autoDelete: false onSuccess: { root.available = result; } onError: { root.available = false } } function pluginsChanged() { - response.setPendingCall(device.hasPlugin("kdeconnect_" + pluginName)) + availableResponse.setPendingCall(device.hasPlugin("kdeconnect_" + pluginName)) + iconResponse.setPendingCall(device.pluginIconName("kdeconnect_" + pluginName)) + + } + + readonly property var vv: DBusAsyncResponse { + id: iconResponse + autoDelete: false + onSuccess: { root.iconName = result; } + onError: { root.iconName = "" } } } diff --git a/plugins/lockdevice/kdeconnect_lockdevice.json b/plugins/lockdevice/kdeconnect_lockdevice.json index fd481a33e..12ff30efc 100644 --- a/plugins/lockdevice/kdeconnect_lockdevice.json +++ b/plugins/lockdevice/kdeconnect_lockdevice.json @@ -46,7 +46,7 @@ "Description[zh_CN]": "锁定您的系统", "Description[zh_TW]": "鎖定您的系統", "EnabledByDefault": true, - "Icon": "applications-miscelaneaous", + "Icon": "lock", "Id": "kdeconnect_lockdevice", "License": "GPL", "Name": "LockDevice", diff --git a/plugins/remotecontrol/kdeconnect_remotecontrol.json b/plugins/remotecontrol/kdeconnect_remotecontrol.json index db44e177c..baadb6a9b 100644 --- a/plugins/remotecontrol/kdeconnect_remotecontrol.json +++ b/plugins/remotecontrol/kdeconnect_remotecontrol.json @@ -46,7 +46,7 @@ "Description[zh_CN]": "控制远程系统", "Description[zh_TW]": "控制遠端系統", "EnabledByDefault": true, - "Icon": "applications-multimedia", + "Icon": "edit-select", "Id": "kdeconnect_remotecontrol", "License": "GPL", "Name": "RemoteControl",