Highlight main pane items on startup and clicks
This commit is contained in:
parent
7547703bb0
commit
7325c78c5a
|
@ -43,9 +43,12 @@ HTileDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
onActivated: pageLoader.showPage(
|
||||
"AccountSettings/AccountSettings", { "userId": model.id }
|
||||
)
|
||||
onActivated: {
|
||||
becomeSelected()
|
||||
pageLoader.showPage(
|
||||
"AccountSettings/AccountSettings", { "userId": model.id }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
readonly property alias addChat: addChat
|
||||
|
@ -53,6 +56,18 @@ HTileDelegate {
|
|||
readonly property bool collapsed:
|
||||
window.uiState.collapseAccounts[model.id] || false
|
||||
|
||||
readonly property bool shouldBeSelected:
|
||||
(
|
||||
window.uiState.page === "Pages/AddChat/AddChat.qml" ||
|
||||
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml"
|
||||
) &&
|
||||
window.uiState.pageProperties.userId === model.id
|
||||
|
||||
|
||||
function becomeSelected() {
|
||||
accountRooms.roomList.currentIndex = -1
|
||||
mainPaneList.currentIndex = index
|
||||
}
|
||||
|
||||
function toggleCollapse() {
|
||||
window.uiState.collapseAccounts[model.id] = ! collapsed
|
||||
|
@ -62,15 +77,29 @@ HTileDelegate {
|
|||
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
|
||||
|
||||
// Trying to set the current item to ourself usually won't work from the
|
||||
// first time, when this delegate is being initialized
|
||||
Timer {
|
||||
interval: 100
|
||||
repeat: true
|
||||
running: shouldBeSelected && mainPaneList.currentIndex === -1
|
||||
triggeredOnStart: true
|
||||
onTriggered: becomeSelected()
|
||||
}
|
||||
|
||||
HButton {
|
||||
id: addChat
|
||||
iconItem.small: true
|
||||
icon.name: "add-chat"
|
||||
backgroundColor: "transparent"
|
||||
toolTip.text: qsTr("Add new chat")
|
||||
onClicked: pageLoader.showPage(
|
||||
"AddChat/AddChat", {userId: model.id},
|
||||
)
|
||||
onClicked: {
|
||||
becomeSelected()
|
||||
pageLoader.showPage(
|
||||
"AddChat/AddChat", {userId: model.id},
|
||||
)
|
||||
}
|
||||
|
||||
leftPadding: theme.spacing / 2
|
||||
rightPadding: leftPadding
|
||||
|
|
|
@ -6,12 +6,13 @@ import ".."
|
|||
import "../Base"
|
||||
|
||||
Column {
|
||||
id: delegate
|
||||
id: accountRooms
|
||||
// visible: account.opacity > 0
|
||||
|
||||
|
||||
property string userId: model.id
|
||||
readonly property HListView view: ListView.view
|
||||
readonly property int listIndex: index
|
||||
readonly property bool hide:
|
||||
mainPane.filter &&
|
||||
roomList.model.count < 1 &&
|
||||
|
@ -25,7 +26,7 @@ Column {
|
|||
Account {
|
||||
id: account
|
||||
width: parent.width
|
||||
view: delegate.view
|
||||
view: accountRooms.view
|
||||
|
||||
opacity: hide ?
|
||||
0 :
|
||||
|
@ -46,7 +47,7 @@ Column {
|
|||
interactive: false
|
||||
|
||||
model: SortFilterProxyModel {
|
||||
sourceModel: ModelStore.get(delegate.userId, "rooms")
|
||||
sourceModel: ModelStore.get(accountRooms.userId, "rooms")
|
||||
|
||||
filters: [
|
||||
ExpressionFilter {
|
||||
|
@ -64,7 +65,7 @@ Column {
|
|||
|
||||
delegate: Room {
|
||||
width: roomList.width
|
||||
userId: delegate.userId
|
||||
userId: accountRooms.userId
|
||||
}
|
||||
|
||||
highlight: null // managed by the AccountRoomsList
|
||||
|
|
|
@ -20,8 +20,6 @@ HListView {
|
|||
highlightRangeMode: ListView.NoHighlightRange
|
||||
|
||||
highlight: Rectangle {
|
||||
Component.onCompleted: print("coc")
|
||||
Component.onDestruction: print("cod")
|
||||
id: highlightRectangle
|
||||
y:
|
||||
selectedRoom ?
|
||||
|
@ -156,6 +154,12 @@ HListView {
|
|||
currentIndex = -1
|
||||
}
|
||||
|
||||
function forceUpdateSelection() {
|
||||
// When the selection is cleared, if an account or room delegate is
|
||||
// supposed to be selected, it will try to be so again.
|
||||
clearSelection()
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
id: activateLimiter
|
||||
|
|
|
@ -134,7 +134,10 @@ HTileDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
onActivated: pageLoader.showRoom(userId, model.id)
|
||||
onActivated: {
|
||||
becomeSelected()
|
||||
pageLoader.showRoom(userId, model.id)
|
||||
}
|
||||
|
||||
|
||||
property string userId
|
||||
|
@ -148,6 +151,32 @@ HTileDelegate {
|
|||
readonly property QtObject lastEvent:
|
||||
eventModel.count > 0 ? eventModel.get(0) : null
|
||||
|
||||
readonly property bool shouldBeSelected:
|
||||
window.uiState.page === "Pages/Chat/Chat.qml" &&
|
||||
window.uiState.pageProperties.userId === userId &&
|
||||
window.uiState.pageProperties.roomId === model.id
|
||||
|
||||
|
||||
function becomeSelected() {
|
||||
mainPaneList.currentIndex = accountRooms.listIndex
|
||||
roomList.currentIndex = index
|
||||
}
|
||||
|
||||
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
|
||||
|
||||
// Trying to set the current item to ourself usually won't work from the
|
||||
// first time, when this delegate is being initialized
|
||||
Timer {
|
||||
interval: 100
|
||||
repeat: true
|
||||
running:
|
||||
shouldBeSelected &&
|
||||
mainPaneList.currentIndex === -1 &&
|
||||
roomList.currentIndex === -1
|
||||
|
||||
triggeredOnStart: true
|
||||
onTriggered: becomeSelected()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ HLoader {
|
|||
window.uiState.page = componentUrl
|
||||
window.uiState.pageProperties = properties
|
||||
window.uiStateChanged()
|
||||
mainUI.mainPane.mainPaneList.forceUpdateSelection()
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user