Let one 'reset' the qmlviewer path in the config page by

just emptying it.

Discussed with Nigel.
This commit is contained in:
Kai Koehne
2009-11-03 12:07:41 +01:00
parent 10e07e01c7
commit a44e33ac93
2 changed files with 9 additions and 21 deletions

View File

@@ -343,7 +343,7 @@ QmlRunConfiguration::QmlRunConfiguration(QmlProject *pro)
+ Utils::SynchronousProcess::pathSeparator() + Utils::SynchronousProcess::pathSeparator()
+ QCoreApplication::applicationDirPath() + QCoreApplication::applicationDirPath()
; ;
m_qmlViewer = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer")); m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer"));
} }
QmlRunConfiguration::~QmlRunConfiguration() QmlRunConfiguration::~QmlRunConfiguration()
@@ -357,8 +357,9 @@ QString QmlRunConfiguration::type() const
QString QmlRunConfiguration::executable() const QString QmlRunConfiguration::executable() const
{ {
// No need to verify if the QML Viewer exists. The console will tell us anyway when we try to launch it. if (!m_qmlViewerCustomPath.isEmpty())
return m_qmlViewer; return m_qmlViewerCustomPath;
return m_qmlViewerDefaultPath;
} }
QmlRunConfiguration::RunMode QmlRunConfiguration::runMode() const QmlRunConfiguration::RunMode QmlRunConfiguration::runMode() const
@@ -469,7 +470,7 @@ void QmlRunConfiguration::setMainScript(const QString &scriptFile)
void QmlRunConfiguration::onQmlViewerChanged() void QmlRunConfiguration::onQmlViewerChanged()
{ {
if (Utils::PathChooser *chooser = qobject_cast<Utils::PathChooser *>(sender())) { if (Utils::PathChooser *chooser = qobject_cast<Utils::PathChooser *>(sender())) {
m_qmlViewer = chooser->path(); m_qmlViewerCustomPath = chooser->path();
} }
} }
@@ -483,7 +484,7 @@ void QmlRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer
{ {
ProjectExplorer::LocalApplicationRunConfiguration::save(writer); ProjectExplorer::LocalApplicationRunConfiguration::save(writer);
writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewer); writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewerCustomPath);
writer.saveValue(QLatin1String("qmlviewerargs"), m_qmlViewerArgs); writer.saveValue(QLatin1String("qmlviewerargs"), m_qmlViewerArgs);
writer.saveValue(QLatin1String("mainscript"), m_scriptFile); writer.saveValue(QLatin1String("mainscript"), m_scriptFile);
} }
@@ -492,24 +493,10 @@ void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReade
{ {
ProjectExplorer::LocalApplicationRunConfiguration::restore(reader); ProjectExplorer::LocalApplicationRunConfiguration::restore(reader);
m_qmlViewer = reader.restoreValue(QLatin1String("qmlviewer")).toString(); m_qmlViewerCustomPath = reader.restoreValue(QLatin1String("qmlviewer")).toString();
m_qmlViewerArgs = reader.restoreValue(QLatin1String("qmlviewerargs")).toString(); m_qmlViewerArgs = reader.restoreValue(QLatin1String("qmlviewerargs")).toString();
m_scriptFile = reader.restoreValue(QLatin1String("mainscript")).toString(); m_scriptFile = reader.restoreValue(QLatin1String("mainscript")).toString();
if (m_qmlViewer.isEmpty()) {
// first see if there is a bundled qmlviewer
#ifdef Q_OS_WIN32
const QLatin1String qmlViewerExe("qmlviewer.exe");
#else
const QLatin1String qmlViewerExe("qmlviewer");
#endif
const QFileInfo info(QCoreApplication::applicationDirPath(), qmlViewerExe);
if (info.exists() && info.isExecutable())
m_qmlViewer = info.absoluteFilePath();
else // if not, then try to locate it elsewhere
m_qmlViewer = Utils::SynchronousProcess::locateBinary(QLatin1String("qmlviewer"));
}
if (m_scriptFile.isEmpty()) if (m_scriptFile.isEmpty())
m_scriptFile = tr("<Current File>"); m_scriptFile = tr("<Current File>");
} }

View File

@@ -175,7 +175,8 @@ private:
private: private:
QmlProject *m_project; QmlProject *m_project;
QString m_scriptFile; QString m_scriptFile;
QString m_qmlViewer; QString m_qmlViewerCustomPath;
QString m_qmlViewerDefaultPath;
QString m_qmlViewerArgs; QString m_qmlViewerArgs;
QLatin1String m_type; QLatin1String m_type;
}; };