Use ListView for plugins list

This commit is contained in:
Nicolas Fella 2019-02-13 18:16:41 +01:00
parent 7970e3d1c4
commit f345b05838
2 changed files with 70 additions and 65 deletions

View file

@ -40,8 +40,6 @@ Kirigami.Page
Loader { Loader {
id: deviceLoader id: deviceLoader
anchors.fill: parent anchors.fill: parent
Layout.fillHeight: true
Layout.fillWidth: true
sourceComponent: { sourceComponent: {
if (deviceView.currentDevice.hasPairingRequests) { if (deviceView.currentDevice.hasPairingRequests) {
@ -61,7 +59,7 @@ Kirigami.Page
Component { Component {
id: trustedDevice id: trustedDevice
ColumnLayout { ListView {
property list<QtObject> actions: [ property list<QtObject> actions: [
Kirigami.Action { Kirigami.Action {
onTriggered: deviceView.currentDevice.unpair() onTriggered: deviceView.currentDevice.unpair()
@ -76,67 +74,74 @@ Kirigami.Page
] ]
id: trustedView id: trustedView
spacing: 0
Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
model: plugins
delegate: Kirigami.BasicListItem {
label: name
icon: iconName
visible: loaded
onClicked: onClick()
}
property list<QtObject> plugins : [
PluginItem { PluginItem {
label: i18n("Multimedia control") name: i18n("Multimedia control")
interfaceFactory: MprisDbusInterfaceFactory interfaceFactory: MprisDbusInterfaceFactory
component: "qrc:/qml/mpris.qml" component: "qrc:/qml/mpris.qml"
pluginName: "mprisremote" pluginName: "mprisremote"
} },
PluginItem { PluginItem {
label: i18n("Remote input") name: i18n("Remote input")
interfaceFactory: RemoteControlDbusInterfaceFactory interfaceFactory: RemoteControlDbusInterfaceFactory
component: "qrc:/qml/mousepad.qml" component: "qrc:/qml/mousepad.qml"
pluginName: "remotecontrol" pluginName: "remotecontrol"
} },
PluginItem { PluginItem {
label: i18n("Presentation Remote") name: i18n("Presentation Remote")
interfaceFactory: RemoteKeyboardDbusInterfaceFactory interfaceFactory: RemoteKeyboardDbusInterfaceFactory
component: "qrc:/qml/presentationRemote.qml" component: "qrc:/qml/presentationRemote.qml"
pluginName: "remotecontrol" pluginName: "remotecontrol"
} },
PluginItem { PluginItem {
readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id()) readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id())
pluginName: "lockdevice" pluginName: "lockdevice"
label: lockIface.isLocked ? i18n("Unlock") : i18n("Lock") name: lockIface.isLocked ? i18n("Unlock") : i18n("Lock")
onClicked: { onClick: function() {
lockIface.isLocked = !lockIface.isLocked; lockIface.isLocked = !lockIface.isLocked;
} }
} },
PluginItem { PluginItem {
readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(deviceView.currentDevice.id()) readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(deviceView.currentDevice.id())
pluginName: "findmyphone" pluginName: "findmyphone"
label: i18n("Find Device") name: i18n("Find Device")
onClicked: { onClick: function() {
findmyphoneIface.ring() findmyphoneIface.ring()
} }
} },
PluginItem { PluginItem {
label: i18n("Run command") name: i18n("Run command")
interfaceFactory: RemoteCommandsDbusInterfaceFactory interfaceFactory: RemoteCommandsDbusInterfaceFactory
component: "qrc:/qml/runcommand.qml" component: "qrc:/qml/runcommand.qml"
pluginName: "remotecommands" pluginName: "remotecommands"
} },
PluginItem { PluginItem {
readonly property var shareIface: ShareDbusInterfaceFactory.create(deviceView.currentDevice.id()) readonly property var shareIface: ShareDbusInterfaceFactory.create(deviceView.currentDevice.id())
pluginName: "share" pluginName: "share"
label: i18n("Share File") name: i18n("Share File")
onClicked: { onClick: function() {
fileDialog.open() fileDialog.open()
shareIface.shareUrl(fileDialog.fileUrl) shareIface.shareUrl(fileDialog.fileUrl)
} }
} },
PluginItem { PluginItem {
label: i18n("Volume control") name: i18n("Volume control")
interfaceFactory: RemoteSystemVolumeDbusInterfaceFactory interfaceFactory: RemoteSystemVolumeDbusInterfaceFactory
component: "qrc:/qml/volume.qml" component: "qrc:/qml/volume.qml"
pluginName: "remotesystemvolume" pluginName: "remotesystemvolume"
} }
]
Item { Layout.fillHeight: true }
} }
} }
Component { Component {

View file

@ -24,20 +24,20 @@ import QtQuick.Layouts 1.1
import org.kde.kirigami 2.0 as Kirigami import org.kde.kirigami 2.0 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
Kirigami.BasicListItem QtObject
{ {
property alias pluginName: checker.pluginName property alias pluginName: checker.pluginName
property alias iconName: checker.iconName
property alias loaded: checker.available
property var interfaceFactory property var interfaceFactory
property var component property var component
property var name
readonly property var checker: PluginChecker { readonly property var checker: PluginChecker {
id: checker id: checker
device: deviceView.currentDevice device: deviceView.currentDevice
} }
visible: checker.available property var onClick: function() {
icon: checker.iconName
iconColor: "transparent"
onClicked: {
if (component === "" || !interfaceFactory) if (component === "" || !interfaceFactory)
return; return;