Add keybinds to go to previous/next room
This commit is contained in:
parent
6ec193d554
commit
5e5a658173
|
@ -115,11 +115,13 @@ class UISettings(JSONConfigFile):
|
||||||
"theme": "Default.qpl",
|
"theme": "Default.qpl",
|
||||||
"writeAliases": {},
|
"writeAliases": {},
|
||||||
"keys": {
|
"keys": {
|
||||||
"reloadConfig": ["Alt+Shift+R"],
|
"reloadConfig": ["Alt+Shift+R"],
|
||||||
"scrollUp": ["Alt+Up", "Alt+K"],
|
"scrollUp": ["Alt+Up", "Alt+K"],
|
||||||
"scrollDown": ["Alt+Down", "Alt+J"],
|
"scrollDown": ["Alt+Down", "Alt+J"],
|
||||||
"filterRooms": ["Alt+R", "Ctrl+R"],
|
"filterRooms": ["Alt+R", "Ctrl+R"],
|
||||||
"startDebugger": ["Alt+Shift+D"],
|
"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 {
|
ListView {
|
||||||
interactive: false
|
interactive: false
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
highlightMoveDuration: theme.animationDuration
|
||||||
|
|
||||||
|
highlight: HRectangle {
|
||||||
|
color: theme.controls.interactiveRectangle.checkedOverlay
|
||||||
|
opacity: theme.controls.interactiveRectangle.checkedOpacity
|
||||||
|
}
|
||||||
|
|
||||||
add: Transition {
|
add: Transition {
|
||||||
HNumberAnimation { properties: "x,y"; from: 100 }
|
HNumberAnimation { properties: "x,y"; from: 100 }
|
||||||
|
|
|
@ -5,8 +5,5 @@ HFixedListView {
|
||||||
interactive: true
|
interactive: true
|
||||||
keyNavigationWraps: true
|
keyNavigationWraps: true
|
||||||
|
|
||||||
// This is used to smooth scroll when currentIndex is changed
|
|
||||||
highlightMoveDuration: theme.animationDuration * 4
|
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
ScrollBar.vertical: ScrollBar {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequences: ["Ctrl+N"]
|
sequences: settings.keys ? settings.keys.goToPreviousRoom : []
|
||||||
onActivated: mainUI.sidePane.activateNext()
|
onActivated: mainUI.sidePane.accountRoomList.previous()
|
||||||
|
}
|
||||||
|
|
||||||
|
Shortcut {
|
||||||
|
sequences: settings.keys ? settings.keys.goToNextRoom : []
|
||||||
|
onActivated: mainUI.sidePane.accountRoomList.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -19,6 +19,9 @@ HListView {
|
||||||
function filterSource() {
|
function filterSource() {
|
||||||
let show = []
|
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++) {
|
for (let i = 0; i < window.sidePaneModelSource.length; i++) {
|
||||||
let item = window.sidePaneModelSource[i]
|
let item = window.sidePaneModelSource[i]
|
||||||
|
|
||||||
|
@ -47,6 +50,16 @@ HListView {
|
||||||
model.source = show
|
model.source = show
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function previous() {
|
||||||
|
accountRoomList.decrementCurrentIndex()
|
||||||
|
accountRoomList.currentItem.item.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
function next() {
|
||||||
|
accountRoomList.incrementCurrentIndex()
|
||||||
|
accountRoomList.currentItem.item.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
model: HListModel {
|
model: HListModel {
|
||||||
keyField: "id"
|
keyField: "id"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import "../Base"
|
||||||
HInteractiveRectangle {
|
HInteractiveRectangle {
|
||||||
id: accountDelegate
|
id: accountDelegate
|
||||||
color: theme.sidePane.account.background
|
color: theme.sidePane.account.background
|
||||||
checked: isCurrent
|
// checked: isCurrent
|
||||||
height: row.height
|
height: row.height
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,13 @@ HInteractiveRectangle {
|
||||||
accountRoomList.collapseAccounts[model.data.user_id] || false
|
accountRoomList.collapseAccounts[model.data.user_id] || false
|
||||||
|
|
||||||
|
|
||||||
|
onIsCurrentChanged: if (isCurrent) beHighlighted()
|
||||||
|
|
||||||
|
|
||||||
|
function beHighlighted() {
|
||||||
|
accountRoomList.currentIndex = model.index
|
||||||
|
}
|
||||||
|
|
||||||
function toggleCollapse() {
|
function toggleCollapse() {
|
||||||
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
|
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
|
||||||
window.uiStateChanged()
|
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() }
|
TapHandler { onTapped: accountDelegate.activate() }
|
||||||
|
|
||||||
HRowLayout {
|
HRowLayout {
|
||||||
|
|
|
@ -9,7 +9,6 @@ HInteractiveRectangle {
|
||||||
visible: height > 0
|
visible: height > 0
|
||||||
height: rowLayout.height
|
height: rowLayout.height
|
||||||
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
|
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
|
||||||
checked: isCurrent
|
|
||||||
|
|
||||||
|
|
||||||
Behavior on opacity { HNumberAnimation {} }
|
Behavior on opacity { HNumberAnimation {} }
|
||||||
|
@ -24,11 +23,26 @@ HInteractiveRectangle {
|
||||||
window.uiState.pageProperties.roomId == model.data.room_id
|
window.uiState.pageProperties.roomId == model.data.room_id
|
||||||
|
|
||||||
|
|
||||||
|
onIsCurrentChanged: if (isCurrent) beHighlighted()
|
||||||
|
|
||||||
|
|
||||||
|
function beHighlighted() {
|
||||||
|
accountRoomList.currentIndex = model.index
|
||||||
|
}
|
||||||
|
|
||||||
function activate() {
|
function activate() {
|
||||||
pageStack.showRoom(model.user_id, model.data.room_id)
|
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() }
|
TapHandler { onTapped: activate() }
|
||||||
|
|
||||||
HRowLayout {
|
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 {
|
HColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user