diff --git a/src/gui/Pages/Chat/FileTransfer/Transfer.qml b/src/gui/Pages/Chat/FileTransfer/Transfer.qml index cbe3e960..9cd64e02 100644 --- a/src/gui/Pages/Chat/FileTransfer/Transfer.qml +++ b/src/gui/Pages/Chat/FileTransfer/Transfer.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 +import CppUtils 0.1 import "../../../Base" HColumnLayout { diff --git a/src/gui/Pages/Chat/Timeline/EventFile.qml b/src/gui/Pages/Chat/Timeline/EventFile.qml index 4267deb7..3015dd58 100644 --- a/src/gui/Pages/Chat/Timeline/EventFile.qml +++ b/src/gui/Pages/Chat/Timeline/EventFile.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 +import CppUtils 0.1 import "../../../Base" HTile { diff --git a/src/gui/PythonBridge/PythonBridge.qml b/src/gui/PythonBridge/PythonBridge.qml index 14f72571..565d28bd 100644 --- a/src/gui/PythonBridge/PythonBridge.qml +++ b/src/gui/PythonBridge/PythonBridge.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import io.thp.pyotherside 1.5 +import CppUtils 0.1 Python { id: py diff --git a/src/gui/Utils.qml b/src/gui/Utils.qml index 14cd543c..1750ed7f 100644 --- a/src/gui/Utils.qml +++ b/src/gui/Utils.qml @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later import QtQuick 2.12 +import CppUtils 0.1 QtObject { function makeObject(urlComponent, parent=null, properties={}, diff --git a/src/main.cpp b/src/main.cpp index a3f19573..66ca27f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,9 +39,19 @@ int main(int argc, char *argv[]) { // Add our custom non-visual `QObject `s as properties. // Their attributes and methods will be accessing like normal QML objects. - objectContext->setContextProperty("CppUtils", new Utils()); + /* objectContext->setContextProperty("CppUtils", new Utils()); */ objectContext->setContextProperty("Clipboard", new Clipboard()); + + qmlRegisterSingletonType( + "CppUtils", 0, 1, "CppUtils", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + return new Utils(); + } + ); + // Register our custom visual items that will be importable from QML, // e.g. `import RadialBar 1.0` qmlRegisterType("RadialBar", 1, 0, "RadialBar");