From f345b058383bb66aafa6d56ea38c47d8938f0182 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 13 Feb 2019 18:16:41 +0100 Subject: [PATCH] Use ListView for plugins list --- app/qml/DevicePage.qml | 125 +++++++++++++++++++++-------------------- app/qml/PluginItem.qml | 10 ++-- 2 files changed, 70 insertions(+), 65 deletions(-) diff --git a/app/qml/DevicePage.qml b/app/qml/DevicePage.qml index 165c268d7..e508d3298 100644 --- a/app/qml/DevicePage.qml +++ b/app/qml/DevicePage.qml @@ -40,8 +40,6 @@ Kirigami.Page Loader { id: deviceLoader anchors.fill: parent - Layout.fillHeight: true - Layout.fillWidth: true sourceComponent: { if (deviceView.currentDevice.hasPairingRequests) { @@ -61,7 +59,7 @@ Kirigami.Page Component { id: trustedDevice - ColumnLayout { + ListView { property list actions: [ Kirigami.Action { onTriggered: deviceView.currentDevice.unpair() @@ -76,67 +74,74 @@ Kirigami.Page ] id: trustedView - spacing: 0 - Layout.fillHeight: true Layout.fillWidth: true - PluginItem { - label: i18n("Multimedia control") - interfaceFactory: MprisDbusInterfaceFactory - component: "qrc:/qml/mpris.qml" - pluginName: "mprisremote" - } - PluginItem { - label: i18n("Remote input") - interfaceFactory: RemoteControlDbusInterfaceFactory - component: "qrc:/qml/mousepad.qml" - pluginName: "remotecontrol" - } - PluginItem { - label: i18n("Presentation Remote") - interfaceFactory: RemoteKeyboardDbusInterfaceFactory - component: "qrc:/qml/presentationRemote.qml" - pluginName: "remotecontrol" - } - PluginItem { - readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id()) - pluginName: "lockdevice" - label: lockIface.isLocked ? i18n("Unlock") : i18n("Lock") - onClicked: { - lockIface.isLocked = !lockIface.isLocked; - } - } - PluginItem { - readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(deviceView.currentDevice.id()) - pluginName: "findmyphone" - label: i18n("Find Device") - onClicked: { - findmyphoneIface.ring() - } - } - PluginItem { - label: i18n("Run command") - interfaceFactory: RemoteCommandsDbusInterfaceFactory - component: "qrc:/qml/runcommand.qml" - pluginName: "remotecommands" - } - PluginItem { - readonly property var shareIface: ShareDbusInterfaceFactory.create(deviceView.currentDevice.id()) - pluginName: "share" - label: i18n("Share File") - onClicked: { - fileDialog.open() - shareIface.shareUrl(fileDialog.fileUrl) - } - } - PluginItem { - label: i18n("Volume control") - interfaceFactory: RemoteSystemVolumeDbusInterfaceFactory - component: "qrc:/qml/volume.qml" - pluginName: "remotesystemvolume" + model: plugins + delegate: Kirigami.BasicListItem { + label: name + icon: iconName + visible: loaded + onClicked: onClick() } - Item { Layout.fillHeight: true } + property list plugins : [ + + PluginItem { + name: i18n("Multimedia control") + interfaceFactory: MprisDbusInterfaceFactory + component: "qrc:/qml/mpris.qml" + pluginName: "mprisremote" + }, + PluginItem { + name: i18n("Remote input") + interfaceFactory: RemoteControlDbusInterfaceFactory + component: "qrc:/qml/mousepad.qml" + pluginName: "remotecontrol" + }, + PluginItem { + name: i18n("Presentation Remote") + interfaceFactory: RemoteKeyboardDbusInterfaceFactory + component: "qrc:/qml/presentationRemote.qml" + pluginName: "remotecontrol" + }, + PluginItem { + readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id()) + pluginName: "lockdevice" + name: lockIface.isLocked ? i18n("Unlock") : i18n("Lock") + onClick: function() { + lockIface.isLocked = !lockIface.isLocked; + } + }, + PluginItem { + readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(deviceView.currentDevice.id()) + pluginName: "findmyphone" + name: i18n("Find Device") + onClick: function() { + findmyphoneIface.ring() + } + }, + PluginItem { + name: i18n("Run command") + interfaceFactory: RemoteCommandsDbusInterfaceFactory + component: "qrc:/qml/runcommand.qml" + pluginName: "remotecommands" + }, + PluginItem { + readonly property var shareIface: ShareDbusInterfaceFactory.create(deviceView.currentDevice.id()) + pluginName: "share" + name: i18n("Share File") + onClick: function() { + fileDialog.open() + shareIface.shareUrl(fileDialog.fileUrl) + } + }, + PluginItem { + name: i18n("Volume control") + interfaceFactory: RemoteSystemVolumeDbusInterfaceFactory + component: "qrc:/qml/volume.qml" + pluginName: "remotesystemvolume" + } + ] } } Component { diff --git a/app/qml/PluginItem.qml b/app/qml/PluginItem.qml index b4185e126..d34732695 100644 --- a/app/qml/PluginItem.qml +++ b/app/qml/PluginItem.qml @@ -24,20 +24,20 @@ import QtQuick.Layouts 1.1 import org.kde.kirigami 2.0 as Kirigami import org.kde.kdeconnect 1.0 -Kirigami.BasicListItem +QtObject { property alias pluginName: checker.pluginName + property alias iconName: checker.iconName + property alias loaded: checker.available property var interfaceFactory property var component + property var name readonly property var checker: PluginChecker { id: checker device: deviceView.currentDevice } - visible: checker.available - icon: checker.iconName - iconColor: "transparent" - onClicked: { + property var onClick: function() { if (component === "" || !interfaceFactory) return;