2019-07-20 18:08:58 -04:00
|
|
|
import QtQuick 2.12
|
2019-11-10 09:28:57 -04:00
|
|
|
import QtQuick.Controls 2.12
|
2019-08-22 13:03:26 -04:00
|
|
|
import "Base"
|
|
|
|
import "utils.js" as Utils
|
2019-07-20 18:08:58 -04:00
|
|
|
|
2019-12-08 12:42:40 -04:00
|
|
|
Item {
|
|
|
|
visible: false
|
|
|
|
|
2019-11-10 09:28:57 -04:00
|
|
|
// Flickable or ListView that should be affected by scroll shortcuts
|
2019-09-19 16:47:35 -04:00
|
|
|
property Item flickTarget
|
2019-11-10 09:28:57 -04:00
|
|
|
|
|
|
|
// TabBar that should be affected by tab navigation shortcuts
|
|
|
|
property TabBar tabsTarget
|
|
|
|
|
|
|
|
// DebugConsole that should be affected by console shortcuts
|
2019-09-19 16:47:35 -04:00
|
|
|
property DebugConsole debugConsole
|
2019-07-20 18:08:58 -04:00
|
|
|
|
2019-11-10 09:28:57 -04:00
|
|
|
|
2019-08-22 14:16:49 -04:00
|
|
|
// App
|
2019-08-19 13:55:21 -04:00
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
|
|
|
enabled: debugMode
|
2019-09-05 15:05:57 -04:00
|
|
|
sequences: settings.keys.startPythonDebugger
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: py.call("APP.pdb")
|
2019-07-20 18:08:58 -04:00
|
|
|
}
|
|
|
|
|
2019-09-05 15:05:57 -04:00
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: debugMode && debugConsole
|
2019-09-05 15:05:57 -04:00
|
|
|
sequences: settings.keys.toggleDebugConsole
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: debugConsole.visible = ! debugConsole.visible
|
2019-09-05 15:05:57 -04:00
|
|
|
}
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.reloadConfig
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: py.loadSettings(() => { mainUI.pressAnimation.start() })
|
2019-07-20 18:08:58 -04:00
|
|
|
}
|
2019-07-24 02:14:34 -04:00
|
|
|
|
2019-12-04 09:08:38 -04:00
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomIn
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: theme.uiScale += 0.1
|
2019-12-04 09:08:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomOut
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: theme.uiScale = Math.max(0.1, theme.uiScale - 0.1)
|
2019-12-04 09:08:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.zoomReset
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: theme.uiScale = 1
|
2019-12-04 09:08:38 -04:00
|
|
|
}
|
|
|
|
|
2019-11-08 16:01:09 -04:00
|
|
|
// Pages
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: settings.keys.goToLastPage
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.pageLoader.showPrevious()
|
2019-11-08 16:01:09 -04:00
|
|
|
}
|
|
|
|
|
2019-08-22 14:16:49 -04:00
|
|
|
// Page scrolling
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.scrollUp
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.smartVerticalFlick(flickTarget, -335)
|
2019-08-19 14:05:59 -04:00
|
|
|
}
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.scrollDown
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.smartVerticalFlick(flickTarget, 335)
|
2019-08-19 13:09:05 -04:00
|
|
|
}
|
|
|
|
|
2019-08-30 13:06:54 -04:00
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-30 13:06:54 -04:00
|
|
|
sequences: settings.keys.scrollPageUp
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.smartVerticalFlick(
|
2019-09-06 17:03:52 -04:00
|
|
|
flickTarget, -2.3 * flickTarget.height, 8,
|
2019-08-30 13:06:54 -04:00
|
|
|
)
|
2019-09-06 17:03:52 -04:00
|
|
|
// Ensure only a slight slip after releasing the key
|
2019-12-08 12:42:40 -04:00
|
|
|
// onReleased: Utils.smartVerticalFlick(flickTarget, -335)
|
2019-08-30 13:06:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-30 13:06:54 -04:00
|
|
|
sequences: settings.keys.scrollPageDown
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.smartVerticalFlick(
|
2019-09-06 17:03:52 -04:00
|
|
|
flickTarget, 2.3 * flickTarget.height, 8,
|
2019-08-30 13:06:54 -04:00
|
|
|
)
|
2019-12-08 12:42:40 -04:00
|
|
|
// onReleased: Utils.smartVerticalFlick(flickTarget, 335)
|
2019-08-30 13:06:54 -04:00
|
|
|
}
|
|
|
|
|
2019-08-30 13:40:56 -04:00
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-30 13:40:56 -04:00
|
|
|
sequences: settings.keys.scrollToTop
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.flickToTop(flickTarget)
|
2019-08-30 13:40:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2019-09-19 16:47:35 -04:00
|
|
|
enabled: flickTarget
|
2019-08-30 13:40:56 -04:00
|
|
|
sequences: settings.keys.scrollToBottom
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.flickToBottom(flickTarget)
|
2019-08-30 13:40:56 -04:00
|
|
|
}
|
|
|
|
|
2019-08-30 13:06:54 -04:00
|
|
|
|
2019-11-10 09:28:57 -04:00
|
|
|
// Tab navigation
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: tabsTarget
|
|
|
|
sequences: settings.keys.previousTab
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: tabsTarget.setCurrentIndex(
|
2019-11-10 09:28:57 -04:00
|
|
|
Utils.numberWrapAt(tabsTarget.currentIndex - 1, tabsTarget.count),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: tabsTarget
|
|
|
|
sequences: settings.keys.nextTab
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: tabsTarget.setCurrentIndex(
|
2019-11-10 09:28:57 -04:00
|
|
|
Utils.numberWrapAt(tabsTarget.currentIndex + 1, tabsTarget.count),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-22 14:16:49 -04:00
|
|
|
// SidePane
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-08-23 11:06:19 -04:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.focusSidePane
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.toggleFocus()
|
|
|
|
context: Qt.ApplicationShortcut
|
2019-08-17 20:29:56 -04:00
|
|
|
}
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-08-23 11:06:19 -04:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.clearRoomFilter
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.toolBar.roomFilter = ""
|
2019-08-19 14:28:12 -04:00
|
|
|
}
|
|
|
|
|
2019-08-23 11:02:22 -04:00
|
|
|
HShortcut {
|
2019-08-23 11:06:19 -04:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-23 11:02:22 -04:00
|
|
|
sequences: settings.keys.addNewAccount
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.toolBar.addAccountButton.clicked()
|
2019-08-23 11:02:22 -04:00
|
|
|
}
|
|
|
|
|
2019-11-10 08:32:17 -04:00
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.addNewChat
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.sidePaneList.addNewChat()
|
2019-11-10 08:32:17 -04:00
|
|
|
}
|
|
|
|
|
2019-11-10 08:54:45 -04:00
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.accountSettings
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.sidePaneList.accountSettings()
|
2019-11-10 08:54:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: mainUI.accountsPresent
|
|
|
|
sequences: settings.keys.toggleCollapseAccount
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.sidePaneList.toggleCollapseAccount()
|
2019-11-10 08:54:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-08-23 11:06:19 -04:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.goToPreviousRoom
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.sidePaneList.previous()
|
2019-07-24 02:14:34 -04:00
|
|
|
}
|
|
|
|
|
2019-08-22 13:03:26 -04:00
|
|
|
HShortcut {
|
2019-08-23 11:06:19 -04:00
|
|
|
enabled: mainUI.accountsPresent
|
2019-08-22 13:03:26 -04:00
|
|
|
sequences: settings.keys.goToNextRoom
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: mainUI.sidePane.sidePaneList.next()
|
2019-07-24 02:14:34 -04:00
|
|
|
}
|
|
|
|
|
2019-09-08 11:49:47 -04:00
|
|
|
|
|
|
|
// Chat
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: window.uiState.page == "Chat/Chat.qml"
|
|
|
|
sequences: settings.keys.clearRoomMessages
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.makePopup(
|
2019-09-09 08:57:38 -04:00
|
|
|
"Popups/ClearMessagesPopup.qml",
|
2019-09-09 06:23:46 -04:00
|
|
|
mainUI,
|
|
|
|
{
|
|
|
|
userId: window.uiState.pageProperties.userId,
|
|
|
|
roomId: window.uiState.pageProperties.roomId,
|
|
|
|
}
|
2019-09-08 11:49:47 -04:00
|
|
|
)
|
|
|
|
}
|
2019-11-06 16:45:33 -04:00
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: window.uiState.page == "Chat/Chat.qml"
|
|
|
|
sequences: settings.keys.sendFile
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.makeObject(
|
2019-11-06 16:45:33 -04:00
|
|
|
"Dialogs/SendFilePicker.qml",
|
|
|
|
mainUI,
|
|
|
|
{
|
2019-11-06 17:03:34 -04:00
|
|
|
userId: window.uiState.pageProperties.userId,
|
|
|
|
roomId: window.uiState.pageProperties.roomId,
|
2019-11-06 16:45:33 -04:00
|
|
|
destroyWhenDone: true,
|
|
|
|
},
|
|
|
|
picker => { picker.dialog.open() }
|
|
|
|
)
|
|
|
|
}
|
2019-11-06 17:03:34 -04:00
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
enabled: window.uiState.page == "Chat/Chat.qml"
|
|
|
|
sequences: settings.keys.sendFileFromPathInClipboard
|
2019-12-08 12:42:40 -04:00
|
|
|
onActivated: Utils.sendFile(
|
2019-11-06 17:03:34 -04:00
|
|
|
window.uiState.pageProperties.userId,
|
|
|
|
window.uiState.pageProperties.roomId,
|
|
|
|
Clipboard.text.trim(),
|
|
|
|
)
|
|
|
|
}
|
2019-07-20 18:08:58 -04:00
|
|
|
}
|