Improve filtered main pane keyboard navigation

This commit is contained in:
miruka 2020-03-07 10:15:54 -04:00
parent f60b46f26b
commit 269bd1d557
2 changed files with 31 additions and 4 deletions

View File

@ -51,7 +51,8 @@ HTileDelegate {
readonly property alias addChat: addChat readonly property alias addChat: addChat
readonly property bool collapsed: readonly property bool collapsed:
window.uiState.collapseAccounts[model.id] || false (window.uiState.collapseAccounts[model.id] || false) &&
! mainPane.filter
readonly property bool shouldBeSelected: readonly property bool shouldBeSelected:
( (

View File

@ -61,14 +61,26 @@ HListView {
readonly property Room selectedRoom: readonly property Room selectedRoom:
currentItem ? currentItem.roomList.currentItem : null currentItem ? currentItem.roomList.currentItem : null
function previous() {
if (! mainPane.filter) {
_previous()
return
}
function previous(activate=true) { let reachedStart = false
do {
if (currentIndex === count - 1 && reachedStart) break
_previous()
if (currentIndex === 0) reachedStart = true
} while (! currentItem.roomList.currentItem)
}
function _previous() {
let currentAccount = currentItem let currentAccount = currentItem
// Nothing is selected // Nothing is selected
if (! currentAccount) { if (! currentAccount) {
decrementCurrentIndex() decrementCurrentIndex()
return
} }
let roomList = currentAccount.roomList let roomList = currentAccount.roomList
@ -93,7 +105,21 @@ HListView {
} }
} }
function next(activate=true) { function next() {
if (! mainPane.filter) {
_next()
return
}
let reachedEnd = false
do {
if (currentIndex === 0 && reachedEnd) break
_next()
if (currentIndex === count - 1) reachedEnd = true
} while (! currentItem.roomList.currentItem)
}
function _next() {
const currentAccount = currentItem const currentAccount = currentItem
// Nothing is selected // Nothing is selected