Fix/improve Security page offline account handling

This commit is contained in:
miruka 2020-09-20 16:01:02 -04:00
parent 755d954948
commit 38da930a99
3 changed files with 36 additions and 19 deletions

View File

@ -4,6 +4,12 @@
- PCN error handling - PCN error handling
- Change docs linking to dev branch back to master - Change docs linking to dev branch back to master
- Implement fallback QML notifications, usable if dbus isn't available
- annoying tooltips when menu open
- profiles missing in notifications
- add http_proxy support
- Encrypted rooms don't show invites in member list after Mirage restart
- Room display name not updated when someone removes theirs - Room display name not updated when someone removes theirs
- Fix right margin of own `<image url>\n<image url>` messages - Fix right margin of own `<image url>\n<image url>` messages

View File

@ -12,6 +12,7 @@ HTile {
property HListView view property HListView view
property string userId property string userId
property bool offline: false
signal verified() signal verified()
signal blacklisted() signal blacklisted()
@ -84,6 +85,7 @@ HTile {
label.horizontalAlignment: Qt.AlignHCenter label.horizontalAlignment: Qt.AlignHCenter
HRowLayout { HRowLayout {
enabled: ! deviceTile.offline
width: parent.width width: parent.width
HTextField { HTextField {
@ -166,6 +168,7 @@ HTile {
NegativeButton { NegativeButton {
text: qsTr("Sign out") text: qsTr("Sign out")
enabled: ! deviceTile.offline
icon.name: "device-delete" icon.name: "device-delete"
onClicked: deviceTile.deleteRequest() onClicked: deviceTile.deleteRequest()
} }

View File

@ -19,6 +19,9 @@ HColumnPage {
property Future loadFuture: null property Future loadFuture: null
readonly property QtObject account: ModelStore.get("accounts").find(userId)
readonly property bool offline: ! account || account.presence === "offline"
function takeFocus() { function takeFocus() {
deviceList.headerItem.exportButton.forceActiveFocus() deviceList.headerItem.exportButton.forceActiveFocus()
} }
@ -88,8 +91,12 @@ HColumnPage {
return counts return counts
} }
function focusListController(top=true) {
deviceList.currentIndex = top ? 0 : deviceList.count - 1
listController.forceActiveFocus()
}
enabled: ModelStore.get("accounts").find(userId).presence !== "offline"
contentHeight: Math.min( contentHeight: Math.min(
window.height, window.height,
Math.max( Math.max(
@ -114,6 +121,7 @@ HColumnPage {
header: HColumnLayout { header: HColumnLayout {
readonly property alias exportButton: exportButton readonly property alias exportButton: exportButton
readonly property alias importButton: importButton
readonly property alias signOutCheckedButton: signOutCheckedButton readonly property alias signOutCheckedButton: signOutCheckedButton
spacing: theme.spacing spacing: theme.spacing
@ -160,13 +168,11 @@ HColumnPage {
} }
) )
Keys.onBacktabPressed: { Keys.onBacktabPressed: page.focusListController(false)
deviceList.currentIndex = deviceList.count - 1
listController.forceActiveFocus()
}
} }
GroupButton { GroupButton {
id: importButton
text: qsTr("Import") text: qsTr("Import")
icon.name: "import-keys" icon.name: "import-keys"
@ -176,6 +182,11 @@ HColumnPage {
{ userId: page.userId }, { userId: page.userId },
obj => { obj.dialog.open() } obj => { obj.dialog.open() }
) )
Keys.onTabPressed:
signOutCheckedButton.enabled ?
refreshButton.forceActiveFocus() :
page.focusListController()
} }
} }
@ -199,6 +210,8 @@ HColumnPage {
} }
AutoDirectionLayout { AutoDirectionLayout {
enabled: ! page.offline
GroupButton { GroupButton {
id: refreshButton id: refreshButton
text: qsTr("Refresh") text: qsTr("Refresh")
@ -222,10 +235,7 @@ HColumnPage {
...utils.range(1, deviceList.count - 1), ...utils.range(1, deviceList.count - 1),
) )
Keys.onTabPressed: { Keys.onTabPressed: page.focusListController()
deviceList.currentIndex = 0
listController.forceActiveFocus()
}
} }
} }
} }
@ -234,6 +244,7 @@ HColumnPage {
width: deviceList.width width: deviceList.width
view: deviceList view: deviceList
userId: page.userId userId: page.userId
offline: page.offline
onVerified: page.loadDevices() onVerified: page.loadDevices()
onBlacklisted: page.loadDevices() onBlacklisted: page.loadDevices()
onRenameRequest: name => page.renameDevice(model.index, name) onRenameRequest: name => page.renameDevice(model.index, name)
@ -257,15 +268,8 @@ HColumnPage {
Keys.onReturnPressed: Keys.onEnterPressed(event) Keys.onReturnPressed: Keys.onEnterPressed(event)
Keys.onMenuPressed: Keys.onEnterPressed(event) Keys.onMenuPressed: Keys.onEnterPressed(event)
Keys.onUpPressed: { Keys.onUpPressed: page.focusListController(false)
deviceList.currentIndex = deviceList.count - 1 Keys.onDownPressed: page.focusListController()
listController.forceActiveFocus()
}
Keys.onDownPressed: {
deviceList.currentIndex = 0
listController.forceActiveFocus()
}
Item { Item {
id: listController id: listController
@ -273,7 +277,11 @@ HColumnPage {
Keys.onBacktabPressed: { Keys.onBacktabPressed: {
if (parent.currentIndex === 0) { if (parent.currentIndex === 0) {
parent.currentIndex = -1 parent.currentIndex = -1
parent.headerItem.signOutCheckedButton.forceActiveFocus()
parent.headerItem.signOutCheckedButton.enabled ?
parent.headerItem.signOutCheckedButton.forceActiveFocus() :
parent.headerItem.importButton.forceActiveFocus()
return return
} }
parent.decrementCurrentIndex() parent.decrementCurrentIndex()