moment/src/qml/Shortcuts.qml

126 lines
3.2 KiB
QML
Raw Normal View History

import QtQuick 2.12
import "Base"
import "utils.js" as Utils
HShortcutHandler {
property Item flickTarget: Item {}
// App
HShortcut {
enabled: debugMode
2019-09-06 05:05:57 +10:00
sequences: settings.keys.startPythonDebugger
onPressed: py.call("APP.pdb")
}
2019-09-06 05:05:57 +10:00
HShortcut {
enabled: debugMode
sequences: settings.keys.toggleDebugConsole
onPressed: mainUI.debugConsole.visible = ! mainUI.debugConsole.visible
}
HShortcut {
sequences: settings.keys.reloadConfig
onPressed: py.loadSettings(() => { mainUI.pressAnimation.start() })
}
// Page scrolling
HShortcut {
sequences: settings.keys.scrollUp
onPressed: Utils.smartVerticalFlick(flickTarget, -335)
onHeld: pressed(event)
2019-08-20 04:05:59 +10:00
}
HShortcut {
sequences: settings.keys.scrollDown
onPressed: Utils.smartVerticalFlick(flickTarget, 335)
onHeld: pressed(event)
}
2019-08-31 03:06:54 +10:00
HShortcut {
sequences: settings.keys.scrollPageUp
onPressed: Utils.smartVerticalFlick(
2019-09-07 07:03:52 +10:00
flickTarget, -2.3 * flickTarget.height, 8,
2019-08-31 03:06:54 +10:00
)
onHeld: pressed(event)
2019-09-07 07:03:52 +10:00
// Ensure only a slight slip after releasing the key
onReleased: Utils.smartVerticalFlick(flickTarget, -335)
2019-08-31 03:06:54 +10:00
}
HShortcut {
sequences: settings.keys.scrollPageDown
onPressed: Utils.smartVerticalFlick(
2019-09-07 07:03:52 +10:00
flickTarget, 2.3 * flickTarget.height, 8,
2019-08-31 03:06:54 +10:00
)
onHeld: pressed(event)
2019-09-07 07:03:52 +10:00
onReleased: Utils.smartVerticalFlick(flickTarget, 335)
2019-08-31 03:06:54 +10:00
}
2019-08-31 03:40:56 +10:00
HShortcut {
sequences: settings.keys.scrollToTop
onPressed: Utils.flickToTop(flickTarget)
onHeld: pressed(event)
}
HShortcut {
sequences: settings.keys.scrollToBottom
onPressed: Utils.flickToBottom(flickTarget)
onHeld: pressed(event)
}
2019-08-31 03:06:54 +10:00
// SidePane
HShortcut {
enabled: mainUI.accountsPresent
sequences: settings.keys.focusSidePane
onPressed: mainUI.sidePane.setFocus()
}
HShortcut {
enabled: mainUI.accountsPresent
sequences: settings.keys.clearRoomFilter
2019-08-31 01:05:11 +10:00
onPressed: mainUI.sidePane.toolBar.roomFilter = ""
}
2019-08-24 01:02:22 +10:00
HShortcut {
enabled: mainUI.accountsPresent
2019-08-24 01:02:22 +10:00
sequences: settings.keys.addNewAccount
2019-08-31 01:05:11 +10:00
onPressed: mainUI.sidePane.toolBar.addAccountButton.clicked()
2019-08-24 01:02:22 +10:00
}
HShortcut {
enabled: mainUI.accountsPresent
sequences: settings.keys.goToPreviousRoom
2019-08-31 01:05:11 +10:00
onPressed: mainUI.sidePane.sidePaneList.previous()
onHeld: pressed(event)
}
HShortcut {
enabled: mainUI.accountsPresent
sequences: settings.keys.goToNextRoom
2019-08-31 01:05:11 +10:00
onPressed: mainUI.sidePane.sidePaneList.next()
onHeld: pressed(event)
}
HShortcut {
enabled: mainUI.accountsPresent
sequences: settings.keys.toggleCollapseAccount
2019-08-31 01:05:11 +10:00
onPressed: mainUI.sidePane.sidePaneList.toggleCollapseAccount()
}
2019-09-09 01:49:47 +10:00
// Chat
HShortcut {
enabled: window.uiState.page == "Chat/Chat.qml"
sequences: settings.keys.clearRoomMessages
onPressed: py.callClientCoro(
window.uiState.pageProperties.userId,
"clear_events",
[window.uiState.pageProperties.roomId],
)
}
}