Commit 9e012e7d authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Prototype Ui for update of QmlApplicationView files.

We may want to implement a proper Ui for this. Maybe not as modal
message box.
parent 7311e425
......@@ -37,6 +37,7 @@
#include "profilereader.h"
#include "qmakestep.h"
#include "qt4buildconfiguration.h"
#include "wizards/qmlstandaloneapp.h"
#include <coreplugin/icore.h>
#include <coreplugin/basefilewizard.h>
......@@ -56,6 +57,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QVariant>
#include <QtGui/QFileDialog>
#include <QtGui/QMessageBox>
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<GeneratedFileInfo> 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("<ul>"));
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("<li><nobr>%1 (%2)</nobr></li>")
.arg(QDir::toNativeSeparators(info.fileInfo.canonicalFilePath()))
.arg(reasons.join(QLatin1String(", "))));
}
message.append(QLatin1String("</ul>"));
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;
}
......
Markdown is supported
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