2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-12-18 09:07:38 +11:00
|
|
|
import QtQuick 2.12
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function onExitRequested(exitCode) {
|
|
|
|
Qt.exit(exitCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onAlertRequested() {
|
|
|
|
if (Qt.application.state !== Qt.ApplicationActive) {
|
|
|
|
window.alert(window.settings.alertOnMessageForMsec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onCoroutineDone(uuid, result, error, traceback) {
|
2019-12-18 21:16:24 +11:00
|
|
|
let onSuccess = py.privates.pendingCoroutines[uuid].onSuccess
|
|
|
|
let onError = py.privates.pendingCoroutines[uuid].onError
|
2019-12-18 09:07:38 +11:00
|
|
|
|
2019-12-27 00:20:51 +11:00
|
|
|
delete py.privates.pendingCoroutines[uuid]
|
|
|
|
|
2019-12-18 09:07:38 +11:00
|
|
|
if (error) {
|
2019-12-27 00:20:51 +11:00
|
|
|
const type = py.getattr(py.getattr(error, "__class__"), "__name__")
|
|
|
|
const args = py.getattr(error, "args")
|
2019-12-18 09:07:38 +11:00
|
|
|
|
2019-12-27 00:20:51 +11:00
|
|
|
if (type === "CancelledError") {
|
|
|
|
console.warn(`python: cancelled: ${uuid}`)
|
|
|
|
return
|
|
|
|
}
|
2019-12-18 09:07:38 +11:00
|
|
|
|
2019-12-27 00:20:51 +11:00
|
|
|
if (onError) {
|
|
|
|
onError(type, args, error, traceback)
|
|
|
|
return
|
|
|
|
}
|
2019-12-18 09:07:38 +11:00
|
|
|
|
|
|
|
console.error(`python: ${uuid}\n${traceback}`)
|
|
|
|
|
2019-12-27 00:20:51 +11:00
|
|
|
if (window.hideErrorTypes.has(type)) {
|
|
|
|
console.warn(
|
|
|
|
"Not showing error popup for this type due to user choice"
|
|
|
|
)
|
|
|
|
return
|
|
|
|
}
|
2019-12-18 09:07:38 +11:00
|
|
|
|
2019-12-27 00:20:51 +11:00
|
|
|
utils.makePopup(
|
|
|
|
"Popups/UnexpectedErrorPopup.qml",
|
|
|
|
window,
|
|
|
|
{ errorType: type, errorArguments: args, traceback },
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onSuccess) onSuccess(result)
|
2019-12-18 09:07:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onModelUpdated(syncId, data, serializedSyncId) {
|
|
|
|
if (serializedSyncId === "Account" || serializedSyncId[0] === "Room") {
|
|
|
|
py.callCoro("get_flat_mainpane_data", [], data => {
|
|
|
|
window.mainPaneModelSource = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
window.modelSources[serializedSyncId] = data
|
|
|
|
window.modelSourcesChanged()
|
|
|
|
}
|
|
|
|
}
|