From bd30f89055c3a503c23dc439bc6dccb935c838b7 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 17 Jul 2020 10:30:06 -0400 Subject: [PATCH] Fix compiling on Qt 5.12 (clipboard lambda) --- .../Popups/ConfirmClipboardUploadPopup.qml | 5 ++++- src/main.cpp | 20 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) 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; } );