From efd1a29927a28bb9d153c6113fe9b119af420105 Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Sun, 27 Mar 2016 10:40:35 +0200 Subject: [PATCH] Added example for showing load of qmls from resources --- examples/resourcebundling/.gitignore | 3 +++ examples/resourcebundling/main.nim | 16 ++++++++++++++++ examples/resourcebundling/main.nim.cfg | 2 ++ examples/resourcebundling/main.qml | 11 +++++++++++ .../resourcebundling/resourcebundling.nimble | 19 +++++++++++++++++++ examples/resourcebundling/resources.qrc | 6 ++++++ 6 files changed, 57 insertions(+) create mode 100644 examples/resourcebundling/.gitignore create mode 100644 examples/resourcebundling/main.nim create mode 100644 examples/resourcebundling/main.nim.cfg create mode 100644 examples/resourcebundling/main.qml create mode 100644 examples/resourcebundling/resourcebundling.nimble create mode 100644 examples/resourcebundling/resources.qrc diff --git a/examples/resourcebundling/.gitignore b/examples/resourcebundling/.gitignore new file mode 100644 index 0000000..7e21100 --- /dev/null +++ b/examples/resourcebundling/.gitignore @@ -0,0 +1,3 @@ +nimcache +main +*.rcc \ No newline at end of file diff --git a/examples/resourcebundling/main.nim b/examples/resourcebundling/main.nim new file mode 100644 index 0000000..271496e --- /dev/null +++ b/examples/resourcebundling/main.nim @@ -0,0 +1,16 @@ +import nimqml + +proc mainProc() = + let app = newQApplication() + defer: app.delete + let engine = newQQmlApplicationEngine() + defer: engine.delete + let appDirPath = app.applicationDirPath & "/" & "main.rcc" + QResource.registerResource(appDirPath) + engine.load(newQUrl("qrc:///main.qml")) + + app.exec() + +when isMainModule: + mainProc() + GC_fullcollect() diff --git a/examples/resourcebundling/main.nim.cfg b/examples/resourcebundling/main.nim.cfg new file mode 100644 index 0000000..7ae8bee --- /dev/null +++ b/examples/resourcebundling/main.nim.cfg @@ -0,0 +1,2 @@ +--passL:"-lDOtherSide" +--path:"../../src" diff --git a/examples/resourcebundling/main.qml b/examples/resourcebundling/main.qml new file mode 100644 index 0000000..b6132f0 --- /dev/null +++ b/examples/resourcebundling/main.qml @@ -0,0 +1,11 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.1 + +ApplicationWindow { + width: 400 + height: 300 + title: "Hello World" + Component.onCompleted: visible = true +} diff --git a/examples/resourcebundling/resourcebundling.nimble b/examples/resourcebundling/resourcebundling.nimble new file mode 100644 index 0000000..1a5eada --- /dev/null +++ b/examples/resourcebundling/resourcebundling.nimble @@ -0,0 +1,19 @@ +# Package + +version = "0.1.0" +author = "Filippo Cucchetto" +description = "resourcebundling" +license = "MIT" + +bin = @["resourcebundling"] + +# Dependencies + +requires "nimqml >= 0.5.0" + +task compileresources, "Compile the qrc into rcc": + exec ("rcc --binary resources.qrc -o main.rcc") + setCommand("nop") + +task compilebinary, "Compile the binary": + setCommand "c" diff --git a/examples/resourcebundling/resources.qrc b/examples/resourcebundling/resources.qrc new file mode 100644 index 0000000..e295b13 --- /dev/null +++ b/examples/resourcebundling/resources.qrc @@ -0,0 +1,6 @@ + + + + main.qml + +