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
This commit is contained in:
Nicolas Fella 2018-08-03 01:53:21 +02:00
parent d9f427aaeb
commit e4385042eb
9 changed files with 33 additions and 5 deletions

View file

@ -35,6 +35,7 @@ Kirigami.BasicListItem
device: deviceView.currentDevice
}
visible: checker.available
icon: checker.iconName
onClicked: {
if (component === "" || !interfaceFactory)
return;

View file

@ -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();
}

View file

@ -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);

View file

@ -28,6 +28,7 @@ struct KdeConnectPluginPrivate
QString m_pluginName;
QSet<QString> 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;
}

View file

@ -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

View file

@ -76,7 +76,7 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin
QVariant deviceVariant = QVariant::fromValue<Device*>(device);
ret = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << pluginName << outgoingInterfaces);
ret = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << pluginName << outgoingInterfaces << service.iconName());
if (!ret) {
qCDebug(KDECONNECT_CORE) << "Error loading plugin";
return ret;

View file

@ -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 = "" }
}
}

View file

@ -46,7 +46,7 @@
"Description[zh_CN]": "锁定您的系统",
"Description[zh_TW]": "鎖定您的系統",
"EnabledByDefault": true,
"Icon": "applications-miscelaneaous",
"Icon": "lock",
"Id": "kdeconnect_lockdevice",
"License": "GPL",
"Name": "LockDevice",

View file

@ -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",