2010-11-29 11:42:58 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-11-29 11:42:58 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-11-29 11:42:58 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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-11-29 11:42:58 +01:00
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2010-11-29 11:42:58 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlprojectrunconfigurationwidget.h"
|
|
|
|
|
#include "qmlprojectrunconfiguration.h"
|
|
|
|
|
#include "qmlprojecttarget.h"
|
|
|
|
|
#include "qmlproject.h"
|
|
|
|
|
|
2011-02-24 14:58:37 +01:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2011-01-13 11:41:45 +01:00
|
|
|
#include <projectexplorer/environmentwidget.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2011-09-15 19:20:50 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
#include <utils/debuggerlanguagechooser.h>
|
|
|
|
|
#include <utils/detailswidget.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <utils/environment.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
|
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2010-11-29 11:42:58 +01:00
|
|
|
|
2011-01-20 14:03:07 +01:00
|
|
|
#include <QtGui/QLineEdit>
|
|
|
|
|
#include <QtGui/QComboBox>
|
|
|
|
|
#include <QtGui/QFormLayout>
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QPushButton>
|
|
|
|
|
#include <QtGui/QStandardItemModel>
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
using Core::ICore;
|
|
|
|
|
using Utils::DebuggerLanguageChooser;
|
2011-05-20 21:40:53 +02:00
|
|
|
using QtSupport::QtVersionManager;
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc) :
|
|
|
|
|
m_runConfiguration(rc),
|
|
|
|
|
m_qtVersionComboBox(0),
|
|
|
|
|
m_fileListCombo(0),
|
2010-12-03 17:04:29 +01:00
|
|
|
m_fileListModel(new QStandardItemModel(this))
|
2010-11-29 11:42:58 +01:00
|
|
|
{
|
2010-11-29 12:50:44 +01:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Qt Version, Arguments
|
|
|
|
|
//
|
|
|
|
|
|
2010-11-29 11:42:58 +01:00
|
|
|
Utils::DetailsWidget *detailsWidget = new Utils::DetailsWidget();
|
|
|
|
|
detailsWidget->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
|
|
|
|
|
QWidget *formWidget = new QWidget(detailsWidget);
|
|
|
|
|
detailsWidget->setWidget(formWidget);
|
|
|
|
|
QFormLayout *form = new QFormLayout(formWidget);
|
|
|
|
|
form->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
|
|
|
|
|
m_fileListCombo = new QComboBox;
|
|
|
|
|
m_fileListCombo->setModel(m_fileListModel);
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
connect(m_fileListCombo, SIGNAL(activated(int)), this, SLOT(setMainScript(int)));
|
2010-11-29 11:42:58 +01:00
|
|
|
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(fileListChanged()),
|
|
|
|
|
SLOT(updateFileComboBox()));
|
|
|
|
|
|
|
|
|
|
m_qtVersionComboBox = new QComboBox;
|
|
|
|
|
m_qtVersionComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
|
connect(m_qtVersionComboBox, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(onQtVersionSelectionChanged()));
|
|
|
|
|
|
|
|
|
|
QPushButton *pushButton = new QPushButton;
|
2011-10-05 20:13:49 +02:00
|
|
|
pushButton->setText(tr("Manage Qt versions..."));
|
2010-11-29 11:42:58 +01:00
|
|
|
connect(pushButton, SIGNAL(clicked()), this, SLOT(manageQtVersions()));
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *qtVersionLayout = new QHBoxLayout;
|
|
|
|
|
qtVersionLayout->addWidget(m_qtVersionComboBox);
|
|
|
|
|
qtVersionLayout->addWidget(pushButton);
|
|
|
|
|
|
|
|
|
|
QLineEdit *qmlViewerArgs = new QLineEdit;
|
|
|
|
|
qmlViewerArgs->setText(rc->m_qmlViewerArgs);
|
|
|
|
|
connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onViewerArgsChanged()));
|
|
|
|
|
|
|
|
|
|
form->addRow(tr("Qt version:"), qtVersionLayout);
|
|
|
|
|
form->addRow(tr("Arguments:"), qmlViewerArgs);
|
2010-11-29 12:50:44 +01:00
|
|
|
form->addRow(tr("Main QML file:"), m_fileListCombo);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(detailsWidget);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Debugging
|
|
|
|
|
//
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
QLabel *debuggerLabel = new QLabel(tr("Debugger:"));
|
2011-05-17 14:43:01 +02:00
|
|
|
debuggerLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
DebuggerLanguageChooser *debuggerLanguageChooser = new DebuggerLanguageChooser(formWidget);
|
2011-05-17 14:43:01 +02:00
|
|
|
form->addRow(debuggerLabel, debuggerLanguageChooser);
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
debuggerLanguageChooser->setCppChecked(rc->useCppDebugger());
|
|
|
|
|
debuggerLanguageChooser->setQmlChecked(rc->useQmlDebugger());
|
|
|
|
|
debuggerLanguageChooser->setQmlDebugServerPort(rc->qmlDebugServerPort());
|
|
|
|
|
|
|
|
|
|
connect(debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
|
|
|
|
|
this, SLOT(useCppDebuggerToggled(bool)));
|
|
|
|
|
connect(debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
|
|
|
|
|
this, SLOT(useQmlDebuggerToggled(bool)));
|
|
|
|
|
connect(debuggerLanguageChooser, SIGNAL(qmlDebugServerPortChanged(uint)),
|
|
|
|
|
this, SLOT(qmlDebugServerPortChanged(uint)));
|
2011-02-24 14:58:37 +01:00
|
|
|
connect(debuggerLanguageChooser, SIGNAL(openHelpUrl(QString)),
|
|
|
|
|
Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
|
|
|
|
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)),
|
|
|
|
|
this, SLOT(updateQtVersionComboBox()));
|
|
|
|
|
|
2010-11-29 12:50:44 +01:00
|
|
|
//
|
|
|
|
|
// Environment
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
QLabel *environmentLabel = new QLabel(this);
|
|
|
|
|
environmentLabel->setText(tr("Run Environment"));
|
|
|
|
|
QFont f = environmentLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() *1.2);
|
|
|
|
|
environmentLabel->setFont(f);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(environmentLabel);
|
|
|
|
|
|
|
|
|
|
QWidget *baseEnvironmentWidget = new QWidget;
|
|
|
|
|
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
|
|
|
|
|
baseEnvironmentLayout->setMargin(0);
|
|
|
|
|
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(rc->baseEnvironment());
|
2010-11-29 14:16:38 +01:00
|
|
|
m_environmentWidget->setBaseEnvironmentText(tr("System Environment"));
|
2010-11-29 12:50:44 +01:00
|
|
|
m_environmentWidget->setUserChanges(rc->userEnvironmentChanges());
|
|
|
|
|
|
|
|
|
|
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
|
|
|
|
|
this, SLOT(userChangesChanged()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layout->addWidget(m_environmentWidget);
|
2011-07-28 18:23:01 +02:00
|
|
|
|
|
|
|
|
updateFileComboBox();
|
|
|
|
|
updateQtVersionComboBox();
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
|
|
|
|
{
|
|
|
|
|
return s1.toLower() < s2.toLower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::updateFileComboBox()
|
|
|
|
|
{
|
|
|
|
|
QmlProject *project = m_runConfiguration->qmlTarget()->qmlProject();
|
|
|
|
|
QDir projectDir = project->projectDir();
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
m_fileListModel->clear();
|
|
|
|
|
m_fileListModel->appendRow(new QStandardItem(CURRENT_FILE));
|
|
|
|
|
QModelIndex currentIndex;
|
|
|
|
|
QModelIndex fileInQmlProjectIndex;
|
|
|
|
|
|
|
|
|
|
const QString mainScriptInFilePath = projectDir.absoluteFilePath(project->mainFile());
|
|
|
|
|
|
2010-11-29 11:42:58 +01:00
|
|
|
QStringList sortedFiles = project->files();
|
2010-12-03 17:04:29 +01:00
|
|
|
if (!sortedFiles.contains(mainScriptInFilePath))
|
|
|
|
|
sortedFiles += mainScriptInFilePath;
|
|
|
|
|
|
|
|
|
|
// make paths relative to project directory
|
|
|
|
|
QStringList relativeFiles;
|
|
|
|
|
foreach (const QString &fn, sortedFiles) {
|
|
|
|
|
relativeFiles += projectDir.relativeFilePath(fn);
|
|
|
|
|
}
|
|
|
|
|
sortedFiles = relativeFiles;
|
|
|
|
|
|
2010-11-29 11:42:58 +01:00
|
|
|
qStableSort(sortedFiles.begin(), sortedFiles.end(), caseInsensitiveLessThan);
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
QString mainScriptPath;
|
|
|
|
|
if (m_runConfiguration->mainScriptSource() != QmlProjectRunConfiguration::FileInEditor)
|
|
|
|
|
mainScriptPath = projectDir.relativeFilePath(m_runConfiguration->mainScript());
|
|
|
|
|
|
2010-11-29 11:42:58 +01:00
|
|
|
foreach (const QString &fn, sortedFiles) {
|
|
|
|
|
QFileInfo fileInfo(fn);
|
|
|
|
|
if (fileInfo.suffix() != QLatin1String("qml"))
|
|
|
|
|
continue;
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
QStandardItem *item = new QStandardItem(fn);
|
|
|
|
|
m_fileListModel->appendRow(item);
|
2010-11-29 11:42:58 +01:00
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
if (mainScriptPath == fn)
|
|
|
|
|
currentIndex = item->index();
|
|
|
|
|
|
|
|
|
|
if (mainScriptInFilePath == fn)
|
|
|
|
|
fileInQmlProjectIndex = item->index();
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
if (currentIndex.isValid()) {
|
|
|
|
|
m_fileListCombo->setCurrentIndex(currentIndex.row());
|
|
|
|
|
} else {
|
2010-11-29 11:42:58 +01:00
|
|
|
m_fileListCombo->setCurrentIndex(0);
|
2010-12-03 17:04:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fileInQmlProjectIndex.isValid()) {
|
|
|
|
|
QFont font;
|
|
|
|
|
font.setBold(true);
|
|
|
|
|
m_fileListModel->setData(fileInQmlProjectIndex, font, Qt::FontRole);
|
|
|
|
|
}
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
void QmlProjectRunConfigurationWidget::setMainScript(int index)
|
2010-11-29 11:42:58 +01:00
|
|
|
{
|
2010-12-03 17:04:29 +01:00
|
|
|
QmlProject *project = m_runConfiguration->qmlTarget()->qmlProject();
|
|
|
|
|
QDir projectDir = project->projectDir();
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
m_runConfiguration->setScriptSource(QmlProjectRunConfiguration::FileInEditor);
|
|
|
|
|
} else {
|
|
|
|
|
const QString path = m_fileListModel->data(m_fileListModel->index(index, 0)).toString();
|
|
|
|
|
if (projectDir.relativeFilePath(project->mainFile()) == path) {
|
|
|
|
|
m_runConfiguration->setScriptSource(QmlProjectRunConfiguration::FileInProjectFile);
|
|
|
|
|
} else {
|
|
|
|
|
m_runConfiguration->setScriptSource(QmlProjectRunConfiguration::FileInSettings, path);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::onQtVersionSelectionChanged()
|
|
|
|
|
{
|
|
|
|
|
QVariant data = m_qtVersionComboBox->itemData(m_qtVersionComboBox->currentIndex());
|
|
|
|
|
QTC_ASSERT(data.isValid() && data.canConvert(QVariant::Int), return)
|
|
|
|
|
m_runConfiguration->setQtVersionId(data.toInt());
|
|
|
|
|
m_runConfiguration->updateEnabled();
|
2011-07-28 18:23:01 +02:00
|
|
|
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::onViewerArgsChanged()
|
|
|
|
|
{
|
|
|
|
|
if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender()))
|
|
|
|
|
m_runConfiguration->m_qmlViewerArgs = lineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::useCppDebuggerToggled(bool toggled)
|
|
|
|
|
{
|
|
|
|
|
m_runConfiguration->setUseCppDebugger(toggled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::useQmlDebuggerToggled(bool toggled)
|
|
|
|
|
{
|
|
|
|
|
m_runConfiguration->setUseQmlDebugger(toggled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::qmlDebugServerPortChanged(uint port)
|
|
|
|
|
{
|
|
|
|
|
m_runConfiguration->setQmlDebugServerPort(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::manageQtVersions()
|
|
|
|
|
{
|
|
|
|
|
ICore *core = ICore::instance();
|
2011-09-15 19:20:50 +02:00
|
|
|
core->showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
|
2011-05-20 21:40:53 +02:00
|
|
|
QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::updateQtVersionComboBox()
|
|
|
|
|
{
|
|
|
|
|
m_qtVersionComboBox->clear();
|
|
|
|
|
|
|
|
|
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
2011-05-20 21:40:53 +02:00
|
|
|
foreach (QtSupport::BaseQtVersion *version, qtVersions->validVersions()) {
|
2010-11-29 11:42:58 +01:00
|
|
|
if (m_runConfiguration->isValidVersion(version)) {
|
|
|
|
|
m_qtVersionComboBox->addItem(version->displayName(), version->uniqueId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_runConfiguration->m_qtVersionId != -1) {
|
|
|
|
|
int index = m_qtVersionComboBox->findData(m_runConfiguration->m_qtVersionId);
|
|
|
|
|
QTC_ASSERT(index >= 0, return);
|
|
|
|
|
m_qtVersionComboBox->setCurrentIndex(index);
|
|
|
|
|
} else {
|
|
|
|
|
m_qtVersionComboBox->addItem(tr("Invalid Qt version"), -1);
|
|
|
|
|
m_qtVersionComboBox->setCurrentIndex(0);
|
|
|
|
|
}
|
2011-07-28 18:23:01 +02:00
|
|
|
// Might have edited the qt version or changed e.g. the sysroot of a SymbianQtVersion
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
|
2010-11-29 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-29 12:50:44 +01:00
|
|
|
void QmlProjectRunConfigurationWidget::userChangesChanged()
|
|
|
|
|
{
|
|
|
|
|
m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectRunConfigurationWidget::userEnvironmentChangesChanged()
|
|
|
|
|
{
|
|
|
|
|
m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges());
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-29 11:42:58 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|