Add keybind to reload config file (default Alt+R)

This commit is contained in:
miruka 2019-07-24 17:26:40 -04:00
parent cf5d76dd10
commit eb97f08d6a
3 changed files with 18 additions and 7 deletions

View File

@ -108,10 +108,10 @@ class UISettings(JSONConfigFile):
"theme": "Default.qpl", "theme": "Default.qpl",
"writeAliases": {}, "writeAliases": {},
"keys": { "keys": {
"reloadConfig": ["Alt+R"],
"scrollUp": ["Alt+Up", "Alt+K"], "scrollUp": ["Alt+Up", "Alt+K"],
"scrollDown": ["Alt+Down", "Alt+J"], "scrollDown": ["Alt+Down", "Alt+J"],
"startDebugger": ["Alt+Shift+D"], "startDebugger": ["Alt+Shift+D"],
"reloadConfig": ["Alt+R"],
}, },
} }

View File

@ -40,6 +40,16 @@ Python {
callCoro(backend_attribute + ".write", [data], callback) callCoro(backend_attribute + ".write", [data], callback)
} }
function loadSettings(callback=null) {
callCoro("load_settings", [], ([settings, uiState, theme]) => {
window.settings = settings
window.uiState = uiState
window.theme = Qt.createQmlObject(theme, window, "theme")
if (callback) { callback(settings, uiState, theme) }
})
}
Component.onCompleted: { Component.onCompleted: {
for (var func in EventHandlers) { for (var func in EventHandlers) {
if (EventHandlers.hasOwnProperty(func)) { if (EventHandlers.hasOwnProperty(func)) {
@ -53,11 +63,7 @@ Python {
call("APP.is_debug_on", [Qt.application.arguments], on => { call("APP.is_debug_on", [Qt.application.arguments], on => {
window.debug = on window.debug = on
callCoro("load_settings", [], ([settings, uiState, theme]) => { loadSettings(() => {
window.settings = settings
window.uiState = uiState
window.theme = Qt.createQmlObject(theme, window, "theme")
callCoro("saved_accounts.any_saved", [], any => { callCoro("saved_accounts.any_saved", [], any => {
py.ready = true py.ready = true
willLoadAccounts(any) willLoadAccounts(any)

View File

@ -17,6 +17,11 @@ Item {
flickTarget.flick(0, baseVelocity * (fast ? fastMultiply : 1)) flickTarget.flick(0, baseVelocity * (fast ? fastMultiply : 1))
} }
Shortcut {
sequences: settings.keys ? settings.keys.reloadConfig : []
onActivated: py.loadSettings()
}
Shortcut { Shortcut {
sequences: settings.keys ? settings.keys.scrollUp : [] sequences: settings.keys ? settings.keys.scrollUp : []
onActivated: smartVerticalFlick(-335) onActivated: smartVerticalFlick(-335)
@ -28,7 +33,7 @@ Item {
} }
Shortcut { Shortcut {
sequence: settings.keys ? settings.keys.startDebugger : [] sequences: settings.keys ? settings.keys.startDebugger : []
onActivated: if (window.debug) { py.call("APP.pdb") } onActivated: if (window.debug) { py.call("APP.pdb") }
} }