summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/video/qmlvideofx/filereader.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/examples/video/qmlvideofx/filereader.cpp b/examples/video/qmlvideofx/filereader.cpp
index 26997d7fc..1d6b03279 100644
--- a/examples/video/qmlvideofx/filereader.cpp
+++ b/examples/video/qmlvideofx/filereader.cpp
@@ -41,14 +41,36 @@
#include "filereader.h"
#include "trace.h"
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
+QString adjustPath(const QString &path)
+{
+#ifdef Q_OS_UNIX
+#ifdef Q_OS_MAC
+ if (!QDir::isAbsolutePath(path))
+ return QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/") + path;
+#else
+ QString pathInInstallDir;
+ const QString applicationDirPath = QCoreApplication::applicationDirPath();
+ pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
+
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+#endif
+#endif
+ return path;
+}
+
QString FileReader::readFile(const QString &fileName)
{
qtTrace() << "FileReader::readFile" << "fileName" << fileName;
QString content;
- QFile file(fileName);
+ QFile file(adjustPath(fileName));
if (file.open(QIODevice::ReadOnly)) {
QTextStream stream(&file);
content = stream.readAll();