2010-02-16 13:39:13 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-16 13:39:13 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-07-13 15:02:37 +02:00
|
|
|
#include "qmlprojectrunconfiguration.h"
|
2010-02-16 13:39:13 +01:00
|
|
|
#include "qmlproject.h"
|
|
|
|
|
#include "qmlprojectmanagerconstants.h"
|
|
|
|
|
#include "qmlprojecttarget.h"
|
2010-04-13 10:58:30 +02:00
|
|
|
#include "projectexplorer/projectexplorer.h"
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-03-05 11:11:05 +01:00
|
|
|
#include <coreplugin/mimedatabase.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2010-02-16 13:39:13 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/ifile.h>
|
|
|
|
|
#include <utils/synchronousprocess.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
2010-09-01 11:34:34 +02:00
|
|
|
#include <utils/debuggerlanguagechooser.h>
|
2010-08-19 16:51:27 +02:00
|
|
|
#include <qt4projectmanager/qtversionmanager.h>
|
|
|
|
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QSpinBox>
|
2010-04-13 10:58:30 +02:00
|
|
|
#include <QStringListModel>
|
2010-02-28 10:57:58 +01:00
|
|
|
#include <QDebug>
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
|
|
|
|
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent) :
|
|
|
|
|
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
|
2010-04-13 10:58:30 +02:00
|
|
|
m_fileListModel(new QStringListModel(this)),
|
2010-03-08 14:36:44 +01:00
|
|
|
m_projectTarget(parent),
|
2010-03-09 17:04:09 +01:00
|
|
|
m_usingCurrentFile(true),
|
2010-03-05 11:11:05 +01:00
|
|
|
m_isEnabled(false)
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent, QmlProjectRunConfiguration *source) :
|
|
|
|
|
ProjectExplorer::RunConfiguration(parent, source),
|
|
|
|
|
m_qmlViewerCustomPath(source->m_qmlViewerCustomPath),
|
2010-04-16 15:55:42 +02:00
|
|
|
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
2010-04-19 10:48:50 +02:00
|
|
|
m_fileListModel(new QStringListModel(this)),
|
2010-04-16 15:55:42 +02:00
|
|
|
m_projectTarget(parent)
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-04-19 11:02:06 +02:00
|
|
|
ctor();
|
|
|
|
|
setMainScript(source->m_scriptFile);
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-05 11:11:05 +01:00
|
|
|
bool QmlProjectRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *bc) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(bc);
|
|
|
|
|
|
2010-06-10 09:10:11 +02:00
|
|
|
return m_isEnabled;
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
void QmlProjectRunConfiguration::ctor()
|
|
|
|
|
{
|
2010-09-01 11:34:34 +02:00
|
|
|
// reset default settings in constructor
|
|
|
|
|
setUseCppDebugger(false);
|
|
|
|
|
setUseQmlDebugger(true);
|
|
|
|
|
|
2010-03-05 11:11:05 +01:00
|
|
|
Core::EditorManager *em = Core::EditorManager::instance();
|
|
|
|
|
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
|
|
|
this, SLOT(changeCurrentFile(Core::IEditor*)));
|
|
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
Qt4ProjectManager::QtVersionManager *qtVersions = Qt4ProjectManager::QtVersionManager::instance();
|
|
|
|
|
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)), this, SLOT(updateEnabled()));
|
2010-08-20 11:34:02 +02:00
|
|
|
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)), this, SLOT(onViewerChanged()));
|
2010-05-20 11:59:42 +02:00
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProjectRunConfiguration::~QmlProjectRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Internal::QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Internal::QmlProjectTarget *>(target());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlProjectRunConfiguration::viewerPath() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_qmlViewerCustomPath.isEmpty())
|
|
|
|
|
return m_qmlViewerCustomPath;
|
2010-08-19 16:51:27 +02:00
|
|
|
|
|
|
|
|
return viewerDefaultPath();
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList QmlProjectRunConfiguration::viewerArguments() const
|
|
|
|
|
{
|
|
|
|
|
QStringList args;
|
|
|
|
|
|
|
|
|
|
// arguments in .user file
|
|
|
|
|
if (!m_qmlViewerArgs.isEmpty())
|
2010-04-06 11:23:37 +02:00
|
|
|
args.append(m_qmlViewerArgs.split(QLatin1Char(' ')));
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
// arguments from .qmlproject file
|
2010-03-21 09:36:54 +01:00
|
|
|
foreach (const QString &importPath, qmlTarget()->qmlProject()->importPaths()) {
|
2010-04-14 15:47:56 +02:00
|
|
|
args.append(QLatin1String("-I"));
|
2010-03-21 09:36:54 +01:00
|
|
|
args.append(importPath);
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString s = mainScript();
|
|
|
|
|
if (! s.isEmpty())
|
|
|
|
|
args.append(s);
|
|
|
|
|
return args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlProjectRunConfiguration::workingDirectory() const
|
|
|
|
|
{
|
|
|
|
|
QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName());
|
|
|
|
|
return projectFile.absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 17:28:00 +02:00
|
|
|
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
|
|
|
|
{
|
|
|
|
|
return s1.toLower() < s2.toLower();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
QWidget *QmlProjectRunConfiguration::createConfigurationWidget()
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
QWidget *config = new QWidget;
|
|
|
|
|
QFormLayout *form = new QFormLayout(config);
|
|
|
|
|
|
2010-04-13 10:58:30 +02:00
|
|
|
m_fileListCombo = new QComboBox;
|
|
|
|
|
m_fileListCombo.data()->setModel(m_fileListModel);
|
|
|
|
|
updateFileComboBox();
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-04-13 10:58:30 +02:00
|
|
|
connect(m_fileListCombo.data(), SIGNAL(activated(QString)), this, SLOT(setMainScript(QString)));
|
|
|
|
|
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(fileListChanged()), SLOT(updateFileComboBox()));
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
Utils::PathChooser *qmlViewer = new Utils::PathChooser;
|
|
|
|
|
qmlViewer->setExpectedKind(Utils::PathChooser::Command);
|
2010-08-20 11:34:02 +02:00
|
|
|
qmlViewer->setPath(m_qmlViewerCustomPath);
|
2010-08-19 16:51:27 +02:00
|
|
|
|
2010-02-26 14:46:04 +01:00
|
|
|
connect(qmlViewer, SIGNAL(changed(QString)), this, SLOT(onViewerChanged()));
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-08-20 11:34:02 +02:00
|
|
|
m_qmlViewerExecutable = new QLabel;
|
|
|
|
|
m_qmlViewerExecutable.data()->setText(viewerPath() + " " + m_qmlViewerArgs);
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QLineEdit *qmlViewerArgs = new QLineEdit;
|
|
|
|
|
qmlViewerArgs->setText(m_qmlViewerArgs);
|
2010-02-26 14:46:04 +01:00
|
|
|
connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onViewerArgsChanged()));
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-07-12 13:03:24 +02:00
|
|
|
form->addRow(tr("Custom QML Viewer:"), qmlViewer);
|
2010-05-20 11:59:42 +02:00
|
|
|
form->addRow(tr("QML Viewer arguments:"), qmlViewerArgs);
|
2010-08-20 11:34:02 +02:00
|
|
|
form->addRow(QString(), m_qmlViewerExecutable.data());
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), config);
|
|
|
|
|
Utils::DebuggerLanguageChooser *debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(config);
|
|
|
|
|
|
2010-04-13 10:58:30 +02:00
|
|
|
form->addRow(tr("Main QML File:"), m_fileListCombo.data());
|
2010-09-01 11:34:34 +02:00
|
|
|
form->addRow(debuggerLabel, debuggerLanguageChooser);
|
|
|
|
|
|
|
|
|
|
debuggerLanguageChooser->setCppChecked(useCppDebugger());
|
|
|
|
|
debuggerLanguageChooser->setQmlChecked(useQmlDebugger());
|
2010-09-02 17:17:35 +02:00
|
|
|
debuggerLanguageChooser->setQmlDebugServerPort(qmlDebugServerPort());
|
2010-09-01 11:34:34 +02:00
|
|
|
|
|
|
|
|
connect(debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
|
|
|
|
|
this, SLOT(useCppDebuggerToggled(bool)));
|
|
|
|
|
connect(debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
|
|
|
|
|
this, SLOT(useQmlDebuggerToggled(bool)));
|
2010-09-02 17:17:35 +02:00
|
|
|
connect(debuggerLanguageChooser, SIGNAL(qmlDebugServerPortChanged(uint)),
|
|
|
|
|
this, SLOT(qmlDebugServerPortChanged(uint)));
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 10:58:30 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QString QmlProjectRunConfiguration::mainScript() const
|
|
|
|
|
{
|
2010-03-05 11:11:05 +01:00
|
|
|
if (m_usingCurrentFile)
|
|
|
|
|
return m_currentFileFilename;
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-03-05 11:11:05 +01:00
|
|
|
return m_mainScriptFilename;
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 10:58:30 +02:00
|
|
|
void QmlProjectRunConfiguration::updateFileComboBox()
|
|
|
|
|
{
|
|
|
|
|
if (m_fileListCombo.isNull())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QDir projectDir = qmlTarget()->qmlProject()->projectDir();
|
|
|
|
|
QStringList files;
|
|
|
|
|
|
|
|
|
|
files.append(CURRENT_FILE);
|
|
|
|
|
int currentIndex = -1;
|
|
|
|
|
QStringList sortedFiles = qmlTarget()->qmlProject()->files();
|
|
|
|
|
qStableSort(sortedFiles.begin(), sortedFiles.end(), caseInsensitiveLessThan);
|
|
|
|
|
|
|
|
|
|
foreach (const QString &fn, sortedFiles) {
|
|
|
|
|
QFileInfo fileInfo(fn);
|
|
|
|
|
if (fileInfo.suffix() != QLatin1String("qml"))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QString fileName = projectDir.relativeFilePath(fn);
|
|
|
|
|
if (fileName == m_scriptFile)
|
|
|
|
|
currentIndex = files.size();
|
|
|
|
|
|
|
|
|
|
files.append(fileName);
|
|
|
|
|
}
|
|
|
|
|
m_fileListModel->setStringList(files);
|
|
|
|
|
|
|
|
|
|
if (currentIndex != -1)
|
|
|
|
|
m_fileListCombo.data()->setCurrentIndex(currentIndex);
|
|
|
|
|
else
|
|
|
|
|
m_fileListCombo.data()->setCurrentIndex(0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
void QmlProjectRunConfiguration::setMainScript(const QString &scriptFile)
|
|
|
|
|
{
|
|
|
|
|
m_scriptFile = scriptFile;
|
2010-03-05 11:38:17 +01:00
|
|
|
// replace with locale-agnostic string
|
|
|
|
|
if (m_scriptFile == CURRENT_FILE)
|
|
|
|
|
m_scriptFile = M_CURRENT_FILE;
|
2010-03-05 11:11:05 +01:00
|
|
|
|
2010-03-05 11:38:17 +01:00
|
|
|
if (m_scriptFile.isEmpty() || m_scriptFile == M_CURRENT_FILE) {
|
2010-03-05 11:11:05 +01:00
|
|
|
m_usingCurrentFile = true;
|
|
|
|
|
changeCurrentFile(Core::EditorManager::instance()->currentEditor());
|
|
|
|
|
} else {
|
|
|
|
|
m_usingCurrentFile = false;
|
|
|
|
|
m_mainScriptFilename = qmlTarget()->qmlProject()->projectDir().absoluteFilePath(scriptFile);
|
2010-08-19 16:51:27 +02:00
|
|
|
updateEnabled();
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-26 14:46:04 +01:00
|
|
|
void QmlProjectRunConfiguration::onViewerChanged()
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
if (Utils::PathChooser *chooser = qobject_cast<Utils::PathChooser *>(sender())) {
|
|
|
|
|
m_qmlViewerCustomPath = chooser->path();
|
|
|
|
|
}
|
2010-08-20 11:34:02 +02:00
|
|
|
if (!m_qmlViewerExecutable.isNull()) {
|
|
|
|
|
m_qmlViewerExecutable.data()->setText(viewerPath() + " " + m_qmlViewerArgs);
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-26 14:46:04 +01:00
|
|
|
void QmlProjectRunConfiguration::onViewerArgsChanged()
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender()))
|
|
|
|
|
m_qmlViewerArgs = lineEdit->text();
|
2010-08-20 11:34:02 +02:00
|
|
|
|
|
|
|
|
if (!m_qmlViewerExecutable.isNull()) {
|
|
|
|
|
m_qmlViewerExecutable.data()->setText(viewerPath() + " " + m_qmlViewerArgs);
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
void QmlProjectRunConfiguration::useCppDebuggerToggled(bool toggled)
|
|
|
|
|
{
|
|
|
|
|
setUseCppDebugger(toggled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfiguration::useQmlDebuggerToggled(bool toggled)
|
|
|
|
|
{
|
|
|
|
|
setUseQmlDebugger(toggled);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-02 17:17:35 +02:00
|
|
|
void QmlProjectRunConfiguration::qmlDebugServerPortChanged(uint port)
|
|
|
|
|
{
|
|
|
|
|
setQmlDebugServerPort(port);
|
|
|
|
|
}
|
2010-09-01 11:34:34 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QVariantMap QmlProjectRunConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
|
|
|
|
|
|
|
|
|
map.insert(QLatin1String(Constants::QML_VIEWER_KEY), m_qmlViewerCustomPath);
|
|
|
|
|
map.insert(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY), m_qmlViewerArgs);
|
|
|
|
|
map.insert(QLatin1String(Constants::QML_MAINSCRIPT_KEY), m_scriptFile);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_qmlViewerCustomPath = map.value(QLatin1String(Constants::QML_VIEWER_KEY)).toString();
|
|
|
|
|
m_qmlViewerArgs = map.value(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY)).toString();
|
2010-03-05 11:38:17 +01:00
|
|
|
m_scriptFile = map.value(QLatin1String(Constants::QML_MAINSCRIPT_KEY), M_CURRENT_FILE).toString();
|
2010-03-05 11:11:05 +01:00
|
|
|
setMainScript(m_scriptFile);
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
return RunConfiguration::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor * /*editor*/)
|
|
|
|
|
{
|
|
|
|
|
updateEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfiguration::updateEnabled()
|
2010-03-05 11:11:05 +01:00
|
|
|
{
|
2010-08-19 16:51:27 +02:00
|
|
|
bool qmlFileFound = false;
|
2010-03-05 11:11:05 +01:00
|
|
|
if (m_usingCurrentFile) {
|
2010-08-19 16:51:27 +02:00
|
|
|
Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
|
2010-03-05 11:11:05 +01:00
|
|
|
if (editor) {
|
|
|
|
|
m_currentFileFilename = editor->file()->fileName();
|
2010-06-10 09:10:11 +02:00
|
|
|
if (Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).type() == QLatin1String("application/x-qml"))
|
2010-08-19 16:51:27 +02:00
|
|
|
qmlFileFound = true;
|
2010-06-10 09:10:11 +02:00
|
|
|
}
|
|
|
|
|
if (!editor
|
|
|
|
|
|| Core::ICore::instance()->mimeDatabase()->findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
|
2010-03-08 14:36:44 +01:00
|
|
|
// find a qml file with lowercase filename. This is slow but only done in initialization/other border cases.
|
2010-08-19 16:51:27 +02:00
|
|
|
foreach(const QString &filename, m_projectTarget->qmlProject()->files()) {
|
2010-03-08 14:36:44 +01:00
|
|
|
const QFileInfo fi(filename);
|
|
|
|
|
|
|
|
|
|
if (!filename.isEmpty() && fi.baseName()[0].isLower()
|
2010-06-10 09:10:11 +02:00
|
|
|
&& Core::ICore::instance()->mimeDatabase()->findByFile(fi).type() == QLatin1String("application/x-qml"))
|
2010-03-08 14:36:44 +01:00
|
|
|
{
|
|
|
|
|
m_currentFileFilename = filename;
|
2010-08-19 16:51:27 +02:00
|
|
|
qmlFileFound = true;
|
2010-03-08 14:36:44 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
2010-08-19 16:51:27 +02:00
|
|
|
} else { // use default one
|
|
|
|
|
qmlFileFound = !m_mainScriptFilename.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool newValue = QFileInfo(viewerPath()).exists() && qmlFileFound;
|
2010-03-05 11:11:05 +01:00
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
if (m_isEnabled != newValue) {
|
|
|
|
|
m_isEnabled = newValue;
|
|
|
|
|
emit isEnabledChanged(m_isEnabled);
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
QString QmlProjectRunConfiguration::viewerDefaultPath() const
|
2010-03-05 11:11:05 +01:00
|
|
|
{
|
2010-08-19 16:51:27 +02:00
|
|
|
QString path;
|
|
|
|
|
|
2010-08-23 16:00:24 +02:00
|
|
|
// Search for QmlObserver
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
const QString qmlObserverName = QLatin1String("QMLObserver.app");
|
|
|
|
|
#else
|
|
|
|
|
const QString qmlObserverName = QLatin1String("qmlobserver");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
QDir appDir(QCoreApplication::applicationDirPath());
|
|
|
|
|
QString qmlObserverPath;
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
qmlObserverPath = appDir.absoluteFilePath(qmlObserverName + QLatin1String(".exe"));
|
|
|
|
|
#else
|
|
|
|
|
qmlObserverPath = appDir.absoluteFilePath(qmlObserverName);
|
|
|
|
|
#endif
|
|
|
|
|
if (QFileInfo(qmlObserverPath).exists()) {
|
|
|
|
|
return qmlObserverPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Search for QmlViewer
|
|
|
|
|
|
2010-08-19 16:51:27 +02:00
|
|
|
// prepend creator/bin dir to search path (only useful for special creator-qml package)
|
|
|
|
|
const QString searchPath = QCoreApplication::applicationDirPath()
|
|
|
|
|
+ Utils::SynchronousProcess::pathSeparator()
|
|
|
|
|
+ QString::fromLocal8Bit(qgetenv("PATH"));
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
const QString qmlViewerName = QLatin1String("QMLViewer");
|
|
|
|
|
#else
|
|
|
|
|
const QString qmlViewerName = QLatin1String("qmlviewer");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
path = Utils::SynchronousProcess::locateBinary(searchPath, qmlViewerName);
|
|
|
|
|
if (!path.isEmpty())
|
|
|
|
|
return path;
|
|
|
|
|
|
|
|
|
|
// Try to locate default path in Qt Versions
|
|
|
|
|
Qt4ProjectManager::QtVersionManager *qtVersions = Qt4ProjectManager::QtVersionManager::instance();
|
|
|
|
|
foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) {
|
|
|
|
|
if (!version->qmlviewerCommand().isEmpty()
|
|
|
|
|
&& version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) {
|
|
|
|
|
return version->qmlviewerCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path;
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
} // namespace QmlProjectManager
|