[app] Rework device page
To achive the proper scrolling behaviour it needs to be a ScrollablePage. In order to do that correctly the listview needs to be the direct content item of the page. Therefore we need to get rid of the loader and the various placeholder messages are parented to the listview.
This commit is contained in:
parent
0c32010a28
commit
151f829308
2 changed files with 116 additions and 153 deletions
|
@ -25,58 +25,30 @@ import QtQuick.Dialogs 1.0
|
|||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kdeconnect 1.0
|
||||
|
||||
Kirigami.Page
|
||||
Kirigami.ScrollablePage
|
||||
{
|
||||
id: deviceView
|
||||
id: root
|
||||
property QtObject currentDevice
|
||||
title: currentDevice.name
|
||||
|
||||
actions.contextualActions: deviceLoader.item.actions
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
Loader {
|
||||
id: deviceLoader
|
||||
anchors.fill: parent
|
||||
|
||||
sourceComponent: {
|
||||
if (deviceView.currentDevice.hasPairingRequests) {
|
||||
return pairDevice;
|
||||
}
|
||||
|
||||
if (deviceView.currentDevice.isReachable) {
|
||||
if (deviceView.currentDevice.isTrusted) {
|
||||
return trustedDevice;
|
||||
} else {
|
||||
return untrustedDevice;
|
||||
}
|
||||
} else {
|
||||
return notReachableDevice;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: trustedDevice
|
||||
ListView {
|
||||
property list<QtObject> actions: [
|
||||
actions.contextualActions: [
|
||||
Kirigami.Action {
|
||||
iconName:"network-disconnect"
|
||||
onTriggered: deviceView.currentDevice.unpair()
|
||||
onTriggered: root.currentDevice.unpair()
|
||||
text: i18nd("kdeconnect-app", "Unpair")
|
||||
visible: root.currentDevice.isTrusted
|
||||
},
|
||||
Kirigami.Action {
|
||||
iconName:"hands-free"
|
||||
text: i18nd("kdeconnect-app", "Send Ping")
|
||||
visible: root.currentDevice.isTrusted && root.currentDevice.isReachable
|
||||
onTriggered: {
|
||||
deviceView.currentDevice.pluginCall("ping", "sendPing");
|
||||
root.currentDevice.pluginCall("ping", "sendPing");
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
id: trustedView
|
||||
Layout.fillWidth: true
|
||||
ListView {
|
||||
|
||||
model: plugins
|
||||
delegate: Kirigami.BasicListItem {
|
||||
|
@ -95,104 +67,95 @@ Kirigami.Page
|
|||
interfaceFactory: MprisDbusInterfaceFactory
|
||||
component: "qrc:/qml/mpris.qml"
|
||||
pluginName: "mprisremote"
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
name: i18nd("kdeconnect-app", "Remote input")
|
||||
interfaceFactory: RemoteControlDbusInterfaceFactory
|
||||
component: "qrc:/qml/mousepad.qml"
|
||||
pluginName: "remotecontrol"
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
name: i18nd("kdeconnect-app", "Presentation Remote")
|
||||
interfaceFactory: RemoteKeyboardDbusInterfaceFactory
|
||||
component: "qrc:/qml/presentationRemote.qml"
|
||||
pluginName: "remotecontrol"
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id())
|
||||
readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(root.currentDevice.id())
|
||||
pluginName: "lockdevice"
|
||||
name: lockIface.isLocked ? i18nd("kdeconnect-app", "Unlock") : i18nd("kdeconnect-app", "Lock")
|
||||
onClick: function() {
|
||||
lockIface.isLocked = !lockIface.isLocked;
|
||||
}
|
||||
onClick: () => lockIface.isLocked = !lockIface.isLocked;
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(deviceView.currentDevice.id())
|
||||
readonly property var findmyphoneIface: FindMyPhoneDbusInterfaceFactory.create(root.currentDevice.id())
|
||||
pluginName: "findmyphone"
|
||||
name: i18nd("kdeconnect-app", "Find Device")
|
||||
onClick: function() {
|
||||
findmyphoneIface.ring()
|
||||
}
|
||||
onClick: () => findmyphoneIface.ring()
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
name: i18nd("kdeconnect-app", "Run command")
|
||||
interfaceFactory: RemoteCommandsDbusInterfaceFactory
|
||||
component: "qrc:/qml/runcommand.qml"
|
||||
pluginName: "remotecommands"
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
readonly property var shareIface: ShareDbusInterfaceFactory.create(deviceView.currentDevice.id())
|
||||
readonly property var shareIface: ShareDbusInterfaceFactory.create(root.currentDevice.id())
|
||||
pluginName: "share"
|
||||
name: i18nd("kdeconnect-app", "Share File")
|
||||
onClick: function() {
|
||||
onClick: () => {
|
||||
fileDialog.open()
|
||||
shareIface.shareUrl(fileDialog.fileUrl)
|
||||
}
|
||||
device: root.currentDevice
|
||||
},
|
||||
PluginItem {
|
||||
name: i18nd("kdeconnect-app", "Volume control")
|
||||
interfaceFactory: RemoteSystemVolumeDbusInterfaceFactory
|
||||
component: "qrc:/qml/volume.qml"
|
||||
pluginName: "remotesystemvolume"
|
||||
device: root.currentDevice
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: untrustedDevice
|
||||
Item {
|
||||
readonly property var actions: []
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
text: i18nd("kdeconnect-app", "This device is not paired")
|
||||
anchors.centerIn: parent
|
||||
visible: root.currentDevice.isReachable && !root.currentDevice.isTrusted && !root.currentDevice.hasPairingRequests
|
||||
helpfulAction: Kirigami.Action {
|
||||
text: i18nd("kdeconnect-app", "Pair")
|
||||
icon.name:"network-connect"
|
||||
onTriggered: deviceView.currentDevice.requestPair()
|
||||
onTriggered: root.currentDevice.requestPair()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: pairDevice
|
||||
Item {
|
||||
readonly property var actions: []
|
||||
|
||||
RowLayout {
|
||||
visible: root.currentDevice.hasPairingRequests
|
||||
anchors.centerIn: parent
|
||||
Button {
|
||||
text: i18nd("kdeconnect-app", "Accept")
|
||||
icon.name:"dialog-ok"
|
||||
onClicked: deviceView.currentDevice.acceptPairing()
|
||||
onClicked: root.currentDevice.acceptPairing()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: i18nd("kdeconnect-app", "Reject")
|
||||
icon.name:"dialog-cancel"
|
||||
onClicked: deviceView.currentDevice.rejectPairing()
|
||||
}
|
||||
}
|
||||
onClicked: root.currentDevice.rejectPairing()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: notReachableDevice
|
||||
Kirigami.PlaceholderMessage {
|
||||
visible: !root.currentDevice.isReachable
|
||||
text: i18nd("kdeconnect-app", "This device is not reachable")
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
|
|
|
@ -29,15 +29,15 @@ QtObject
|
|||
property alias pluginName: checker.pluginName
|
||||
property alias iconName: checker.iconName
|
||||
property alias loaded: checker.available
|
||||
property alias device: checker.device
|
||||
property var interfaceFactory
|
||||
property var component
|
||||
property var name
|
||||
|
||||
readonly property var checker: PluginChecker {
|
||||
id: checker
|
||||
device: deviceView.currentDevice
|
||||
}
|
||||
property var onClick: function() {
|
||||
property var onClick: () => {
|
||||
if (component === "" || !interfaceFactory)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue