From 213867750d83408b84a43b8c5c500fe60a6bbcc9 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 26 Jun 2020 04:30:47 -0400 Subject: [PATCH] Add unimplemented auth popup for deleting devices --- .../Pages/AccountSettings/DeviceDelegate.qml | 6 ++-- src/gui/Pages/AccountSettings/Sessions.qml | 31 +++++++++++++++---- src/gui/Popups/AuthentificationPopup.qml | 25 +++++++++++++++ 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 src/gui/Popups/AuthentificationPopup.qml diff --git a/src/gui/Pages/AccountSettings/DeviceDelegate.qml b/src/gui/Pages/AccountSettings/DeviceDelegate.qml index ff68f37d..9131b235 100644 --- a/src/gui/Pages/AccountSettings/DeviceDelegate.qml +++ b/src/gui/Pages/AccountSettings/DeviceDelegate.qml @@ -16,6 +16,7 @@ HTile { signal verified() signal blacklisted() signal renameRequest(string name) + signal deleteRequest() backgroundColor: "transparent" @@ -89,7 +90,7 @@ HTile { defaultText: model.display_name maximumLength: 255 horizontalAlignment: Qt.AlignHCenter - onAccepted: renameRequest(text) + onAccepted: deviceTile.renameRequest(text) Layout.fillWidth: true } @@ -97,7 +98,7 @@ HTile { HButton { icon.name: "apply" icon.color: theme.colors.positiveBackground - onClicked: renameRequest(nameField.text) + onClicked: deviceTile.renameRequest(nameField.text) Layout.fillHeight: true } @@ -167,6 +168,7 @@ HTile { CancelButton { text: qsTr("Sign out") icon.name: "device-delete" + onClicked: deviceTile.deleteRequest() } } } diff --git a/src/gui/Pages/AccountSettings/Sessions.qml b/src/gui/Pages/AccountSettings/Sessions.qml index cce1d565..a4d9c8c3 100644 --- a/src/gui/Pages/AccountSettings/Sessions.qml +++ b/src/gui/Pages/AccountSettings/Sessions.qml @@ -26,11 +26,8 @@ HColumnPage { property Future loadFuture: null - // property var pr: column.childrenRect.height - // onPrChanged: print("pr changed:", pr, deviceList.implicitHeight) - - function takeFocus() {} // XXX + function takeFocus() {} // TODO function loadDevices() { loadFuture = py.callClientCoro(userId, "devices_info", [], devices => { @@ -55,6 +52,22 @@ HColumnPage { }) } + function deleteDevices(...indice) { + const deviceIds = [] + + for (const i of indice.sort()) + deviceIds.push(deviceList.model.get(i).id) + + utils.makePopup( + "Popups/AuthentificationPopup.qml", + page, + { + userId: page.userId, + deviceIds, + }, + ) + } + function getSectionItemCounts() { const counts = {} @@ -71,10 +84,11 @@ HColumnPage { OtherButton { text: qsTr("Refresh") icon.name: "device-refresh-list" - onClicked: loadDevices() + onClicked: page.loadDevices() } OtherButton { + enabled: deviceList.model.count > 0 text: deviceList.selectedCount === 0 ? qsTr("Sign out all") : @@ -84,6 +98,10 @@ HColumnPage { icon.name: "device-delete-checked" icon.color: theme.colors.negativeBackground + onClicked: + deviceList.selectedCount ? + page.deleteDevices(...deviceList.checkedIndice) : + page.deleteDevices(...utils.range(1, deviceList.count - 1)) } } @@ -103,7 +121,8 @@ HColumnPage { userId: page.userId onVerified: page.loadDevices() onBlacklisted: page.loadDevices() - onRenameRequest: name => renameDevice(model.index, name) + onRenameRequest: name => page.renameDevice(model.index, name) + onDeleteRequest: page.deleteDevices(model.index) } section.property: "type" diff --git a/src/gui/Popups/AuthentificationPopup.qml b/src/gui/Popups/AuthentificationPopup.qml new file mode 100644 index 00000000..929d0d63 --- /dev/null +++ b/src/gui/Popups/AuthentificationPopup.qml @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later + +import QtQuick 2.12 +import "../Base" +import "../Base/ButtonLayout" + +HFlickableColumnPopup { + id: popup + + + property string userId + property string deviceIds + + + page.footer: ButtonLayout { + CancelButton { + id: cancelButton + onClicked: popup.close() + } + } + + onOpened: cancelButton.forceActiveFocus() + + SummaryLabel { text: qsTr("Not implemented yet") } +}