diff --git a/src/plugins/qt4projectmanager/wizards/html5app.cpp b/src/plugins/qt4projectmanager/wizards/html5app.cpp index fc104f7e300..081896e28bb 100644 --- a/src/plugins/qt4projectmanager/wizards/html5app.cpp +++ b/src/plugins/qt4projectmanager/wizards/html5app.cpp @@ -171,6 +171,76 @@ Core::GeneratedFiles Html5App::generateFiles(QString *errorMessage) const } #endif // CREATORLESSTEST +QByteArray Html5App::appViewerCppFileCode(QString *errorMessage) const +{ + static const char* touchNavigavigationFiles[] = { + "webtouchphysicsinterface.h", + "webtouchphysics.h", + "webtouchevent.h", + "webtouchscroller.h", + "webtouchnavigation.h", + "webnavigation.h", + "navigationcontroller.h", + "webtouchphysicsinterface.cpp", + "webtouchphysics.cpp", + "webtouchevent.cpp", + "webtouchscroller.cpp", + "webtouchnavigation.cpp", + "webnavigation.cpp", + "navigationcontroller.cpp", + }; + static const QString touchNavigavigationDir = + originsRoot() + appViewerOriginsSubDir + QLatin1String("touchnavigation/"); + QByteArray touchNavigavigationCode; + for (int i = 0; i < sizeof(touchNavigavigationFiles) / sizeof(touchNavigavigationFiles[0]); ++i) { + QFile touchNavigavigationFile(touchNavigavigationDir + QLatin1String(touchNavigavigationFiles[i])); + if (!touchNavigavigationFile.open(QIODevice::ReadOnly)) { + if (errorMessage) + *errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp", + "Could not open template file '%1'.").arg(touchNavigavigationFiles[i]); + return QByteArray(); + } + QTextStream touchNavigavigationFileIn(&touchNavigavigationFile); + QString line; + while (!(line = touchNavigavigationFileIn.readLine()).isNull()) { + if (line.startsWith(QLatin1String("#include")) || + (line.startsWith(QLatin1String("#ifndef")) + || line.startsWith(QLatin1String("#define")) + || line.startsWith(QLatin1String("#endif"))) + && line.endsWith(QLatin1String("_H"))) + continue; + touchNavigavigationCode.append(line + QLatin1Char('\n')); + } + } + + QFile appViewerCppFile(path(AppViewerCppOrigin)); + if (!appViewerCppFile.open(QIODevice::ReadOnly)) { + if (errorMessage) + *errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp", + "Could not open template file '%1'.").arg(path(AppViewerCppOrigin)); + return QByteArray(); + } + QTextStream in(&appViewerCppFile); + QByteArray appViewerCppCode; + bool touchNavigavigationCodeInserted = false; + QString line; + while (!(line = in.readLine()).isNull()) { + if (!touchNavigavigationCodeInserted && line == QLatin1String("#ifdef TOUCH_OPTIMIZED_NAVIGATION")) { + appViewerCppCode.append(line + QLatin1Char('\n')); + while (!(line = in.readLine()).isNull() + && !line.contains(QLatin1String("#endif // TOUCH_OPTIMIZED_NAVIGATION"))) + { + if (!line.startsWith(QLatin1String("#include \""))) + appViewerCppCode.append(line + QLatin1Char('\n')); + } + appViewerCppCode.append(touchNavigavigationCode); + touchNavigavigationCodeInserted = true; + } + appViewerCppCode.append(line + QLatin1Char('\n')); + } + return appViewerCppCode; +} + QByteArray Html5App::generateFileExtended(int fileType, bool *versionAndCheckSum, QString *comment, QString *errorMessage) const { @@ -186,7 +256,7 @@ QByteArray Html5App::generateFileExtended(int fileType, *versionAndCheckSum = true; break; case Html5AppGeneratedFileInfo::AppViewerCppFile: - data = readBlob(path(AppViewerCppOrigin), errorMessage); + data = appViewerCppFileCode(errorMessage); *versionAndCheckSum = true; break; case Html5AppGeneratedFileInfo::AppViewerHFile: diff --git a/src/plugins/qt4projectmanager/wizards/html5app.h b/src/plugins/qt4projectmanager/wizards/html5app.h index 4938ecb0ea8..b46730d0a45 100644 --- a/src/plugins/qt4projectmanager/wizards/html5app.h +++ b/src/plugins/qt4projectmanager/wizards/html5app.h @@ -109,6 +109,7 @@ private: bool &commentOutNextLine) const; QList updateableFiles(const QString &mainProFile) const; QList deploymentFolders() const; + QByteArray appViewerCppFileCode(QString *errorMessage) const; QFileInfo m_indexHtmlFile; Mode m_mainHtmlMode;