Fix compiling on Qt 5.12 (clipboard lambda)

This commit is contained in:
miruka 2020-07-17 10:30:06 -04:00
parent 357affc4dd
commit bd30f89055
2 changed files with 15 additions and 10 deletions

View File

@ -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

View File

@ -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://<providerId>/<id>`
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>(
"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://<providerId>/<id>`
engine->addImageProvider(
"clipboard", new ClipboardImageProvider(clipboard)
);
return clipboard;
}
);