Commit bf249abe authored by Alex Blasche's avatar Alex Blasche
Browse files

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: default avatarAlessandro Portale <alessandro.portale@digia.com>
Showing with 67 additions and 3 deletions
......@@ -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()
......
......@@ -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();
......
......@@ -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
......
<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>
......@@ -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]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment