diff options
Diffstat (limited to 'examples/qwebchannel')
-rw-r--r-- | examples/qwebchannel/exampleassets.pri | 31 | ||||
-rw-r--r-- | examples/qwebchannel/standalone/index.html | 2 | ||||
-rw-r--r-- | examples/qwebchannel/standalone/main.cpp | 2 | ||||
-rw-r--r-- | examples/qwebchannel/standalone/standalone.pro | 7 |
4 files changed, 38 insertions, 4 deletions
diff --git a/examples/qwebchannel/exampleassets.pri b/examples/qwebchannel/exampleassets.pri new file mode 100644 index 0000000..035ca12 --- /dev/null +++ b/examples/qwebchannel/exampleassets.pri @@ -0,0 +1,31 @@ +# This adds the qwebchannel js library to an example, creating a self-contained bundle +QTDIR_build { + # Build from within Qt. Copy and install the reference lib. + jslib = $$dirname(_QMAKE_CONF_)/src/webchannel/qwebchannel.js + copyfiles = $$jslib +} else { + # This is what an actual 3rd party project would do. + jslib = qwebchannel.js +} + +# This installs all assets including qwebchannel.js, regardless of the source. +exampleassets.files += $$jslib +INSTALLS += exampleassets + +# This code ensures that all assets are present in the build directory. + +!equals(_PRO_FILE_PWD_, $$OUT_PWD) { + # Shadow build, copy all example assets. + copyfiles = $$exampleassets.files +} + +defineReplace(stripSrcDir) { + return($$basename(1)) +} + +assetcopy.input = copyfiles +assetcopy.output = $$OUT_PWD/${QMAKE_FUNC_FILE_IN_stripSrcDir} +assetcopy.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +assetcopy.name = COPY ${QMAKE_FILE_IN} +assetcopy.CONFIG = no_link target_predeps +QMAKE_EXTRA_COMPILERS += assetcopy diff --git a/examples/qwebchannel/standalone/index.html b/examples/qwebchannel/standalone/index.html index 8c85143..778a502 100644 --- a/examples/qwebchannel/standalone/index.html +++ b/examples/qwebchannel/standalone/index.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <script type="text/javascript" src="../../../src/webchannel/qwebchannel.js"></script> + <script type="text/javascript" src="./qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP function output(message) diff --git a/examples/qwebchannel/standalone/main.cpp b/examples/qwebchannel/standalone/main.cpp index cc22ed3..fa3912d 100644 --- a/examples/qwebchannel/standalone/main.cpp +++ b/examples/qwebchannel/standalone/main.cpp @@ -139,7 +139,7 @@ int main(int argc, char** argv) channel.registerObject(QStringLiteral("dialog"), &dialog); // open a browser window with the client HTML page - QUrl url = QUrl::fromLocalFile(SOURCE_DIR "/index.html"); + QUrl url = QUrl::fromLocalFile(BUILD_DIR "/index.html"); url.setQuery(QStringLiteral("webChannelBaseUrl=") + server.serverUrl().toString()); QDesktopServices::openUrl(url); diff --git a/examples/qwebchannel/standalone/standalone.pro b/examples/qwebchannel/standalone/standalone.pro index 6b96169..fdeb87a 100644 --- a/examples/qwebchannel/standalone/standalone.pro +++ b/examples/qwebchannel/standalone/standalone.pro @@ -14,6 +14,9 @@ HEADERS += \ FORMS += \ dialog.ui -DEFINES += "SOURCE_DIR=\"\\\""$$PWD"\\\"\"" +DEFINES += "BUILD_DIR=\"\\\""$$OUT_PWD"\\\"\"" -EXAMPLE_FILES += index.html +exampleassets.files += \ + index.html +exampleassets.path = $$[QT_INSTALL_EXAMPLES]/qwebchannel/standalone +include(../exampleassets.pri) |