Add keyboard shortcuts to flick the events list
This commit is contained in:
parent
d033ea84e8
commit
41eea44fff
2
TODO.md
2
TODO.md
|
@ -12,12 +12,14 @@
|
|||
- When qml syntax highlighting supports string interpolation, use them
|
||||
|
||||
- Fixes
|
||||
- Don't strip user spacing in html
|
||||
- Past events loading (limit 100) freezes the GUI - need to move upsert func
|
||||
to a WorkerScript
|
||||
- `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function`
|
||||
- Horrible performance for big rooms
|
||||
|
||||
- UI
|
||||
- Adapt shortcuts flicking speed to font size and DPI
|
||||
- Show error box if uploading avatar fails
|
||||
- EditAccount page:
|
||||
- Device settings
|
||||
|
|
|
@ -14,6 +14,7 @@ HRectangle {
|
|||
HListView {
|
||||
id: eventList
|
||||
clip: true
|
||||
Component.onCompleted: shortcuts.flickTarget = eventList
|
||||
|
||||
function canCombine(item, itemAfter) {
|
||||
if (! item || ! itemAfter) { return false }
|
||||
|
|
37
src/qml/Shortcuts.qml
Normal file
37
src/qml/Shortcuts.qml
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2019 miruka
|
||||
// This file is part of harmonyqml, licensed under LGPLv3.
|
||||
|
||||
import QtQuick 2.12
|
||||
|
||||
Item {
|
||||
property Item flickTarget: Item {}
|
||||
|
||||
function smartVerticalFlick(baseVelocity, fastMultiply=3) {
|
||||
let vel = flickTarget.verticalVelocity
|
||||
|
||||
if (flickTarget.verticalLayoutDirection == ListView.BottomToTop) {
|
||||
baseVelocity = -baseVelocity
|
||||
vel = -vel
|
||||
}
|
||||
|
||||
let fast = (baseVelocity < 0 && vel < baseVelocity / 2) ||
|
||||
(baseVelocity > 0 && vel > baseVelocity / 2)
|
||||
|
||||
flickTarget.flick(0, baseVelocity * (fast ? fastMultiply : 1))
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequences: ["Alt+Up", "Alt+K"]
|
||||
onActivated: smartVerticalFlick(-335)
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequences: ["Alt+Down", "Alt+J"]
|
||||
onActivated: smartVerticalFlick(335)
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: "Alt+Shift+D"
|
||||
onActivated: if (window.debug) { py.call("APP.pdb") }
|
||||
}
|
||||
}
|
|
@ -98,7 +98,5 @@ Item {
|
|||
popExit: null
|
||||
pushExit: null
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: if (window.debug) { py.call("APP.pdb") }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ ApplicationWindow {
|
|||
onSettingsChanged: py.saveSettings()
|
||||
|
||||
Theme { id: theme }
|
||||
|
||||
Shortcuts { id: shortcuts}
|
||||
Python { id: py }
|
||||
|
||||
// Models
|
||||
|
|
Loading…
Reference in New Issue
Block a user