Adapt auto-repeat shortcuts to new system

This commit is contained in:
miruka 2019-08-22 14:16:49 -04:00
parent 8de26c11a1
commit a47351a5ad
4 changed files with 22 additions and 13 deletions

View File

@ -5,6 +5,7 @@ QtObject {
signal held(var event) signal held(var event)
signal released(var event) signal released(var event)
property bool enabled: true property bool enabled: true
property var sequences: "" // string or array of strings property var sequences: "" // string or array of strings
} }

View File

@ -79,7 +79,7 @@ HButton {
Timer { Timer {
interval: 100 interval: 100
repeat: true repeat: true
running: true // running: true
// Component.onCompleted won't work for this // Component.onCompleted won't work for this
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
} }

View File

@ -5,6 +5,7 @@ import "utils.js" as Utils
HShortcutHandler { HShortcutHandler {
property Item flickTarget: Item {} property Item flickTarget: Item {}
// App
HShortcut { HShortcut {
enabled: debugMode enabled: debugMode
@ -17,16 +18,22 @@ HShortcutHandler {
onPressed: py.loadSettings(() => { mainUI.pressAnimation.start() }) onPressed: py.loadSettings(() => { mainUI.pressAnimation.start() })
} }
// Page scrolling
HShortcut { HShortcut {
sequences: settings.keys.scrollUp sequences: settings.keys.scrollUp
onPressed: Utils.smartVerticalFlick(flickTarget, -335) onPressed: Utils.smartVerticalFlick(flickTarget, -335)
onHeld: pressed(event)
} }
HShortcut { HShortcut {
sequences: settings.keys.scrollDown sequences: settings.keys.scrollDown
onPressed: Utils.smartVerticalFlick(flickTarget, 335) onPressed: Utils.smartVerticalFlick(flickTarget, 335)
onHeld: pressed(event)
} }
// SidePane
HShortcut { HShortcut {
sequences: settings.keys.focusSidePane sequences: settings.keys.focusSidePane
onPressed: mainUI.sidePane.setFocus() onPressed: mainUI.sidePane.setFocus()
@ -40,11 +47,13 @@ HShortcutHandler {
HShortcut { HShortcut {
sequences: settings.keys.goToPreviousRoom sequences: settings.keys.goToPreviousRoom
onPressed: mainUI.sidePane.accountRoomList.previous() onPressed: mainUI.sidePane.accountRoomList.previous()
onHeld: pressed(event)
} }
HShortcut { HShortcut {
sequences: settings.keys.goToNextRoom sequences: settings.keys.goToNextRoom
onPressed: mainUI.sidePane.accountRoomList.next() onPressed: mainUI.sidePane.accountRoomList.next()
onHeld: pressed(event)
} }
HShortcut { HShortcut {

View File

@ -11,9 +11,9 @@ HListView {
readonly property var collapseAccounts: window.uiState.collapseAccounts readonly property var collapseAccounts: window.uiState.collapseAccounts
readonly property string filter: paneToolBar.roomFilter readonly property string filter: paneToolBar.roomFilter
onOriginSourceChanged: filterLimiter.requestFire() onOriginSourceChanged: filterLimiter.restart()
onFilterChanged: filterLimiter.requestFire() onFilterChanged: filterLimiter.restart()
onCollapseAccountsChanged: filterLimiter.requestFire() onCollapseAccountsChanged: filterLimiter.restart()
function filterSource() { function filterSource() {
@ -59,13 +59,12 @@ HListView {
function previous(activate=true) { function previous(activate=true) {
decrementCurrentIndex() decrementCurrentIndex()
if (activate) activateLimiter.requestFire() if (activate) activateLimiter.restart()
} }
function next(activate=true) { function next(activate=true) {
incrementCurrentIndex() incrementCurrentIndex()
if (activate) activateLimiter.requestFire() if (activate) activateLimiter.restart()
} }
function activate() { function activate() {
@ -108,15 +107,15 @@ HListView {
} }
HRateLimiter { Timer {
id: filterLimiter id: filterLimiter
cooldown: 16 interval: 16
onFired: filterSource() onTriggered: filterSource()
} }
HRateLimiter { Timer {
id: activateLimiter id: activateLimiter
onFired: activate() interval: 300
extendOnRequestWhileCooldownActive: true onTriggered: activate()
} }
} }