Add account logout feature via context menu

This commit is contained in:
miruka
2019-08-21 17:45:05 -04:00
parent 7331c1fa1c
commit b8d43ecfec
7 changed files with 47 additions and 15 deletions

View File

@@ -21,7 +21,7 @@ HPage {
onRoomInfoChanged: {
if (roomInfo.left) {
// The room will most likely be gone on client restart
// If left, the room will most likely be gone on client restart
window.uiState.page = "Pages/Default.qml"
window.uiState.pageProperties = {}
window.uiStateChanged()

View File

@@ -25,6 +25,7 @@ HPage {
Utils.coloredNameHtml(headerName, userId)
)
HSpacer {}
Repeater {

View File

@@ -19,6 +19,7 @@ HTileDelegate {
Behavior on opacity { HNumberAnimation {} }
property bool disconnecting: false
readonly property bool forceExpand: Boolean(accountRoomList.filter)
// Hide harmless error when a filter matches nothing
@@ -27,9 +28,11 @@ HTileDelegate {
} catch (err) {}
onActivated: pageLoader.showPage(
"EditAccount/EditAccount", { "userId": model.data.user_id }
)
onActivated: if (! disconnecting) {
pageLoader.showPage(
"EditAccount/EditAccount", { "userId": model.data.user_id }
)
}
function toggleCollapse() {
@@ -70,4 +73,29 @@ HTileDelegate {
Behavior on opacity { HNumberAnimation {} }
}
contextMenu: HMenu {
HMenuItem {
icon.name: "logout"
text: qsTr("Logout")
onTriggered: {
disconnecting = true
let page = window.uiState.page
let userId = model.data.user_id
if ((modelSources["Account"] || []).length < 2) {
pageLoader.showPage("SignIn")
}
else if ((page == "Pages/EditAccount/EditAccount.qml" ||
page == "Chat/Chat.qml") &&
window.uiState.pageProperties.userId == userId)
{
pageLoader.showPage("Default")
}
py.callCoro("logout_client", [userId])
}
}
}
}