Work in progress keybard sidepane navigation

This commit is contained in:
miruka 2019-08-17 20:29:56 -04:00
parent 4e14828004
commit 3cc39210b4
6 changed files with 98 additions and 10 deletions

View File

@ -5,5 +5,8 @@ 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 {}
} }

View File

@ -39,6 +39,11 @@ Item {
onActivated: if (debugMode) { py.call("APP.pdb") } onActivated: if (debugMode) { py.call("APP.pdb") }
} }
Shortcut {
sequences: ["Ctrl+N"]
onActivated: mainUI.sidePane.activateNext()
}
/* /*
Shortcut { Shortcut {
sequence: "Ctrl+-" sequence: "Ctrl+-"

View File

@ -11,10 +11,16 @@ Column {
paneToolBar.roomFilter && roomList.model.count < 1 ? 0.3 : 1 paneToolBar.roomFilter && roomList.model.count < 1 ? 0.3 : 1
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
property alias roomList: roomList
property bool forceExpand: paneToolBar.roomFilter && roomList.model.count property bool forceExpand: paneToolBar.roomFilter && roomList.model.count
property bool expanded: true property bool expanded: true
readonly property var modelItem: model readonly property var modelItem: model
readonly property bool isCurrent:
window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
window.uiState.pageProperties.userId == model.user_id
Component.onCompleted: Component.onCompleted:
expanded = ! window.uiState.collapseAccounts[model.user_id] expanded = ! window.uiState.collapseAccounts[model.user_id]
@ -23,20 +29,21 @@ Column {
window.uiStateChanged() window.uiStateChanged()
} }
function activate() {
pageStack.showPage(
"EditAccount/EditAccount", { "userId": model.user_id }
)
}
HInteractiveRectangle { HInteractiveRectangle {
id: rectangle
width: parent.width width: parent.width
height: childrenRect.height height: childrenRect.height
color: theme.sidePane.account.background color: theme.sidePane.account.background
checked: checked: accountDelegate.isCurrent
window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
window.uiState.pageProperties.userId == model.user_id
TapHandler { TapHandler { onTapped: accountDelegate.activate() }
onTapped: pageStack.showPage(
"EditAccount/EditAccount", { "userId": model.user_id }
)
}
HRowLayout { HRowLayout {
id: row id: row

View File

@ -12,12 +12,15 @@ HInteractiveRectangle {
opacity: model.left ? theme.sidePane.room.leftRoomOpacity : 1 opacity: model.left ? theme.sidePane.room.leftRoomOpacity : 1
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
checked: checked: isCurrent
readonly property bool isCurrent:
window.uiState.page == "Chat/Chat.qml" && window.uiState.page == "Chat/Chat.qml" &&
window.uiState.pageProperties.userId == userId && window.uiState.pageProperties.userId == userId &&
window.uiState.pageProperties.roomId == model.room_id window.uiState.pageProperties.roomId == model.room_id
TapHandler { onTapped: pageStack.showRoom(userId, model.room_id) } function activate() { pageStack.showRoom(userId, model.room_id) }
TapHandler { onTapped: activate() }
HRowLayout { HRowLayout {
id: rowLayout id: rowLayout

View File

@ -4,6 +4,7 @@ import "../utils.js" as Utils
HFixedListView { HFixedListView {
id: roomList id: roomList
property string userId: "" property string userId: ""
model: HListModel { model: HListModel {

View File

@ -1,6 +1,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../utils.js" as Utils
HRectangle { HRectangle {
id: sidePane id: sidePane
@ -70,6 +71,74 @@ 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