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 {
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<QtObject> 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<QtObject> 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 {

View file

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