2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-21 08:08:58 +10:00
|
|
|
import QtQuick 2.12
|
2019-11-11 00:28:57 +11:00
|
|
|
import QtQuick.Controls 2.12
|
2019-12-28 00:06:42 +11:00
|
|
|
import Clipboard 0.1
|
2019-08-23 03:03:26 +10:00
|
|
|
import "Base"
|
2019-07-21 08:08:58 +10:00
|
|
|
|
2019-12-09 03:42:40 +11:00
|
|
|
Item {
|
|
|
|
visible: false
|
|
|
|
|
2019-11-11 00:28:57 +11:00
|
|
|
// Flickable or ListView that should be affected by scroll shortcuts
|
2019-09-20 06:47:35 +10:00
|
|
|
property Item flickTarget
|
2019-11-11 00:28:57 +11:00
|
|
|
|
2019-12-14 08:59:58 +11:00
|
|
|
// A QQC Container that should be affected by tab navigation shortcuts
|
|
|
|
property Container tabsTarget
|
2019-11-11 00:28:57 +11:00
|
|
|
|
2019-12-20 04:41:57 +11:00
|
|
|
// DebugConsoleLoader that should be affected by console shortcuts
|
|
|
|
property DebugConsoleLoader debugConsoleLoader
|
|
|
|
|
|
|
|
// DebugConsoleLoader to activate if no other loader is active and the
|
|
|
|
// shortcut to bring up a console is pressed
|
|
|
|
property DebugConsoleLoader defaultDebugConsoleLoader
|
|
|
|
|
|
|
|
readonly property DebugConsole debugConsole:
|
|
|
|
debugConsoleLoader ? debugConsoleLoader.item : null
|
|
|
|
|
|
|
|
readonly property DebugConsole defaultDebugConsole:
|
|
|
|
defaultDebugConsoleLoader ? defaultDebugConsoleLoader.item : null
|
2019-07-21 08:08:58 +10:00
|
|
|
|
2019-12-10 04:00:42 +11:00
|
|
|
readonly property Item toFlick:
|
|
|
|
debugConsole && debugConsole.activeFocus ?
|
2019-12-20 04:41:57 +11:00
|
|
|
debugConsole.commandsView :
|
|
|
|
flickTarget
|
2019-12-10 04:00:42 +11:00
|
|
|
|
2019-11-11 00:28:57 +11:00
|
|
|
|
2020-03-13 13:16:33 +11:00
|
|
|
function toggleConsole() {
|
|
|
|
if (debugConsole) {
|
|
|
|
debugConsole.visible = ! debugConsole.visible
|
|
|
|
|
|
|
|
} else if (! defaultDebugConsoleLoader.active) {
|
|
|
|
defaultDebugConsoleLoader.active = true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
defaultDebugConsole.visible = ! defaultDebugConsole.visible
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-23 04:16:49 +10:00
|
|
|
// App
|
2019-08-20 03:55:21 +10:00
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-09-06 05:05:57 +10:00
|
|
|
sequences: settings.keys.startPythonDebugger
|
2019-12-18 21:44:18 +11:00
|
|
|
onActivated: py.call("BRIDGE.pdb")
|
2019-07-21 08:08:58 +10:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:05:57 +10:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.toggleDebugConsole
|
2020-03-13 13:16:33 +11:00
|
|
|
onActivated: toggleConsole()
|
2019-09-06 05:05:57 +10:00
|
|
|
}
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.reloadConfig
|
2020-03-13 13:16:33 +11:00
|
|
|
onActivated: mainUI.reloadSettings()
|
2019-07-21 08:08:58 +10:00
|
|
|
}
|
2019-07-24 16:14:34 +10:00
|
|
|
|
2019-12-05 00:08:38 +11:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomIn
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: theme.uiScale += 0.1
|
2019-12-05 00:08:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomOut
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: theme.uiScale = Math.max(0.1, theme.uiScale - 0.1)
|
2019-12-05 00:08:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomReset
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: theme.uiScale = 1
|
2019-12-05 00:08:38 +11:00
|
|
|
}
|
|
|
|
|
2020-03-23 04:30:03 +11:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.toggleCompactMode
|
|
|
|
onActivated: {
|
|
|
|
settings.compactMode = ! settings.compactMode
|
|
|
|
settingsChanged()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-09 07:01:09 +11:00
|
|
|
// Pages
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.goToLastPage
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: mainUI.pageLoader.showPrevious()
|
2019-11-09 07:01:09 +11:00
|
|
|
}
|
|
|
|
|
2019-08-23 04:16:49 +10:00
|
|
|
// Page scrolling
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-23 03:03:26 +10:00
|
|
|
sequences: settings.keys.scrollUp
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickPages(toFlick, -1 / 10)
|
2019-08-20 04:05:59 +10:00
|
|
|
}
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-23 03:03:26 +10:00
|
|
|
sequences: settings.keys.scrollDown
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickPages(toFlick, 1 / 10)
|
2019-08-20 03:09:05 +10:00
|
|
|
}
|
|
|
|
|
2019-08-31 03:06:54 +10:00
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-31 03:06:54 +10:00
|
|
|
sequences: settings.keys.scrollPageUp
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickPages(toFlick, -1)
|
2019-08-31 03:06:54 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-31 03:06:54 +10:00
|
|
|
sequences: settings.keys.scrollPageDown
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickPages(toFlick, 1)
|
2019-08-31 03:06:54 +10:00
|
|
|
}
|
|
|
|
|
2019-08-31 03:40:56 +10:00
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-31 03:40:56 +10:00
|
|
|
sequences: settings.keys.scrollToTop
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickToTop(toFlick)
|
2019-08-31 03:40:56 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2019-12-10 04:00:42 +11:00
|
|
|
enabled: toFlick
|
2019-08-31 03:40:56 +10:00
|
|
|
sequences: settings.keys.scrollToBottom
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.flickToBottom(toFlick)
|
2019-08-31 03:40:56 +10:00
|
|
|
}
|
|
|
|
|
2019-08-31 03:06:54 +10:00
|
|
|
|
2019-11-11 00:28:57 +11:00
|
|
|
// Tab navigation
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: tabsTarget
|
|
|
|
sequences: settings.keys.previousTab
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: tabsTarget.setCurrentIndex(
|
2019-12-18 08:59:53 +11:00
|
|
|
utils.numberWrapAt(tabsTarget.currentIndex - 1, tabsTarget.count),
|
2019-11-11 00:28:57 +11:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: tabsTarget
|
|
|
|
sequences: settings.keys.nextTab
|
2019-12-09 03:42:40 +11:00
|
|
|
onActivated: tabsTarget.setCurrentIndex(
|
2019-12-18 08:59:53 +11:00
|
|
|
utils.numberWrapAt(tabsTarget.currentIndex + 1, tabsTarget.count),
|
2019-11-11 00:28:57 +11:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-11 06:17:41 +11:00
|
|
|
// MainPane
|
2019-08-23 04:16:49 +10:00
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-08-24 01:06:19 +10:00
|
|
|
enabled: mainUI.accountsPresent
|
2020-03-18 07:55:16 +11:00
|
|
|
sequences: settings.keys.toggleFocusMainPane
|
2019-12-11 06:17:41 +11:00
|
|
|
onActivated: mainUI.mainPane.toggleFocus()
|
2019-12-09 03:42:40 +11:00
|
|
|
context: Qt.ApplicationShortcut
|
2019-08-18 10:29:56 +10:00
|
|
|
}
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-08-24 01:06:19 +10:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-23 03:03:26 +10:00
|
|
|
sequences: settings.keys.clearRoomFilter
|
2020-03-13 14:23:21 +11:00
|
|
|
onActivated: mainUI.mainPane.bottomBar.roomFilter = ""
|
2019-08-20 04:28:12 +10:00
|
|
|
}
|
|
|
|
|
2019-08-24 01:02:22 +10:00
|
|
|
HShortcut {
|
2019-08-24 01:06:19 +10:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-24 01:02:22 +10:00
|
|
|
sequences: settings.keys.addNewAccount
|
2020-03-13 14:23:21 +11:00
|
|
|
onActivated: mainUI.mainPane.bottomBar.addAccountButton.clicked()
|
2019-08-24 01:02:22 +10:00
|
|
|
}
|
|
|
|
|
2019-11-10 23:32:17 +11:00
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.addNewChat
|
2019-12-11 06:17:41 +11:00
|
|
|
onActivated: mainUI.mainPane.mainPaneList.addNewChat()
|
2019-11-10 23:32:17 +11:00
|
|
|
}
|
|
|
|
|
2019-11-10 23:54:45 +11:00
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.accountSettings
|
2019-12-11 06:17:41 +11:00
|
|
|
onActivated: mainUI.mainPane.mainPaneList.accountSettings()
|
2019-11-10 23:54:45 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.toggleCollapseAccount
|
2019-12-11 06:17:41 +11:00
|
|
|
onActivated: mainUI.mainPane.mainPaneList.toggleCollapseAccount()
|
2019-11-10 23:54:45 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-08-24 01:06:19 +10:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-23 03:03:26 +10:00
|
|
|
sequences: settings.keys.goToPreviousRoom
|
2020-02-13 20:56:10 +11:00
|
|
|
onActivated: {
|
|
|
|
mainUI.mainPane.mainPaneList.previous()
|
|
|
|
mainUI.mainPane.mainPaneList.requestActivate()
|
|
|
|
}
|
2019-07-24 16:14:34 +10:00
|
|
|
}
|
|
|
|
|
2019-08-23 03:03:26 +10:00
|
|
|
HShortcut {
|
2019-08-24 01:06:19 +10:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-23 03:03:26 +10:00
|
|
|
sequences: settings.keys.goToNextRoom
|
2020-02-13 20:56:10 +11:00
|
|
|
onActivated: {
|
|
|
|
mainUI.mainPane.mainPaneList.next()
|
|
|
|
mainUI.mainPane.mainPaneList.requestActivate()
|
|
|
|
}
|
2019-07-24 16:14:34 +10:00
|
|
|
}
|
|
|
|
|
2020-03-23 05:07:49 +11:00
|
|
|
Repeater {
|
|
|
|
model: Object.keys(settings.keys.focusRoomAtIndex)
|
|
|
|
|
|
|
|
Item {
|
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequence: settings.keys.focusRoomAtIndex[modelData]
|
|
|
|
onActivated: mainUI.mainPane.mainPaneList.goToRoom(
|
|
|
|
parseInt(modelData - 1, 10),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 01:49:47 +10:00
|
|
|
|
|
|
|
// Chat
|
|
|
|
|
|
|
|
HShortcut {
|
2019-12-18 19:53:08 +11:00
|
|
|
enabled: window.uiState.page === "Pages/Chat/Chat.qml"
|
2019-09-09 01:49:47 +10:00
|
|
|
sequences: settings.keys.clearRoomMessages
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.makePopup(
|
2019-09-09 22:57:38 +10:00
|
|
|
"Popups/ClearMessagesPopup.qml",
|
2019-09-09 20:23:46 +10:00
|
|
|
mainUI,
|
|
|
|
{
|
|
|
|
userId: window.uiState.pageProperties.userId,
|
|
|
|
roomId: window.uiState.pageProperties.roomId,
|
|
|
|
}
|
2019-09-09 01:49:47 +10:00
|
|
|
)
|
|
|
|
}
|
2019-11-07 07:45:33 +11:00
|
|
|
|
|
|
|
HShortcut {
|
2019-12-18 19:53:08 +11:00
|
|
|
enabled: window.uiState.page === "Pages/Chat/Chat.qml"
|
2019-11-07 07:45:33 +11:00
|
|
|
sequences: settings.keys.sendFile
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.makeObject(
|
2019-11-07 07:45:33 +11:00
|
|
|
"Dialogs/SendFilePicker.qml",
|
|
|
|
mainUI,
|
|
|
|
{
|
2019-11-07 08:03:34 +11:00
|
|
|
userId: window.uiState.pageProperties.userId,
|
|
|
|
roomId: window.uiState.pageProperties.roomId,
|
2019-11-07 07:45:33 +11:00
|
|
|
destroyWhenDone: true,
|
|
|
|
},
|
|
|
|
picker => { picker.dialog.open() }
|
|
|
|
)
|
|
|
|
}
|
2019-11-07 08:03:34 +11:00
|
|
|
|
|
|
|
HShortcut {
|
2019-12-18 19:53:08 +11:00
|
|
|
enabled: window.uiState.page === "Pages/Chat/Chat.qml"
|
2019-11-07 08:03:34 +11:00
|
|
|
sequences: settings.keys.sendFileFromPathInClipboard
|
2019-12-18 08:59:53 +11:00
|
|
|
onActivated: utils.sendFile(
|
2019-11-07 08:03:34 +11:00
|
|
|
window.uiState.pageProperties.userId,
|
|
|
|
window.uiState.pageProperties.roomId,
|
|
|
|
Clipboard.text.trim(),
|
|
|
|
)
|
|
|
|
}
|
2020-03-18 07:52:14 +11:00
|
|
|
|
|
|
|
|
|
|
|
// RoomPane
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: window.uiState.page === "Pages/Chat/Chat.qml"
|
|
|
|
sequences: settings.keys.toggleFocusRoomPane
|
|
|
|
onActivated: mainUI.pageLoader.item.roomPane.toggleFocus()
|
|
|
|
context: Qt.ApplicationShortcut
|
|
|
|
}
|
2019-07-21 08:08:58 +10:00
|
|
|
}
|