diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 53c4df3e852..6454625d721 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -37,6 +37,7 @@ #include "profilereader.h" #include "qmakestep.h" #include "qt4buildconfiguration.h" +#include "wizards/qmlstandaloneapp.h" #include #include @@ -56,6 +57,7 @@ #include #include #include +#include using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; @@ -180,6 +182,38 @@ QString Qt4Manager::mimeType() const return QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE); } +// Prototype Ui for update of QmlApplicationView files. +// TODO implement a proper Ui for this. Maybe not as modal message box. +// When removing this, also remove the inclusions of "wizards/qmlstandaloneapp.h" and QtGui/QMessageBox +inline void updateQmlApplicationViewerFiles(const QString proFile) +{ + const QList updates = + QmlStandaloneApp::fileUpdates(proFile); + if (!updates.empty()) { + // TODO Translate the folloing strings when we want to keep the code + QString message = QLatin1String("The following files are either outdated or have been modified:"); + message.append(QLatin1String("
    ")); + foreach (const GeneratedFileInfo &info, updates) { + QStringList reasons; + if (info.wasModified()) + reasons.append(QLatin1String("modified")); + if (info.isOutdated()) + reasons.append(QLatin1String("outdated")); + message.append(QString::fromLatin1("
  • %1 (%2)
  • ") + .arg(QDir::toNativeSeparators(info.fileInfo.canonicalFilePath())) + .arg(reasons.join(QLatin1String(", ")))); + } + message.append(QLatin1String("
")); + message.append(QLatin1String("Do you want Qt Creator to update the files? Any changes will be lost.")); + const QString title = QLatin1String("Update of the QmlApplicationView files"); + if (QMessageBox::question(0, title, message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + QString error; + if (!QmlStandaloneApp::updateFiles(updates, error)) + QMessageBox::critical(0, title, error); + } + } +} + ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName) { Core::MessageManager *messageManager = Core::ICore::instance()->messageManager(); @@ -202,6 +236,8 @@ ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName) } } + updateQmlApplicationViewerFiles(canonicalFilePath); + Qt4Project *pro = new Qt4Project(this, canonicalFilePath); return pro; }