Add keybinds to go to previous/next room
This commit is contained in:
parent
6ec193d554
commit
5e5a658173
|
@ -119,6 +119,8 @@ class UISettings(JSONConfigFile):
|
|||
"scrollUp": ["Alt+Up", "Alt+K"],
|
||||
"scrollDown": ["Alt+Down", "Alt+J"],
|
||||
"filterRooms": ["Alt+R", "Ctrl+R"],
|
||||
"goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"],
|
||||
"goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"],
|
||||
"startDebugger": ["Alt+Shift+D"],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,6 +4,12 @@ import QtQuick.Controls 2.12
|
|||
ListView {
|
||||
interactive: false
|
||||
currentIndex: -1
|
||||
highlightMoveDuration: theme.animationDuration
|
||||
|
||||
highlight: HRectangle {
|
||||
color: theme.controls.interactiveRectangle.checkedOverlay
|
||||
opacity: theme.controls.interactiveRectangle.checkedOpacity
|
||||
}
|
||||
|
||||
add: Transition {
|
||||
HNumberAnimation { properties: "x,y"; from: 100 }
|
||||
|
|
|
@ -5,8 +5,5 @@ HFixedListView {
|
|||
interactive: true
|
||||
keyNavigationWraps: true
|
||||
|
||||
// This is used to smooth scroll when currentIndex is changed
|
||||
highlightMoveDuration: theme.animationDuration * 4
|
||||
|
||||
ScrollBar.vertical: ScrollBar {}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,13 @@ Item {
|
|||
}
|
||||
|
||||
Shortcut {
|
||||
sequences: ["Ctrl+N"]
|
||||
onActivated: mainUI.sidePane.activateNext()
|
||||
sequences: settings.keys ? settings.keys.goToPreviousRoom : []
|
||||
onActivated: mainUI.sidePane.accountRoomList.previous()
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequences: settings.keys ? settings.keys.goToNextRoom : []
|
||||
onActivated: mainUI.sidePane.accountRoomList.next()
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,6 +19,9 @@ HListView {
|
|||
function filterSource() {
|
||||
let show = []
|
||||
|
||||
// Hide a harmless error when activating a DelegateRoom
|
||||
try { window.sidePaneModelSource } catch (err) { return }
|
||||
|
||||
for (let i = 0; i < window.sidePaneModelSource.length; i++) {
|
||||
let item = window.sidePaneModelSource[i]
|
||||
|
||||
|
@ -47,6 +50,16 @@ HListView {
|
|||
model.source = show
|
||||
}
|
||||
|
||||
function previous() {
|
||||
accountRoomList.decrementCurrentIndex()
|
||||
accountRoomList.currentItem.item.activate()
|
||||
}
|
||||
|
||||
function next() {
|
||||
accountRoomList.incrementCurrentIndex()
|
||||
accountRoomList.currentItem.item.activate()
|
||||
}
|
||||
|
||||
|
||||
model: HListModel {
|
||||
keyField: "id"
|
||||
|
|
|
@ -5,7 +5,7 @@ import "../Base"
|
|||
HInteractiveRectangle {
|
||||
id: accountDelegate
|
||||
color: theme.sidePane.account.background
|
||||
checked: isCurrent
|
||||
// checked: isCurrent
|
||||
height: row.height
|
||||
|
||||
|
||||
|
@ -20,6 +20,13 @@ HInteractiveRectangle {
|
|||
accountRoomList.collapseAccounts[model.data.user_id] || false
|
||||
|
||||
|
||||
onIsCurrentChanged: if (isCurrent) beHighlighted()
|
||||
|
||||
|
||||
function beHighlighted() {
|
||||
accountRoomList.currentIndex = model.index
|
||||
}
|
||||
|
||||
function toggleCollapse() {
|
||||
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
|
||||
window.uiStateChanged()
|
||||
|
@ -32,6 +39,14 @@ HInteractiveRectangle {
|
|||
}
|
||||
|
||||
|
||||
// Component.onCompleted won't work for this
|
||||
Timer {
|
||||
interval: 100
|
||||
repeat: true
|
||||
running: accountRoomList.currentIndex == -1
|
||||
onTriggered: if (isCurrent) beHighlighted()
|
||||
}
|
||||
|
||||
TapHandler { onTapped: accountDelegate.activate() }
|
||||
|
||||
HRowLayout {
|
||||
|
|
|
@ -9,7 +9,6 @@ HInteractiveRectangle {
|
|||
visible: height > 0
|
||||
height: rowLayout.height
|
||||
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
|
||||
checked: isCurrent
|
||||
|
||||
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
|
@ -24,11 +23,26 @@ HInteractiveRectangle {
|
|||
window.uiState.pageProperties.roomId == model.data.room_id
|
||||
|
||||
|
||||
onIsCurrentChanged: if (isCurrent) beHighlighted()
|
||||
|
||||
|
||||
function beHighlighted() {
|
||||
accountRoomList.currentIndex = model.index
|
||||
}
|
||||
|
||||
function activate() {
|
||||
pageStack.showRoom(model.user_id, model.data.room_id)
|
||||
}
|
||||
|
||||
|
||||
// Component.onCompleted won't work for this
|
||||
Timer {
|
||||
interval: 100
|
||||
repeat: true
|
||||
running: accountRoomList.currentIndex == -1
|
||||
onTriggered: if (isCurrent) beHighlighted()
|
||||
}
|
||||
|
||||
TapHandler { onTapped: activate() }
|
||||
|
||||
HRowLayout {
|
||||
|
|
|
@ -71,74 +71,6 @@ HRectangle {
|
|||
}
|
||||
|
||||
|
||||
function _getRoomModelSource(accountUserId) {
|
||||
return Utils.filterModelSource(
|
||||
modelSources[["Room", accountUserId]] || [],
|
||||
paneToolBar.roomFilter,
|
||||
)
|
||||
}
|
||||
|
||||
function _activateNextAccount(i) {
|
||||
let nextIndex = i + 1 > accountList.model.count - 1 ? 0 : i + 1
|
||||
if (nextIndex == i) return
|
||||
|
||||
pageStack.showPage(
|
||||
"EditAccount/EditAccount",
|
||||
{userId: accountList.model.get(nextIndex).user_id}
|
||||
)
|
||||
|
||||
accountList.currentIndex = nextIndex
|
||||
}
|
||||
|
||||
function activateNext() {
|
||||
if (accountList.model.count < 1) return
|
||||
|
||||
for (let i = 0; i < accountList.model.count; i++) {
|
||||
let account = accountList.model.get(i)
|
||||
|
||||
if (window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
|
||||
window.uiState.pageProperties.userId == account.user_id)
|
||||
{
|
||||
let room = _getRoomModelSource(account.user_id)[0]
|
||||
|
||||
if (room) { pageStack.showRoom(account.user_id, room.room_id) }
|
||||
else { _activateNextAccount(i) }
|
||||
return
|
||||
}
|
||||
|
||||
if (window.uiState.page == "Chat/Chat.qml" &&
|
||||
window.uiState.pageProperties.userId == account.user_id)
|
||||
{
|
||||
let rooms = _getRoomModelSource(account.user_id)
|
||||
|
||||
if (! rooms) { _activateNextAccount(i); return }
|
||||
|
||||
for (let ri = 0; ri < rooms.length; ri++) {
|
||||
let room = rooms[ri]
|
||||
|
||||
if (room.room_id != window.uiState.pageProperties.roomId) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (ri + 1 > rooms.length -1) {
|
||||
_activateNextAccount(i)
|
||||
return
|
||||
}
|
||||
|
||||
pageStack.showRoom(account.user_id, rooms[ri + 1].room_id)
|
||||
|
||||
let currentRoomItem =
|
||||
accountList.itemAtIndex(i).roomList.itemAtIndex(ri)
|
||||
|
||||
print(currentRoomItem.visible)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user