diff --git a/share/qtcreator/templates/html5app/main.cpp b/share/qtcreator/templates/html5app/main.cpp
index b2df9112ccd..365c3d8cd6b 100644
--- a/share/qtcreator/templates/html5app/main.cpp
+++ b/share/qtcreator/templates/html5app/main.cpp
@@ -8,8 +8,11 @@ int main(int argc, char *argv[])
Html5ApplicationViewer viewer;
viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto); // ORIENTATION
viewer.showExpanded();
- viewer.loadFile(QLatin1String("html/index.html")); // HTMLFILE
-// viewer.loadUrl(QUrl(QLatin1String("http://dev.sencha.com/deploy/touch/examples/kitchensink/")));
+#if 1 // DELETE_LINE
+ viewer.loadFile(QLatin1String("html/index.html")); // MAINHTMLFILE
+#else // DELETE_LINE
+ viewer.loadUrl(QUrl(QLatin1String("http://dev.sencha.com/deploy/touch/examples/kitchensink/"))); // MAINHTMLURL
+#endif // DELETE_LINE
return app.exec();
}
diff --git a/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp b/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp
index 18ef662638a..ee80ca9c604 100644
--- a/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp
+++ b/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp
@@ -219,6 +219,8 @@ QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const
}
insertParameter(line, mainWindowClassName() + QLatin1String("::")
+ QLatin1String(orientationString));
+ } else if (line.contains(QLatin1String("// DELETE_LINE"))) {
+ continue; // omit this line in the output
} else {
adaptLine = adaptCurrentMainCppTemplateLine(line);
}
diff --git a/src/plugins/qt4projectmanager/wizards/html5app.cpp b/src/plugins/qt4projectmanager/wizards/html5app.cpp
index 5ed9c716186..bbf845e3af3 100644
--- a/src/plugins/qt4projectmanager/wizards/html5app.cpp
+++ b/src/plugins/qt4projectmanager/wizards/html5app.cpp
@@ -54,6 +54,7 @@ const QString appViewerOriginsSubDir(appViewerBaseName + QLatin1Char('/'));
Html5App::Html5App()
: AbstractMobileApp()
+ , m_mainHtmlMode(ModeGenerate)
{
}
@@ -61,30 +62,36 @@ Html5App::~Html5App()
{
}
-void Html5App::setIndexHtmlFile(const QString &qmlFile)
+void Html5App::setMainHtml(Mode mode, const QString &data)
{
- m_indexHtmlFile.setFile(qmlFile);
+ Q_ASSERT(mode != ModeGenerate || data.isEmpty());
+ m_mainHtmlMode = mode;
+ m_mainHtmlData = data;
}
-QString Html5App::indexHtmlFile() const
+Html5App::Mode Html5App::mainHtmlMode() const
{
- return path(IndexHtml);
+ return m_mainHtmlMode;
}
QString Html5App::pathExtended(int fileType) const
{
- const QString htmlSubDir = QLatin1String("html/");
const QString appViewerTargetSubDir = appViewerOriginsSubDir;
const QString indexHtml = QLatin1String("index.html");
const QString pathBase = outputPathBase();
const QDir appProFilePath(pathBase);
+ const bool generateHtml = m_mainHtmlMode == ModeGenerate;
+ const bool importHtml = m_mainHtmlMode == ModeImport;
+ const QFileInfo importedHtmlFile(m_mainHtmlData);
+ const QString htmlSubDir = importHtml ? importedHtmlFile.canonicalPath().split(QLatin1Char('/')).last() + QLatin1Char('/')
+ : QString::fromLatin1("html/");
switch (fileType) {
- case IndexHtml: return useExistingIndexHtml() ? m_indexHtmlFile.canonicalFilePath()
- : pathBase + htmlSubDir + indexHtml;
- case IndexHtmlDeployed: return useExistingIndexHtml() ? htmlSubDir + m_indexHtmlFile.fileName()
- : QString(htmlSubDir + indexHtml);
- case IndexHtmlOrigin: return originsRoot() + QLatin1String("html/") + indexHtml;
+ case MainHtml: return generateHtml ? pathBase + htmlSubDir + indexHtml
+ : importedHtmlFile.canonicalFilePath();
+ case MainHtmlDeployed: return generateHtml ? QString(htmlSubDir + indexHtml)
+ : htmlSubDir + importedHtmlFile.fileName();
+ case MainHtmlOrigin: return originsRoot() + QLatin1String("html/") + indexHtml;
case AppViewerPri: return pathBase + appViewerTargetSubDir + appViewerPriFileName;
case AppViewerPriOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerPriFileName;
case AppViewerCpp: return pathBase + appViewerTargetSubDir + appViewerCppFileName;
@@ -92,8 +99,8 @@ QString Html5App::pathExtended(int fileType) const
case AppViewerH: return pathBase + appViewerTargetSubDir + appViewerHFileName;
case AppViewerHOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerHFileName;
case HtmlDir: return pathBase + htmlSubDir;
- case HtmlDirProFileRelative: return useExistingIndexHtml() ? appProFilePath.relativeFilePath(m_indexHtmlFile.canonicalPath())
- : QString(htmlSubDir).remove(htmlSubDir.length() - 1, 1);
+ case HtmlDirProFileRelative: return generateHtml ? QString(htmlSubDir).remove(htmlSubDir.length() - 1, 1)
+ : appProFilePath.relativeFilePath(importedHtmlFile.canonicalPath());
default: qFatal("Html5App::pathExtended() needs more work");
}
return QString();
@@ -113,8 +120,16 @@ bool Html5App::adaptCurrentMainCppTemplateLine(QString &line) const
{
const QLatin1Char quote('"');
bool adaptLine = true;
- if (line.contains(QLatin1String("// MAINHTML"))) {
- insertParameter(line, quote + path(IndexHtmlDeployed) + quote);
+ if (line.contains(QLatin1String("// MAINHTMLFILE"))) {
+ if (m_mainHtmlMode != ModeUrl)
+ insertParameter(line, quote + path(MainHtmlDeployed) + quote);
+ else
+ adaptLine = false;
+ } else if (line.contains(QLatin1String("// MAINHTMLURL"))) {
+ if (m_mainHtmlMode == ModeUrl)
+ insertParameter(line, quote + m_mainHtmlData + quote);
+ else
+ adaptLine = false;
}
return adaptLine;
}
@@ -133,10 +148,10 @@ void Html5App::handleCurrentProFileTemplateLine(const QString &line,
Core::GeneratedFiles Html5App::generateFiles(QString *errorMessage) const
{
Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage);
-// if (!useExistingMainQml()) {
- files.append(file(generateFile(Html5AppGeneratedFileInfo::IndexHtmlFile, errorMessage), path(IndexHtml)));
+ if (m_mainHtmlMode == ModeGenerate) {
+ files.append(file(generateFile(Html5AppGeneratedFileInfo::MainHtmlFile, errorMessage), path(MainHtml)));
files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
-// }
+ }
files.append(file(generateFile(Html5AppGeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri)));
files.append(file(generateFile(Html5AppGeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp)));
@@ -146,18 +161,13 @@ Core::GeneratedFiles Html5App::generateFiles(QString *errorMessage) const
}
#endif // CREATORLESSTEST
-bool Html5App::useExistingIndexHtml() const
-{
- return !m_indexHtmlFile.filePath().isEmpty();
-}
-
QByteArray Html5App::generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
{
QByteArray data;
switch (fileType) {
- case Html5AppGeneratedFileInfo::IndexHtmlFile:
- data = readBlob(path(IndexHtmlOrigin), errorMessage);
+ case Html5AppGeneratedFileInfo::MainHtmlFile:
+ data = readBlob(path(MainHtmlOrigin), errorMessage);
break;
case Html5AppGeneratedFileInfo::AppViewerPriFile:
data = readBlob(path(AppViewerPriOrigin), errorMessage);
@@ -215,7 +225,8 @@ QList Html5App::updateableFiles(const QString &mainPr
QList Html5App::deploymentFolders() const
{
QList result;
- result.append(DeploymentFolder(path(HtmlDirProFileRelative), QLatin1String(".")));
+ if (m_mainHtmlMode != ModeUrl)
+ result.append(DeploymentFolder(path(HtmlDirProFileRelative), QLatin1String(".")));
return result;
}
diff --git a/src/plugins/qt4projectmanager/wizards/html5app.h b/src/plugins/qt4projectmanager/wizards/html5app.h
index 42c0bb0a776..76c3db3df29 100644
--- a/src/plugins/qt4projectmanager/wizards/html5app.h
+++ b/src/plugins/qt4projectmanager/wizards/html5app.h
@@ -45,7 +45,7 @@ namespace Internal {
struct Html5AppGeneratedFileInfo : public AbstractGeneratedFileInfo
{
enum ExtendedFileType {
- IndexHtmlFile = ExtendedFile,
+ MainHtmlFile = ExtendedFile,
AppViewerPriFile,
AppViewerCppFile,
AppViewerHFile
@@ -60,9 +60,9 @@ class Html5App : public AbstractMobileApp
{
public:
enum ExtendedFileType {
- IndexHtml = ExtendedFile,
- IndexHtmlDeployed,
- IndexHtmlOrigin,
+ MainHtml = ExtendedFile,
+ MainHtmlDeployed,
+ MainHtmlOrigin,
AppViewerPri,
AppViewerPriOrigin,
AppViewerCpp,
@@ -74,18 +74,23 @@ public:
ModulesDir
};
+ enum Mode {
+ ModeGenerate,
+ ModeImport,
+ ModeUrl
+ };
+
Html5App();
virtual ~Html5App();
- void setIndexHtmlFile(const QString &qmlFile);
- QString indexHtmlFile() const;
+ void setMainHtml(Mode mode, const QString &data = QString());
+ Mode mainHtmlMode() const;
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
- bool useExistingIndexHtml() const;
static const int StubVersion;
@@ -104,6 +109,8 @@ private:
QList deploymentFolders() const;
QFileInfo m_indexHtmlFile;
+ Mode m_mainHtmlMode;
+ QString m_mainHtmlData;
};
} // namespace Internal
diff --git a/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp b/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp
index ae618107ec1..7564a97abc8 100644
--- a/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp
+++ b/src/plugins/qt4projectmanager/wizards/html5appwizard.cpp
@@ -130,18 +130,18 @@ void Html5AppWizard::prepareGenerateFiles(const QWizard *w,
{
Q_UNUSED(errorMessage)
const Html5AppWizardDialog *wizard = qobject_cast(w);
- const QString mainQmlFile = wizard->m_htmlSourcesPage->mainHtmlFile();
- m_d->app->setIndexHtmlFile(mainQmlFile);
+ m_d->app->setMainHtml(wizard->m_htmlSourcesPage->mainHtmlMode(),
+ wizard->m_htmlSourcesPage->mainHtmlData());
}
bool Html5AppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)
{
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
- if (success && !m_d->app->indexHtmlFile().isEmpty()) {
- ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, m_d->app->indexHtmlFile());
- Core::EditorManager::instance()->openEditor(m_d->app->indexHtmlFile(),
- QString(), Core::EditorManager::ModeSwitch);
+ const QString mainHtmlFile = m_d->app->path(Html5App::MainHtml);
+ if (success && !mainHtmlFile.isEmpty()) {
+ ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, mainHtmlFile);
+ Core::EditorManager::instance()->openEditor(mainHtmlFile, QString(), Core::EditorManager::ModeSwitch);
}
return success;
}
diff --git a/src/plugins/qt4projectmanager/wizards/html5appwizardpages.cpp b/src/plugins/qt4projectmanager/wizards/html5appwizardpages.cpp
index 9447fc88342..e7fe013dcb9 100644
--- a/src/plugins/qt4projectmanager/wizards/html5appwizardpages.cpp
+++ b/src/plugins/qt4projectmanager/wizards/html5appwizardpages.cpp
@@ -54,15 +54,16 @@ Html5AppWizardSourcesPage::Html5AppWizardSourcesPage(QWidget *parent)
, m_d(new Html5AppWizardSourcesPagePrivate)
{
m_d->ui.setupUi(this);
- m_d->ui.mainHtmlFileLineEdit->setExpectedKind(Utils::PathChooser::File);
- m_d->ui.mainHtmlFileLineEdit->setPromptDialogFilter(QLatin1String("*.html"));
- m_d->ui.mainHtmlFileLineEdit->setPromptDialogTitle(tr("Select Html File"));
- connect(m_d->ui.mainHtmlFileLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
- connect(m_d->ui.importExistingHtmlRadioButton,
+ m_d->ui.importLineEdit->setExpectedKind(Utils::PathChooser::File);
+ m_d->ui.importLineEdit->setPromptDialogFilter(QLatin1String("*.html"));
+ m_d->ui.importLineEdit->setPromptDialogTitle(tr("Select Html File"));
+ connect(m_d->ui.importLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
+ connect(m_d->ui.importRadioButton,
SIGNAL(toggled(bool)), SIGNAL(completeChanged()));
- connect(m_d->ui.newHtmlRadioButton, SIGNAL(toggled(bool)),
- m_d->ui.mainHtmlFileLineEdit, SLOT(setDisabled(bool)));
- m_d->ui.newHtmlRadioButton->setChecked(true);
+ connect(m_d->ui.generateRadioButton, SIGNAL(toggled(bool)), SLOT(setLineEditsEnabled()));
+ connect(m_d->ui.importRadioButton, SIGNAL(toggled(bool)), SLOT(setLineEditsEnabled()));
+ connect(m_d->ui.urlRadioButton, SIGNAL(toggled(bool)), SLOT(setLineEditsEnabled()));
+ m_d->ui.generateRadioButton->setChecked(true);
}
Html5AppWizardSourcesPage::~Html5AppWizardSourcesPage()
@@ -70,16 +71,35 @@ Html5AppWizardSourcesPage::~Html5AppWizardSourcesPage()
delete m_d;
}
-QString Html5AppWizardSourcesPage::mainHtmlFile() const
+Html5App::Mode Html5AppWizardSourcesPage::mainHtmlMode() const
{
- return m_d->ui.importExistingHtmlRadioButton->isChecked() ?
- m_d->ui.mainHtmlFileLineEdit->path() : QString();
+ Html5App::Mode result = Html5App::ModeGenerate;
+ if (m_d->ui.importRadioButton->isChecked())
+ result = Html5App::ModeImport;
+ else if (m_d->ui.urlRadioButton->isChecked())
+ result = Html5App::ModeUrl;
+ return result;
+}
+
+QString Html5AppWizardSourcesPage::mainHtmlData() const
+{
+ switch (mainHtmlMode()) {
+ case Html5App::ModeImport: return m_d->ui.importLineEdit->path();
+ case Html5App::ModeUrl: return m_d->ui.urlLineEdit->text();
+ default:
+ case Html5App::ModeGenerate: return QString();
+ }
}
bool Html5AppWizardSourcesPage::isComplete() const
{
- return !m_d->ui.importExistingHtmlRadioButton->isChecked()
- || m_d->ui.mainHtmlFileLineEdit->isValid();
+ return mainHtmlMode() != Html5App::ModeImport || m_d->ui.importLineEdit->isValid();
+}
+
+void Html5AppWizardSourcesPage::setLineEditsEnabled()
+{
+ m_d->ui.importLineEdit->setEnabled(m_d->ui.importRadioButton->isChecked());
+ m_d->ui.urlLineEdit->setEnabled(m_d->ui.urlRadioButton->isChecked());
}
} // namespace Internal
diff --git a/src/plugins/qt4projectmanager/wizards/html5appwizardpages.h b/src/plugins/qt4projectmanager/wizards/html5appwizardpages.h
index 74f613e756b..a400271ff69 100644
--- a/src/plugins/qt4projectmanager/wizards/html5appwizardpages.h
+++ b/src/plugins/qt4projectmanager/wizards/html5appwizardpages.h
@@ -49,9 +49,13 @@ public:
explicit Html5AppWizardSourcesPage(QWidget *parent = 0);
virtual ~Html5AppWizardSourcesPage();
- QString mainHtmlFile() const;
+ Html5App::Mode mainHtmlMode() const;
+ QString mainHtmlData() const;
virtual bool isComplete() const;
+private slots:
+ void setLineEditsEnabled();
+
private:
class Html5AppWizardSourcesPagePrivate *m_d;
};
diff --git a/src/plugins/qt4projectmanager/wizards/html5appwizardsourcespage.ui b/src/plugins/qt4projectmanager/wizards/html5appwizardsourcespage.ui
index 2d522a9be36..4ff40949f97 100644
--- a/src/plugins/qt4projectmanager/wizards/html5appwizardsourcespage.ui
+++ b/src/plugins/qt4projectmanager/wizards/html5appwizardsourcespage.ui
@@ -21,16 +21,16 @@
-
-
+
Generate an index.html file
-
-
+
- false
+ true
Import an existing .html file
@@ -38,9 +38,9 @@
-
-
+
- false
+ true
@@ -61,9 +61,9 @@
-
-
+
- false
+ true
Load a URL
@@ -71,9 +71,12 @@
-
-
+
- false
+ true
+
+
+ http://
@@ -105,7 +108,7 @@
- Note: Unless you chose to load an URL, all files and directories that reside in the same directory as the main Html file are deployed. You can modify the contents of the directory any time before deploying.
+ Note: Unless you chose to load a URL, all files and directories that reside in the same directory as the main Html file are deployed. You can modify the contents of the directory any time before deploying.
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
diff --git a/tests/manual/appwizards/helpers.cpp b/tests/manual/appwizards/helpers.cpp
index 6a93dd6dea8..06b9b5d399d 100644
--- a/tests/manual/appwizards/helpers.cpp
+++ b/tests/manual/appwizards/helpers.cpp
@@ -31,7 +31,7 @@ bool Html5App::generateFiles(QString *errorMessage) const
{
return writeFile(generateFile(Html5AppGeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::AppProFile, errorMessage), path(AppPro))
- && (useExistingIndexHtml() ? true : writeFile(generateFile(Html5AppGeneratedFileInfo::IndexHtmlFile, errorMessage), path(IndexHtml)))
+ && (mainHtmlMode() != ModeGenerate ? true : writeFile(generateFile(Html5AppGeneratedFileInfo::MainHtmlFile, errorMessage), path(MainHtml)))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::AppViewerHFile, errorMessage), path(AppViewerH))
diff --git a/tests/manual/appwizards/main.cpp b/tests/manual/appwizards/main.cpp
index fb2fcc17fe2..421c89b7e75 100644
--- a/tests/manual/appwizards/main.cpp
+++ b/tests/manual/appwizards/main.cpp
@@ -84,6 +84,27 @@ int main(int argc, char *argv[])
Html5App sAppNew;
sAppNew.setProjectPath(projectPath);
sAppNew.setProjectName(QLatin1String("new_html5_app"));
+ qDebug() << sAppNew.path(Html5App::MainHtml);
+ if (!sAppNew.generateFiles(&errorMessage))
+ return 1;
+ }
+
+ {
+ Html5App sAppNew;
+ sAppNew.setProjectPath(projectPath);
+ sAppNew.setProjectName(QLatin1String("html5_imported_scenario_01"));
+ sAppNew.setMainHtml(Html5App::ModeImport, QLatin1String("../appwizards/htmlimportscenario_01/themainhtml.html"));
+ qDebug() << sAppNew.path(Html5App::MainHtml);
+ if (!sAppNew.generateFiles(&errorMessage))
+ return 1;
+ }
+
+ {
+ Html5App sAppNew;
+ sAppNew.setProjectPath(projectPath);
+ sAppNew.setProjectName(QLatin1String("html5_url"));
+ sAppNew.setMainHtml(Html5App::ModeUrl, QLatin1String("http://www.jqtouch.com/preview/demos/main/"));
+ qDebug() << sAppNew.path(Html5App::MainHtml);
if (!sAppNew.generateFiles(&errorMessage))
return 1;
}