2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-12-17 18:07:38 -04:00
|
|
|
import QtQuick 2.12
|
2019-12-02 16:29:29 -04:00
|
|
|
import ".."
|
|
|
|
import "../.."
|
2019-12-17 18:07:38 -04:00
|
|
|
|
|
|
|
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) {
|
2020-03-08 04:46:20 -04:00
|
|
|
const onSuccess = Globals.pendingCoroutines[uuid].onSuccess
|
|
|
|
const onError = Globals.pendingCoroutines[uuid].onError
|
2019-12-17 18:07:38 -04:00
|
|
|
|
2019-12-02 16:29:29 -04:00
|
|
|
delete Globals.pendingCoroutines[uuid]
|
2019-12-26 09:20:51 -04:00
|
|
|
|
2019-12-17 18:07:38 -04:00
|
|
|
if (error) {
|
2019-12-26 09:20:51 -04:00
|
|
|
const type = py.getattr(py.getattr(error, "__class__"), "__name__")
|
|
|
|
const args = py.getattr(error, "args")
|
2019-12-17 18:07:38 -04:00
|
|
|
|
2020-03-13 02:52:38 -04:00
|
|
|
if (type === "CancelledError") return
|
2019-12-17 18:07:38 -04:00
|
|
|
|
2020-03-15 15:40:53 -04:00
|
|
|
onError ?
|
|
|
|
onError(type, args, error, traceback, uuid) :
|
2020-03-22 20:58:24 -04:00
|
|
|
utils.showError(type, traceback, "", uuid)
|
2020-03-15 15:40:53 -04:00
|
|
|
|
|
|
|
return
|
2019-12-26 09:20:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (onSuccess) onSuccess(result)
|
2019-12-17 18:07:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-26 10:05:01 -04:00
|
|
|
function onLoopException(message, error, traceback) {
|
|
|
|
// No need to log these here, the asyncio exception handler does it
|
|
|
|
const type = py.getattr(py.getattr(error, "__class__"), "__name__")
|
2020-03-22 20:58:24 -04:00
|
|
|
utils.showError(type, traceback, message)
|
2019-12-26 10:05:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-02 16:29:29 -04:00
|
|
|
function onModelItemInserted(syncId, index, item) {
|
2020-03-15 17:26:41 -04:00
|
|
|
// print("insert", syncId, index, item)
|
2019-12-02 16:29:29 -04:00
|
|
|
ModelStore.get(syncId).insert(index, item)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onModelItemFieldChanged(syncId, oldIndex, newIndex, field, value){
|
2020-03-15 17:26:41 -04:00
|
|
|
// print("change", syncId, oldIndex, newIndex, field, value)
|
2019-12-02 16:29:29 -04:00
|
|
|
const model = ModelStore.get(syncId)
|
|
|
|
model.setProperty(oldIndex, field, value)
|
|
|
|
|
|
|
|
if (oldIndex !== newIndex) model.move(oldIndex, newIndex, 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onModelItemDeleted(syncId, index) {
|
|
|
|
// print("del", syncId, index)
|
|
|
|
ModelStore.get(syncId).remove(index)
|
|
|
|
}
|
|
|
|
|
2019-12-17 18:07:38 -04:00
|
|
|
|
2019-12-02 16:29:29 -04:00
|
|
|
function onModelCleared(syncId) {
|
|
|
|
// print("clear", syncId)
|
|
|
|
ModelStore.get(syncId).clear()
|
2019-12-17 18:07:38 -04:00
|
|
|
}
|
|
|
|
}
|