diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-09-17 11:22:59 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-09-19 13:04:51 +0200 |
commit | bf249abee98727d517f52b1126dc7fda8af4e302 (patch) | |
tree | ffa65d8d74a48552ae4f7f7577f013871cd09c8f | |
parent | ee083ce7fe84c2173ee4d19666d5547210c63266 (diff) | |
download | qtsvg-bf249abee98727d517f52b1126dc7fda8af4e302.tar.gz |
Fix shadow build behavior of fluidlauncher example
All files are embedded into a qrc file.
The image lookup first assumes that local dirs are used. If nothing is
found the lookup moves to the qrc file. This enables flexibility whereby
the app can still be customized after having been built.
Task-number: QTBUG-28377
Change-Id: I99371ecce08a45321e475a7c32d5b368716bdb18
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
5 files changed, 67 insertions, 3 deletions
diff --git a/examples/svg/embedded/fluidlauncher/demoapplication.cpp b/examples/svg/embedded/fluidlauncher/demoapplication.cpp index a01894f..dfba309 100644 --- a/examples/svg/embedded/fluidlauncher/demoapplication.cpp +++ b/examples/svg/embedded/fluidlauncher/demoapplication.cpp @@ -48,6 +48,11 @@ DemoApplication::DemoApplication(QString executableName, QString caption, QStrin else executablePath = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + executableName); +#ifdef WIN32 + if (!executablePath.endsWith(QLatin1String(".exe"))) + executablePath.append(QLatin1String(".exe")); +#endif + arguments = args; process.setProcessChannelMode(QProcess::ForwardedChannels); @@ -69,7 +74,17 @@ void DemoApplication::launch() QImage DemoApplication::getImage() const { - return imagePath.isEmpty() ? QImage() : QImage(imagePath); + if (imagePath.isEmpty()) + return QImage(); + + // in local dir? + QImage result(imagePath); + if (!result.isNull()) + return result; + + // provided by qrc + result = QImage(QString(":/fluidlauncher/%1").arg(imagePath)); + return result; } QString DemoApplication::getCaption() diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp b/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp index 599bd56..e9e6492 100644 --- a/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp @@ -72,7 +72,7 @@ FluidLauncher::FluidLauncher(QStringList* args) if ( (configIndex != -1) && (configIndex != args->count()-1) ) success = loadConfig(args->at(configIndex+1)); else - success = loadConfig("config.xml"); + success = loadConfig(":/fluidlauncher/config.xml"); if (success) { populatePictureFlow(); diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.pro b/examples/svg/embedded/fluidlauncher/fluidlauncher.pro index f2d4b60..4046055 100644 --- a/examples/svg/embedded/fluidlauncher/fluidlauncher.pro +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.pro @@ -15,7 +15,7 @@ SOURCES += \ pictureflow.cpp \ slideshow.cpp -EXAMPLE_FILES += config.xml screenshots slides +RESOURCES = fluidlauncher.qrc target.path = $$[QT_INSTALL_EXAMPLES]/svg/embedded/fluidlauncher INSTALLS += target diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.qrc b/examples/svg/embedded/fluidlauncher/fluidlauncher.qrc new file mode 100644 index 0000000..e4a451b --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.qrc @@ -0,0 +1,43 @@ +<RCC> + <qresource prefix="/fluidlauncher"> + <file>slides/demo_1.png</file> + <file>slides/demo_2.png</file> + <file>slides/demo_3.png</file> + <file>slides/demo_4.png</file> + <file>slides/demo_5.png</file> + <file>slides/demo_6.png</file> + <file>screenshots/anomaly_s60.png</file> + <file>screenshots/concentriccircles.png</file> + <file>screenshots/context2d_s60.png</file> + <file>screenshots/deform.png</file> + <file>screenshots/desktopservices_s60.png</file> + <file>screenshots/digiflip.png</file> + <file>screenshots/elasticnodes.png</file> + <file>screenshots/embeddedsvgviewer_s60.png</file> + <file>screenshots/embeddedsvgviewer.png</file> + <file>screenshots/flickable.png</file> + <file>screenshots/flightinfo_s60.png</file> + <file>screenshots/fridgemagnets_s60.png</file> + <file>screenshots/ftp_s60.png</file> + <file>screenshots/lightmaps.png</file> + <file>screenshots/mediaplayer.png</file> + <file>screenshots/pathstroke.png</file> + <file>screenshots/qmlcalculator.png</file> + <file>screenshots/qmlclocks.png</file> + <file>screenshots/qmldialcontrol.png</file> + <file>screenshots/qmleasing.png</file> + <file>screenshots/qmlflickr.jpg</file> + <file>screenshots/qmlphotoviewer.jpg</file> + <file>screenshots/qmltwitter.jpg</file> + <file>screenshots/raycasting.png</file> + <file>screenshots/saxbookmarks_s60.png</file> + <file>screenshots/softkeys_s60.png</file> + <file>screenshots/spectrum.png</file> + <file>screenshots/styledemo_s60.png</file> + <file>screenshots/styledemo.png</file> + <file>screenshots/weatherinfo.png</file> + <file>screenshots/wiggly_s60.png</file> + <file>screenshots/wiggly.png</file> + <file>config.xml</file> + </qresource> +</RCC> diff --git a/examples/svg/embedded/fluidlauncher/slideshow.cpp b/examples/svg/embedded/fluidlauncher/slideshow.cpp index efdb97c..2df6642 100644 --- a/examples/svg/embedded/fluidlauncher/slideshow.cpp +++ b/examples/svg/embedded/fluidlauncher/slideshow.cpp @@ -98,8 +98,14 @@ void SlideShow::addImageDir(QString dirName) { QDir dir(dirName); + // lookup in directories QStringList fileNames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name); + for (int i=0; i<fileNames.count(); i++) + d->imagePaths << dir.absoluteFilePath(fileNames[i]); + // lookup in qrc + dir = QDir(QString(":/fluidlauncher/" + dirName)); + fileNames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name); for (int i=0; i<fileNames.count(); i++) d->imagePaths << dir.absoluteFilePath(fileNames[i]); } |