Turn CppUtils into a Singleton
This commit is contained in:
parent
e7caa0b8ef
commit
f34d2a1c6d
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import CppUtils 0.1
|
||||||
import "../../../Base"
|
import "../../../Base"
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import CppUtils 0.1
|
||||||
import "../../../Base"
|
import "../../../Base"
|
||||||
|
|
||||||
HTile {
|
HTile {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import io.thp.pyotherside 1.5
|
import io.thp.pyotherside 1.5
|
||||||
|
import CppUtils 0.1
|
||||||
|
|
||||||
Python {
|
Python {
|
||||||
id: py
|
id: py
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
import CppUtils 0.1
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
function makeObject(urlComponent, parent=null, properties={},
|
function makeObject(urlComponent, parent=null, properties={},
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -39,9 +39,19 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Add our custom non-visual `QObject `s as properties.
|
// Add our custom non-visual `QObject `s as properties.
|
||||||
// Their attributes and methods will be accessing like normal QML objects.
|
// 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());
|
objectContext->setContextProperty("Clipboard", new Clipboard());
|
||||||
|
|
||||||
|
|
||||||
|
qmlRegisterSingletonType<Utils>(
|
||||||
|
"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,
|
// Register our custom visual items that will be importable from QML,
|
||||||
// e.g. `import RadialBar 1.0`
|
// e.g. `import RadialBar 1.0`
|
||||||
qmlRegisterType<RadialBar>("RadialBar", 1, 0, "RadialBar");
|
qmlRegisterType<RadialBar>("RadialBar", 1, 0, "RadialBar");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user