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)
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2010-02-16 13:39:13 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2010-02-16 13:39:13 +01:00
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-16 13:39:13 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
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"
|
2010-11-29 11:42:58 +01:00
|
|
|
#include "qmlprojectrunconfigurationwidget.h"
|
2010-03-05 11:11:05 +01:00
|
|
|
#include <coreplugin/mimedatabase.h>
|
2010-02-16 13:39:13 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-10-04 15:03:01 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2010-08-19 16:51:27 +02:00
|
|
|
#include <qt4projectmanager/qtversionmanager.h>
|
2010-10-18 12:39:02 +02:00
|
|
|
#include <qt4projectmanager/qtoutputformatter.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
2010-11-29 09:45:30 +01:00
|
|
|
|
2010-12-21 12:39:14 +01:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-11-29 09:45:30 +01:00
|
|
|
using Core::EditorManager;
|
|
|
|
|
using Core::ICore;
|
|
|
|
|
using Core::IEditor;
|
|
|
|
|
using Qt4ProjectManager::QtVersionManager;
|
|
|
|
|
|
|
|
|
|
using namespace QmlProjectManager::Internal;
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
const char * const M_CURRENT_FILE = "CurrentFile";
|
2010-11-29 09:45:30 +01:00
|
|
|
|
|
|
|
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent) :
|
2010-02-16 13:39:13 +01:00
|
|
|
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
|
2010-10-04 15:03:01 +02:00
|
|
|
m_qtVersionId(-1),
|
2010-03-08 14:36:44 +01:00
|
|
|
m_projectTarget(parent),
|
2010-03-09 17:04:09 +01:00
|
|
|
m_usingCurrentFile(true),
|
2010-11-29 14:16:38 +01:00
|
|
|
m_isEnabled(false)
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
2010-10-06 10:03:51 +02:00
|
|
|
updateQtVersions();
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-29 09:45:30 +01:00
|
|
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent,
|
|
|
|
|
QmlProjectRunConfiguration *source) :
|
2010-02-16 13:39:13 +01:00
|
|
|
ProjectExplorer::RunConfiguration(parent, source),
|
2010-10-04 15:03:01 +02:00
|
|
|
m_qtVersionId(source->m_qtVersionId),
|
2010-12-03 17:04:29 +01:00
|
|
|
m_scriptFile(source->m_scriptFile),
|
2010-04-16 15:55:42 +02:00
|
|
|
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
2010-11-29 12:50:44 +01:00
|
|
|
m_projectTarget(parent),
|
2010-12-03 17:04:29 +01:00
|
|
|
m_usingCurrentFile(source->m_usingCurrentFile),
|
2010-11-29 14:16:38 +01:00
|
|
|
m_userEnvironmentChanges(source->m_userEnvironmentChanges)
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-04-19 11:02:06 +02:00
|
|
|
ctor();
|
2010-10-06 10:03:51 +02:00
|
|
|
updateQtVersions();
|
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-11-29 09:45:30 +01:00
|
|
|
EditorManager *em = Core::EditorManager::instance();
|
2010-03-05 11:11:05 +01:00
|
|
|
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
|
|
|
this, SLOT(changeCurrentFile(Core::IEditor*)));
|
|
|
|
|
|
2010-11-29 09:45:30 +01:00
|
|
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
2010-10-04 15:03:01 +02:00
|
|
|
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)), this, SLOT(updateQtVersions()));
|
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()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-29 09:45:30 +01:00
|
|
|
QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-11-29 09:45:30 +01:00
|
|
|
return static_cast<QmlProjectTarget *>(target());
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
QString QmlProjectRunConfiguration::viewerPath() const
|
2010-09-28 17:26:27 +02:00
|
|
|
{
|
2010-10-05 10:54:05 +02:00
|
|
|
Qt4ProjectManager::QtVersion *version = qtVersion();
|
|
|
|
|
if (!version) {
|
2010-10-04 15:03:01 +02:00
|
|
|
return QString();
|
2010-10-05 10:54:05 +02:00
|
|
|
} else {
|
|
|
|
|
return version->qmlviewerCommand();
|
|
|
|
|
}
|
2010-09-28 17:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
QString QmlProjectRunConfiguration::observerPath() const
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-10-05 10:54:05 +02:00
|
|
|
Qt4ProjectManager::QtVersion *version = qtVersion();
|
|
|
|
|
if (!version) {
|
2010-10-04 15:03:01 +02:00
|
|
|
return QString();
|
2010-10-05 10:54:05 +02:00
|
|
|
} else {
|
|
|
|
|
return version->qmlObserverTool();
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString QmlProjectRunConfiguration::viewerArguments() const
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
|
|
|
|
// arguments in .user file
|
2010-10-19 11:14:03 +02:00
|
|
|
QString args = m_qmlViewerArgs;
|
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-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&args, "-I");
|
|
|
|
|
Utils::QtcProcess::addArg(&args, importPath);
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-21 12:39:14 +01:00
|
|
|
QString s = mainScript();
|
|
|
|
|
if (!s.isEmpty()) {
|
|
|
|
|
s = canonicalCapsPath(s);
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&args, s);
|
2010-12-21 12:39:14 +01:00
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
return args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlProjectRunConfiguration::workingDirectory() const
|
|
|
|
|
{
|
|
|
|
|
QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName());
|
2010-12-21 12:39:14 +01:00
|
|
|
return canonicalCapsPath(projectFile.absolutePath());
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 10:03:51 +02:00
|
|
|
int QmlProjectRunConfiguration::qtVersionId() const
|
|
|
|
|
{
|
|
|
|
|
return m_qtVersionId;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:02:26 +02:00
|
|
|
void QmlProjectRunConfiguration::setQtVersionId(int id)
|
|
|
|
|
{
|
|
|
|
|
if (m_qtVersionId == id)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_qtVersionId = id;
|
|
|
|
|
qmlTarget()->qmlProject()->refresh(QmlProject::Configuration);
|
2010-11-29 11:42:58 +01:00
|
|
|
if (m_configurationWidget)
|
|
|
|
|
m_configurationWidget.data()->updateQtVersionComboBox();
|
2010-10-13 13:02:26 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-21 12:39:14 +01:00
|
|
|
/* QtDeclarative checks explicitly that the capitalization for any URL / path
|
|
|
|
|
is exactly like the capitalization on disk. This method is uses the same
|
|
|
|
|
native Windows API's to get the exact canonical path. */
|
|
|
|
|
QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
QString canonicalPath = QFileInfo(fileName).canonicalFilePath();
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
|
wchar_t *buffer = 0;
|
|
|
|
|
do {
|
|
|
|
|
long length = ::GetLongPathName((wchar_t*)fileName.utf16(), NULL, 0);
|
|
|
|
|
if (!length)
|
|
|
|
|
break;
|
|
|
|
|
buffer = new wchar_t[length];
|
|
|
|
|
DWORD rv = ::GetLongPathName((wchar_t*)fileName.utf16(), buffer, length);
|
|
|
|
|
if (!rv)
|
|
|
|
|
break;
|
|
|
|
|
canonicalPath = QString((QChar*)buffer);
|
|
|
|
|
} while (false);
|
|
|
|
|
delete buffer;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return canonicalPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-05 10:54:05 +02:00
|
|
|
Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const
|
|
|
|
|
{
|
|
|
|
|
if (m_qtVersionId == -1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2010-11-29 09:45:30 +01:00
|
|
|
QtVersionManager *versionManager = QtVersionManager::instance();
|
2010-10-05 10:54:05 +02:00
|
|
|
Qt4ProjectManager::QtVersion *version = versionManager->version(m_qtVersionId);
|
|
|
|
|
QTC_ASSERT(version, return 0);
|
|
|
|
|
|
|
|
|
|
return version;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
QWidget *QmlProjectRunConfiguration::createConfigurationWidget()
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-11-29 11:42:58 +01:00
|
|
|
QTC_ASSERT(m_configurationWidget.isNull(), return m_configurationWidget.data());
|
|
|
|
|
m_configurationWidget = new QmlProjectRunConfigurationWidget(this);
|
|
|
|
|
return m_configurationWidget.data();
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-18 12:39:02 +02:00
|
|
|
ProjectExplorer::OutputFormatter *QmlProjectRunConfiguration::createOutputFormatter() const
|
|
|
|
|
{
|
|
|
|
|
return new Qt4ProjectManager::QtOutputFormatter(qmlTarget()->qmlProject());
|
|
|
|
|
}
|
2010-04-13 10:58:30 +02:00
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
QmlProjectRunConfiguration::MainScriptSource QmlProjectRunConfiguration::mainScriptSource() const
|
|
|
|
|
{
|
|
|
|
|
if (m_usingCurrentFile) {
|
|
|
|
|
return FileInEditor;
|
|
|
|
|
}
|
|
|
|
|
if (!m_mainScriptFilename.isEmpty()) {
|
|
|
|
|
return FileInSettings;
|
|
|
|
|
}
|
|
|
|
|
return FileInProjectFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns absolute path to main script file.
|
|
|
|
|
*/
|
2010-02-16 13:39:13 +01:00
|
|
|
QString QmlProjectRunConfiguration::mainScript() const
|
|
|
|
|
{
|
2010-12-03 17:04:29 +01:00
|
|
|
if (m_usingCurrentFile) {
|
2010-03-05 11:11:05 +01:00
|
|
|
return m_currentFileFilename;
|
2010-12-03 17:04:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_mainScriptFilename.isEmpty()) {
|
|
|
|
|
return m_mainScriptFilename;
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
QString path = qmlTarget()->qmlProject()->mainFile();
|
|
|
|
|
if (QFileInfo(path).isAbsolute()) {
|
|
|
|
|
return path;
|
|
|
|
|
} else {
|
|
|
|
|
return qmlTarget()->qmlProject()->projectDir().absoluteFilePath(path);
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
void QmlProjectRunConfiguration::setScriptSource(MainScriptSource source,
|
|
|
|
|
const QString &settingsPath)
|
2010-02-16 13:39:13 +01:00
|
|
|
{
|
2010-12-10 13:19:55 +01:00
|
|
|
if (source == FileInEditor) {
|
|
|
|
|
m_scriptFile = M_CURRENT_FILE;
|
2010-12-03 17:04:29 +01:00
|
|
|
m_mainScriptFilename.clear();
|
2010-03-05 11:11:05 +01:00
|
|
|
m_usingCurrentFile = true;
|
2010-12-03 17:04:29 +01:00
|
|
|
} else if (source == FileInProjectFile) {
|
|
|
|
|
m_scriptFile.clear();
|
|
|
|
|
m_mainScriptFilename.clear();
|
|
|
|
|
m_usingCurrentFile = false;
|
|
|
|
|
} else { // FileInSettings
|
|
|
|
|
m_scriptFile = settingsPath;
|
|
|
|
|
m_mainScriptFilename
|
|
|
|
|
= qmlTarget()->qmlProject()->projectDir().absoluteFilePath(m_scriptFile);
|
2010-03-05 11:11:05 +01:00
|
|
|
m_usingCurrentFile = false;
|
|
|
|
|
}
|
2010-12-03 17:04:29 +01:00
|
|
|
updateEnabled();
|
|
|
|
|
if (m_configurationWidget)
|
|
|
|
|
m_configurationWidget.data()->updateFileComboBox();
|
2010-02-16 13:39:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-29 12:50:44 +01:00
|
|
|
Utils::Environment QmlProjectRunConfiguration::environment() const
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env = baseEnvironment();
|
|
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QVariantMap QmlProjectRunConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
map.insert(QLatin1String(Constants::QML_VIEWER_QT_KEY), m_qtVersionId);
|
2010-02-16 13:39:13 +01:00
|
|
|
map.insert(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY), m_qmlViewerArgs);
|
|
|
|
|
map.insert(QLatin1String(Constants::QML_MAINSCRIPT_KEY), m_scriptFile);
|
2010-11-29 12:50:44 +01:00
|
|
|
map.insert(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY),
|
|
|
|
|
Utils::EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
2010-02-16 13:39:13 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2010-10-13 13:02:26 +02:00
|
|
|
setQtVersionId(map.value(QLatin1String(Constants::QML_VIEWER_QT_KEY), -1).toInt());
|
2010-02-16 13:39:13 +01:00
|
|
|
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-11-29 12:50:44 +01:00
|
|
|
m_userEnvironmentChanges = Utils::EnvironmentItem::fromStringList(
|
|
|
|
|
map.value(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
|
|
|
|
|
updateQtVersions();
|
2010-12-03 17:04:29 +01:00
|
|
|
if (m_scriptFile == M_CURRENT_FILE) {
|
|
|
|
|
setScriptSource(FileInEditor);
|
|
|
|
|
} else if (m_scriptFile.isEmpty()) {
|
|
|
|
|
setScriptSource(FileInProjectFile);
|
|
|
|
|
} else {
|
|
|
|
|
setScriptSource(FileInSettings, 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-11-29 09:45:30 +01:00
|
|
|
Core::MimeDatabase *db = ICore::instance()->mimeDatabase();
|
2010-03-05 11:11:05 +01:00
|
|
|
if (editor) {
|
|
|
|
|
m_currentFileFilename = editor->file()->fileName();
|
2010-11-29 09:45:30 +01:00
|
|
|
if (db->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
|
2010-11-29 09:45:30 +01:00
|
|
|
|| db->findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
|
|
|
|
|
// 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-11-29 09:45:30 +01:00
|
|
|
&& db->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
|
2010-12-03 17:04:29 +01:00
|
|
|
qmlFileFound = !mainScript().isEmpty();
|
2010-08-19 16:51:27 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
bool newValue = (QFileInfo(viewerPath()).exists()
|
|
|
|
|
|| QFileInfo(observerPath()).exists()) && qmlFileFound;
|
2010-03-05 11:11:05 +01:00
|
|
|
|
2010-10-05 10:54:05 +02:00
|
|
|
|
|
|
|
|
// Always emit change signal to force reevaluation of run/debug buttons
|
|
|
|
|
m_isEnabled = newValue;
|
|
|
|
|
emit isEnabledChanged(m_isEnabled);
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
void QmlProjectRunConfiguration::updateQtVersions()
|
2010-03-05 11:11:05 +01:00
|
|
|
{
|
2010-11-29 09:45:30 +01:00
|
|
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
2010-10-04 15:03:01 +02:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// update m_qtVersionId
|
|
|
|
|
//
|
|
|
|
|
if (!qtVersions->isValidId(m_qtVersionId)
|
|
|
|
|
|| !isValidVersion(qtVersions->version(m_qtVersionId))) {
|
2010-10-13 13:02:26 +02:00
|
|
|
int newVersionId = -1;
|
2010-10-04 15:03:01 +02:00
|
|
|
// take first one you find
|
|
|
|
|
foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) {
|
|
|
|
|
if (isValidVersion(version)) {
|
2010-10-13 13:02:26 +02:00
|
|
|
newVersionId = version->uniqueId();
|
2010-09-27 17:22:57 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2010-08-19 16:51:27 +02:00
|
|
|
}
|
2010-10-13 13:02:26 +02:00
|
|
|
setQtVersionId(newVersionId);
|
2010-08-19 16:51:27 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:03:01 +02:00
|
|
|
updateEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *version)
|
|
|
|
|
{
|
|
|
|
|
if (version
|
2010-11-12 13:37:54 +01:00
|
|
|
&& (version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)
|
|
|
|
|
|| version->supportsTargetId(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID))
|
2010-10-04 15:03:01 +02:00
|
|
|
&& !version->qmlviewerCommand().isEmpty()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2010-03-05 11:11:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-29 12:50:44 +01:00
|
|
|
Utils::Environment QmlProjectRunConfiguration::baseEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env;
|
2010-11-30 07:48:58 +01:00
|
|
|
if (qtVersion())
|
|
|
|
|
env = qtVersion()->qmlToolsEnvironment();
|
2010-11-29 12:50:44 +01:00
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfiguration::setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff)
|
|
|
|
|
{
|
|
|
|
|
if (m_userEnvironmentChanges != diff) {
|
|
|
|
|
m_userEnvironmentChanges = diff;
|
|
|
|
|
if (m_configurationWidget)
|
|
|
|
|
m_configurationWidget.data()->userEnvironmentChangesChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Utils::EnvironmentItem> QmlProjectRunConfiguration::userEnvironmentChanges() const
|
|
|
|
|
{
|
|
|
|
|
return m_userEnvironmentChanges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
} // namespace QmlProjectManager
|