Fix room list highlight when going to account page

Correctly set it when going to an account settings or add chat page by
using the account context menu, the add chat button or keybinds.
This commit is contained in:
miruka 2020-07-10 10:29:32 -04:00
parent 5abdc1f779
commit 199940ab19
4 changed files with 33 additions and 9 deletions

View File

@ -6,7 +6,6 @@ import ".."
import "../Base" import "../Base"
import "../Base/HTile" import "../Base/HTile"
Rectangle { Rectangle {
implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0 implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0
color: theme.mainPane.accountBar.background color: theme.mainPane.accountBar.background
@ -50,6 +49,8 @@ Rectangle {
expand.visible: false expand.visible: false
onLeftClicked: roomList.goToAccount(model.id) onLeftClicked: roomList.goToAccount(model.id)
onWentToAccountPage:
roomList.currentIndex = roomList.accountIndice[model.id]
} }
highlight: Item { highlight: Item {

View File

@ -13,7 +13,8 @@ HMenu {
property string presence property string presence
property string statusMsg property string statusMsg
onOpened: statusText.forceActiveFocus()
signal wentToAccountPage()
function setPresence(presence, statusMsg=undefined) { function setPresence(presence, statusMsg=undefined) {
@ -21,6 +22,9 @@ HMenu {
} }
onOpened: statusText.forceActiveFocus()
HLabeledItem { HLabeledItem {
id: statusMsgLabel id: statusMsgLabel
enabled: presence && presence !== "offline" enabled: presence && presence !== "offline"
@ -103,15 +107,21 @@ HMenu {
HMenuItem { HMenuItem {
icon.name: "account-settings" icon.name: "account-settings"
text: qsTr("Account settings") text: qsTr("Account settings")
onTriggered: pageLoader.showPage( onTriggered: {
"AccountSettings/AccountSettings", { "userId": userId }, pageLoader.showPage(
) "AccountSettings/AccountSettings", { "userId": userId },
)
wentToAccountPage()
}
} }
HMenuItem { HMenuItem {
icon.name: "menu-add-chat" icon.name: "menu-add-chat"
text: qsTr("Add new chat") text: qsTr("Add new chat")
onTriggered: pageLoader.showPage("AddChat/AddChat", {userId: userId}) onTriggered: {
pageLoader.showPage("AddChat/AddChat", {userId: userId})
wentToAccountPage()
}
} }
HMenuItem { HMenuItem {

View File

@ -72,6 +72,13 @@ HTile {
HColumnLayout { HColumnLayout {
id: title id: title
text: model.display_name || model.id
color:
hovered ?
utils.nameColor(
model.display_name || model.id.substring(1),
) :
theme.mainPane.listView.account.name
TitleLabel { TitleLabel {
text: model.display_name || model.id text: model.display_name || model.id
@ -112,9 +119,10 @@ HTile {
icon.name: "add-chat" icon.name: "add-chat"
backgroundColor: "transparent" backgroundColor: "transparent"
toolTip.text: qsTr("Add new chat") toolTip.text: qsTr("Add new chat")
onClicked: pageLoader.showPage( onClicked: {
"AddChat/AddChat", {userId: model.id}, pageLoader.showPage("AddChat/AddChat", {userId: model.id})
) account.wentToAccountPage()
}
leftPadding: theme.spacing leftPadding: theme.spacing
rightPadding: theme.spacing / 1.75 rightPadding: theme.spacing / 1.75
@ -168,6 +176,7 @@ HTile {
model.presence_support || model.presence === "offline" ? model.presence_support || model.presence === "offline" ?
model.presence : model.presence :
null null
onWentToAccountPage: account.wentToAccountPage()
} }
@ -184,6 +193,8 @@ HTile {
readonly property alias addChat: addChat readonly property alias addChat: addChat
readonly property alias expand: expand readonly property alias expand: expand
signal wentToAccountPage()
function setCollapse(collapse) { function setCollapse(collapse) {
window.uiState.collapseAccounts[model.id] = collapse window.uiState.collapseAccounts[model.id] = collapse

View File

@ -33,6 +33,8 @@ HListView {
onLeftClicked: showItemAtIndex(model.index) onLeftClicked: showItemAtIndex(model.index)
onCollapsedChanged: onCollapsedChanged:
if (wantedUserId === model.id) startCorrectItemSearch() if (wantedUserId === model.id) startCorrectItemSearch()
onWentToAccountPage: roomList.currentIndex = model.index
} }
} }