diff --git a/src/gui/Popups/ConfirmClipboardUploadPopup.qml b/src/gui/Popups/ConfirmClipboardUploadPopup.qml index d97d34f8..4564cb19 100644 --- a/src/gui/Popups/ConfirmClipboardUploadPopup.qml +++ b/src/gui/Popups/ConfirmClipboardUploadPopup.qml @@ -3,9 +3,12 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 -import Clipboard 0.1 import "../Base" import "../Base/Buttons" +// +// Make sure to initialize the image provider by +// importing this first: +import Clipboard 0.1 HColumnPopup { id: popup diff --git a/src/main.cpp b/src/main.cpp index aa0b1a80..f56b9832 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -145,13 +145,6 @@ int main(int argc, char *argv[]) { objectContext->setContextProperty("debugMode", false); #endif - Clipboard *clipboard = new Clipboard(); - - // Register out custom image providers. - // QML will be able to request an image from them by setting an - // `Image`'s `source` to `image:///` - engine.addImageProvider("clipboard",new ClipboardImageProvider(clipboard)); - // Register our custom non-visual QObject singletons, // that will be importable anywhere in QML. Example: // import Clipboard 0.1 @@ -159,9 +152,18 @@ int main(int argc, char *argv[]) { // Component.onCompleted: print(Clipboard.text) qmlRegisterSingletonType( "Clipboard", 0, 1, "Clipboard", - [clipboard](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { - Q_UNUSED(engine) + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(scriptEngine) + + Clipboard *clipboard = new Clipboard(); + + // Register out custom image providers. + // QML will be able to request an image from them by setting an + // `Image`'s `source` to `image:///` + engine->addImageProvider( + "clipboard", new ClipboardImageProvider(clipboard) + ); + return clipboard; } );