Implement device renaming

This commit is contained in:
miruka
2020-06-25 12:11:11 -04:00
parent 3001131ffa
commit 51327d810b
3 changed files with 25 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ HTile {
property HListView view
signal renameDeviceRequest(string name)
backgroundColor: "transparent"
compact: false
@@ -81,6 +83,7 @@ HTile {
width: parent.width
defaultText: model.display_name
horizontalAlignment: Qt.AlignHCenter
onAccepted: renameDeviceRequest(text)
}
}

View File

@@ -29,6 +29,16 @@ HColumnPage {
})
}
function renameDevice(index, name) {
const device = deviceList.model.get(index)
device.display_name = name
py.callClientCoro(userId, "rename_device", [device.id, name], ok => {
if (! ok) deviceList.model.remove(index) // 404 happened
})
}
footer: ButtonLayout {
visible: height >= 0
@@ -67,6 +77,7 @@ HColumnPage {
delegate: DeviceDelegate {
width: deviceList.width
view: deviceList
onRenameDeviceRequest: name => renameDevice(model.index, name)
}
section.property: "type"