Turn Clipboard into a singleton
This commit is contained in:
parent
f34d2a1c6d
commit
a1256cf20a
|
@ -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 Clipboard 0.1
|
||||||
|
|
||||||
FocusScope {
|
FocusScope {
|
||||||
signal deselectAll()
|
signal deselectAll()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
import Clipboard 0.1
|
||||||
import "Base"
|
import "Base"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import Clipboard 0.1
|
||||||
import "../Base"
|
import "../Base"
|
||||||
|
|
||||||
HTileDelegate {
|
HTileDelegate {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import Clipboard 0.1
|
||||||
import "../Base"
|
import "../Base"
|
||||||
|
|
||||||
HTileDelegate {
|
HTileDelegate {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import Clipboard 0.1
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
import "../../Dialogs"
|
import "../../Dialogs"
|
||||||
|
|
||||||
|
|
|
@ -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 Clipboard 0.1
|
||||||
import "../../../Base"
|
import "../../../Base"
|
||||||
|
|
||||||
HTileDelegate {
|
HTileDelegate {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import Clipboard 0.1
|
||||||
import "../../../Base"
|
import "../../../Base"
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -37,11 +37,19 @@ int main(int argc, char *argv[]) {
|
||||||
objectContext->setContextProperty("debugMode", false);
|
objectContext->setContextProperty("debugMode", false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add our custom non-visual `QObject `s as properties.
|
// Register our custom non-visual QObject singletons,
|
||||||
// Their attributes and methods will be accessing like normal QML objects.
|
// that will be importable anywhere in QML. Example:
|
||||||
/* objectContext->setContextProperty("CppUtils", new Utils()); */
|
// import Clipboard 0.1
|
||||||
objectContext->setContextProperty("Clipboard", new Clipboard());
|
// ...
|
||||||
|
// Component.onCompleted: print(Clipboard.text)
|
||||||
|
qmlRegisterSingletonType<Clipboard>(
|
||||||
|
"Clipboard", 0, 1, "Clipboard",
|
||||||
|
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
Q_UNUSED(scriptEngine)
|
||||||
|
return new Clipboard();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
qmlRegisterSingletonType<Utils>(
|
qmlRegisterSingletonType<Utils>(
|
||||||
"CppUtils", 0, 1, "CppUtils",
|
"CppUtils", 0, 1, "CppUtils",
|
||||||
|
@ -52,8 +60,10 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Register our custom visual items that will be importable from QML,
|
// Register our custom visual items that will be importable from QML, e.g.
|
||||||
// e.g. `import RadialBar 1.0`
|
// import RadialBar 1.0
|
||||||
|
// ...
|
||||||
|
// RadialBar { ... }
|
||||||
qmlRegisterType<RadialBar>("RadialBar", 1, 0, "RadialBar");
|
qmlRegisterType<RadialBar>("RadialBar", 1, 0, "RadialBar");
|
||||||
|
|
||||||
// Create the QML root component by loading its file from the Qt Resource
|
// Create the QML root component by loading its file from the Qt Resource
|
||||||
|
|
Loading…
Reference in New Issue
Block a user