Don't center the room list on clicks by default

Previously, clicking to select a room would make the list jump around
to become centered again. This behavior is now reserved to keyboard
navigation.

A "centerRoomListOnClick" setting has been added to allow going back
to the previous behavior.
This commit is contained in:
miruka 2020-09-14 12:02:28 -04:00
parent 2712896456
commit d7d111705f
2 changed files with 15 additions and 3 deletions

View File

@ -269,6 +269,7 @@ class UISettings(JSONDataFile):
"alwaysCenterRoomHeader": False, "alwaysCenterRoomHeader": False,
# "autoHideScrollBarsAfterMsec": 2000, # "autoHideScrollBarsAfterMsec": 2000,
"beUnavailableAfterSecondsIdle": 60 * 10, "beUnavailableAfterSecondsIdle": 60 * 10,
"centerRoomListOnClick": False,
"compactMode": False, "compactMode": False,
"clearRoomFilterOnEnter": True, "clearRoomFilterOnEnter": True,
"clearRoomFilterOnEscape": True, "clearRoomFilterOnEscape": True,

View File

@ -11,6 +11,8 @@ HListView {
property string filter: "" property string filter: ""
property bool keepListCentered: true
readonly property bool currentShouldBeAccount: readonly property bool currentShouldBeAccount:
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" || window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" ||
window.uiState.page === "Pages/AddChat/AddChat.qml" window.uiState.page === "Pages/AddChat/AddChat.qml"
@ -54,7 +56,7 @@ HListView {
showItemLimiter.restart() showItemLimiter.restart()
} }
function showItemAtIndex(index=currentIndex) { function showItemAtIndex(index=currentIndex, fromClick=false) {
if (index === -1) index = 0 if (index === -1) index = 0
index = Math.min(index, model.count - 1) index = Math.min(index, model.count - 1)
@ -66,7 +68,13 @@ HListView {
) : ) :
pageLoader.showRoom(item.for_account, item.id) pageLoader.showRoom(item.for_account, item.id)
if (fromClick && ! window.settings.centerRoomListOnClick)
keepListCentered = false
currentIndex = index currentIndex = index
if (fromClick && ! window.settings.centerRoomListOnClick)
keepListCentered = true
} }
function showAccountRoomAtIndex(index) { function showAccountRoomAtIndex(index) {
@ -135,6 +143,9 @@ HListView {
} }
highlightRangeMode:
keepListCentered ? ListView.ApplyRange : ListView.NoHighlightRange
model: ModelStore.get("all_rooms") model: ModelStore.get("all_rooms")
delegate: DelegateChooser { delegate: DelegateChooser {
@ -157,7 +168,7 @@ HListView {
totalMessageIndicator.visible: false totalMessageIndicator.visible: false
onLeftClicked: showItemAtIndex(model.index) onLeftClicked: showItemAtIndex(model.index, true)
onCollapsedChanged: onCollapsedChanged:
if (wantedUserId === model.id) startCorrectItemSearch() if (wantedUserId === model.id) startCorrectItemSearch()
@ -169,7 +180,7 @@ HListView {
roleValue: "Room" roleValue: "Room"
RoomDelegate { RoomDelegate {
width: roomList.width width: roomList.width
onLeftClicked: showItemAtIndex(model.index) onLeftClicked: showItemAtIndex(model.index, true)
} }
} }
} }