From a44e33ac934fb7f4e68ae9347934bd7ab339710c Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@nokia.com> Date: Tue, 3 Nov 2009 12:07:41 +0100 Subject: [PATCH] Let one 'reset' the qmlviewer path in the config page by just emptying it. Discussed with Nigel. --- src/plugins/qmlprojectmanager/qmlproject.cpp | 27 +++++--------------- src/plugins/qmlprojectmanager/qmlproject.h | 3 ++- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 43707de1ad4..fd1a1bc9e5b 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -343,7 +343,7 @@ QmlRunConfiguration::QmlRunConfiguration(QmlProject *pro) + Utils::SynchronousProcess::pathSeparator() + QCoreApplication::applicationDirPath() ; - m_qmlViewer = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer")); + m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer")); } QmlRunConfiguration::~QmlRunConfiguration() @@ -357,8 +357,9 @@ QString QmlRunConfiguration::type() 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. - return m_qmlViewer; + if (!m_qmlViewerCustomPath.isEmpty()) + return m_qmlViewerCustomPath; + return m_qmlViewerDefaultPath; } QmlRunConfiguration::RunMode QmlRunConfiguration::runMode() const @@ -469,7 +470,7 @@ void QmlRunConfiguration::setMainScript(const QString &scriptFile) void QmlRunConfiguration::onQmlViewerChanged() { 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); - writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewer); + writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewerCustomPath); writer.saveValue(QLatin1String("qmlviewerargs"), m_qmlViewerArgs); writer.saveValue(QLatin1String("mainscript"), m_scriptFile); } @@ -492,24 +493,10 @@ void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReade { 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_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()) m_scriptFile = tr("<Current File>"); } diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 9e81a04d1ee..d3454177311 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -175,7 +175,8 @@ private: private: QmlProject *m_project; QString m_scriptFile; - QString m_qmlViewer; + QString m_qmlViewerCustomPath; + QString m_qmlViewerDefaultPath; QString m_qmlViewerArgs; QLatin1String m_type; }; -- GitLab