Refactor user_files module & add live reloading
- Cleaner design for the backend user_files classes and simplified interaction with QML - Config and theme files will now automatically reload when changed on disk - Removed manual reload keybind and button
This commit is contained in:
@@ -65,6 +65,19 @@ QtObject {
|
||||
py.showError(type, traceback, "", message)
|
||||
}
|
||||
|
||||
function onUserFileChanged(type, newData) {
|
||||
if (type === "Theme") {
|
||||
window.theme = Qt.createQmlObject(newData, window, "theme")
|
||||
utils.theme = window.theme
|
||||
return
|
||||
}
|
||||
|
||||
type === "Settings" ? window.settings = newData :
|
||||
type === "UIState" ? window.uiState = newData :
|
||||
type === "History" ? window.history = newData :
|
||||
null
|
||||
}
|
||||
|
||||
function onModelItemSet(syncId, indexThen, indexNow, changedFields) {
|
||||
const model = ModelStore.get(syncId)
|
||||
|
||||
|
@@ -47,23 +47,9 @@ Python {
|
||||
call("BRIDGE.cancel_coro", [uuid])
|
||||
}
|
||||
|
||||
function saveConfig(backend_attribute, data, callback=null) {
|
||||
if (! py.ready) { return } // config not loaded yet
|
||||
return callCoro(backend_attribute + ".write", [data], callback)
|
||||
}
|
||||
|
||||
function loadSettings(callback=null) {
|
||||
const func = "load_settings"
|
||||
|
||||
return callCoro(func, [], ([settings, uiState, history, theme]) => {
|
||||
window.settings = settings
|
||||
window.uiState = uiState
|
||||
window.history = history
|
||||
window.theme = Qt.createQmlObject(theme, window, "theme")
|
||||
utils.theme = window.theme
|
||||
|
||||
if (callback) { callback(settings, uiState, theme) }
|
||||
})
|
||||
function saveConfig(backend_attribute, data) {
|
||||
if (! py.ready) { return } // config not done loading yet
|
||||
callCoro(backend_attribute + ".set_data", [data])
|
||||
}
|
||||
|
||||
function showError(type, traceback, sourceIndication="", message="") {
|
||||
|
@@ -22,7 +22,13 @@ PythonBridge {
|
||||
addImportPath("qrc:/src")
|
||||
|
||||
importNames("backend.qml_bridge", ["BRIDGE"], () => {
|
||||
loadSettings(() => {
|
||||
callCoro("get_settings", [], ([settings, state, hist, theme]) => {
|
||||
window.settings = settings
|
||||
window.uiState = state
|
||||
window.history = hist
|
||||
window.theme = Qt.createQmlObject(theme, window, "theme")
|
||||
utils.theme = window.theme
|
||||
|
||||
callCoro("saved_accounts.any_saved", [], any => {
|
||||
if (any) { callCoro("load_saved_accounts", []) }
|
||||
|
||||
|
Reference in New Issue
Block a user