From d7d111705f8e8d703ccf923ab51f9d6f11f91866 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 14 Sep 2020 12:02:28 -0400 Subject: [PATCH] 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. --- src/backend/user_files.py | 1 + src/gui/MainPane/RoomList.qml | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/backend/user_files.py b/src/backend/user_files.py index 155feee5..ec889fdf 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -269,6 +269,7 @@ class UISettings(JSONDataFile): "alwaysCenterRoomHeader": False, # "autoHideScrollBarsAfterMsec": 2000, "beUnavailableAfterSecondsIdle": 60 * 10, + "centerRoomListOnClick": False, "compactMode": False, "clearRoomFilterOnEnter": True, "clearRoomFilterOnEscape": True, diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index 07f721b3..73f2a593 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -11,6 +11,8 @@ HListView { property string filter: "" + property bool keepListCentered: true + readonly property bool currentShouldBeAccount: window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" || window.uiState.page === "Pages/AddChat/AddChat.qml" @@ -54,7 +56,7 @@ HListView { showItemLimiter.restart() } - function showItemAtIndex(index=currentIndex) { + function showItemAtIndex(index=currentIndex, fromClick=false) { if (index === -1) index = 0 index = Math.min(index, model.count - 1) @@ -66,7 +68,13 @@ HListView { ) : pageLoader.showRoom(item.for_account, item.id) + if (fromClick && ! window.settings.centerRoomListOnClick) + keepListCentered = false + currentIndex = index + + if (fromClick && ! window.settings.centerRoomListOnClick) + keepListCentered = true } function showAccountRoomAtIndex(index) { @@ -135,6 +143,9 @@ HListView { } + highlightRangeMode: + keepListCentered ? ListView.ApplyRange : ListView.NoHighlightRange + model: ModelStore.get("all_rooms") delegate: DelegateChooser { @@ -157,7 +168,7 @@ HListView { totalMessageIndicator.visible: false - onLeftClicked: showItemAtIndex(model.index) + onLeftClicked: showItemAtIndex(model.index, true) onCollapsedChanged: if (wantedUserId === model.id) startCorrectItemSearch() @@ -169,7 +180,7 @@ HListView { roleValue: "Room" RoomDelegate { width: roomList.width - onLeftClicked: showItemAtIndex(model.index) + onLeftClicked: showItemAtIndex(model.index, true) } } }