2023-01-13 13:36:12 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
2024-10-31 22:52:08 +00:00
|
|
|
import QtQml 2.15
|
2023-01-13 13:36:12 +00:00
|
|
|
|
|
|
|
import Monitoring 1.0
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function typeName(obj) {
|
|
|
|
const type = Monitor.typeName(obj)
|
|
|
|
|
|
|
|
if (type === "QJSValue")
|
|
|
|
return typeof obj
|
|
|
|
|
|
|
|
return type
|
|
|
|
}
|
|
|
|
|
|
|
|
function valueToString(val) {
|
|
|
|
if (val === undefined)
|
|
|
|
return "undefined"
|
|
|
|
|
|
|
|
if (val === null)
|
|
|
|
return "null"
|
|
|
|
|
|
|
|
const str = val.toString()
|
|
|
|
|
|
|
|
if (typeof val === "string")
|
|
|
|
return `"${str}"`
|
|
|
|
|
|
|
|
if (typeof val !== "object")
|
|
|
|
return str
|
|
|
|
|
|
|
|
const bracketPos = str.indexOf("(")
|
|
|
|
|
|
|
|
if (bracketPos === -1)
|
|
|
|
return str
|
|
|
|
|
|
|
|
return str.substring(bracketPos + 1, str.length - 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
function contextPropertyBindingHelper(name, parent) {
|
|
|
|
return Qt.createQmlObject(
|
2024-10-31 22:52:08 +00:00
|
|
|
`import QtQml 2.15; QtObject { readonly property var value: ${name} }`,
|
2023-01-13 13:36:12 +00:00
|
|
|
parent, `ctxPropHelperSnippet_${name}`)
|
|
|
|
}
|
|
|
|
}
|