Main pane list items keyboard activation

This commit is contained in:
miruka 2020-02-13 05:56:10 -04:00
parent 4636a36154
commit 7547703bb0
5 changed files with 34 additions and 5 deletions

View File

@ -187,13 +187,19 @@ Item {
HShortcut { HShortcut {
enabled: mainUI.accountsPresent enabled: mainUI.accountsPresent
sequences: settings.keys.goToPreviousRoom sequences: settings.keys.goToPreviousRoom
onActivated: mainUI.mainPane.mainPaneList.previous() onActivated: {
mainUI.mainPane.mainPaneList.previous()
mainUI.mainPane.mainPaneList.requestActivate()
}
} }
HShortcut { HShortcut {
enabled: mainUI.accountsPresent enabled: mainUI.accountsPresent
sequences: settings.keys.goToNextRoom sequences: settings.keys.goToNextRoom
onActivated: mainUI.mainPane.mainPaneList.next() onActivated: {
mainUI.mainPane.mainPaneList.next()
mainUI.mainPane.mainPaneList.requestActivate()
}
} }

View File

@ -48,6 +48,8 @@ HTileDelegate {
) )
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

View File

@ -20,6 +20,8 @@ HListView {
highlightRangeMode: ListView.NoHighlightRange highlightRangeMode: ListView.NoHighlightRange
highlight: Rectangle { highlight: Rectangle {
Component.onCompleted: print("coc")
Component.onDestruction: print("cod")
id: highlightRectangle id: highlightRectangle
y: y:
selectedRoom ? selectedRoom ?
@ -120,8 +122,15 @@ HListView {
} }
} }
function requestActivate() {
activateLimiter.restart()
}
function activate() { function activate() {
currentItem.item.activated() if (! currentItem) incrementCurrentIndex()
selectedRoom ?
currentItem.roomList.currentItem.activated() :
currentItem.account.activated()
} }
function accountSettings() { function accountSettings() {
@ -133,7 +142,7 @@ HListView {
function addNewChat() { function addNewChat() {
if (! currentItem) incrementCurrentIndex() if (! currentItem) incrementCurrentIndex()
currentItem.roomList.currentIndex = -1 currentItem.roomList.currentIndex = -1
currentItem.account.activated() currentItem.account.addChat.clicked()
} }
function toggleCollapseAccount() { function toggleCollapseAccount() {
@ -142,6 +151,11 @@ HListView {
currentItem.account.toggleCollapse() currentItem.account.toggleCollapse()
} }
function clearSelection() {
if (selectedRoom) currentItem.roomList.currentIndex = -1
currentIndex = -1
}
Timer { Timer {
id: activateLimiter id: activateLimiter

View File

@ -27,6 +27,10 @@ HDrawer {
toolBar.filterField.forceActiveFocus() toolBar.filterField.forceActiveFocus()
} }
function addccount() {
toolBar.addAccountButton.clicked()
}
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }

View File

@ -19,7 +19,10 @@ HRowLayout {
icon.name: "add-account" icon.name: "add-account"
toolTip.text: qsTr("Add another account") toolTip.text: qsTr("Add another account")
backgroundColor: theme.mainPane.settingsButton.background backgroundColor: theme.mainPane.settingsButton.background
onClicked: pageLoader.showPage("AddAccount/AddAccount") onClicked: {
mainPaneList.clearSelection()
pageLoader.showPage("AddAccount/AddAccount")
}
Layout.fillHeight: true Layout.fillHeight: true
} }