forked from qt-creator/qt-creator
QmlProject: Split RunConfiguration, ..Widget into two classes
This commit is contained in:
@@ -20,7 +20,8 @@ HEADERS += qmlproject.h \
|
|||||||
qmlprojectapplicationwizard.h \
|
qmlprojectapplicationwizard.h \
|
||||||
qmlprojectmanager_global.h \
|
qmlprojectmanager_global.h \
|
||||||
qmlprojectmanagerconstants.h \
|
qmlprojectmanagerconstants.h \
|
||||||
qmlprojecttarget.h
|
qmlprojecttarget.h \
|
||||||
|
qmlprojectrunconfigurationwidget.h
|
||||||
|
|
||||||
SOURCES += qmlproject.cpp \
|
SOURCES += qmlproject.cpp \
|
||||||
qmlprojectplugin.cpp \
|
qmlprojectplugin.cpp \
|
||||||
@@ -31,7 +32,8 @@ SOURCES += qmlproject.cpp \
|
|||||||
qmlprojectrunconfiguration.cpp \
|
qmlprojectrunconfiguration.cpp \
|
||||||
qmlprojectrunconfigurationfactory.cpp \
|
qmlprojectrunconfigurationfactory.cpp \
|
||||||
qmlprojectapplicationwizard.cpp \
|
qmlprojectapplicationwizard.cpp \
|
||||||
qmlprojecttarget.cpp
|
qmlprojecttarget.cpp \
|
||||||
|
qmlprojectrunconfigurationwidget.cpp
|
||||||
|
|
||||||
RESOURCES += qmlproject.qrc
|
RESOURCES += qmlproject.qrc
|
||||||
|
|
||||||
|
|||||||
@@ -30,48 +30,31 @@
|
|||||||
#include "qmlprojectrunconfiguration.h"
|
#include "qmlprojectrunconfiguration.h"
|
||||||
#include "qmlproject.h"
|
#include "qmlproject.h"
|
||||||
#include "qmlprojectmanagerconstants.h"
|
#include "qmlprojectmanagerconstants.h"
|
||||||
#include "qmlprojecttarget.h"
|
#include "qmlprojectrunconfigurationwidget.h"
|
||||||
#include "projectexplorer/projectexplorer.h"
|
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/ifile.h>
|
|
||||||
#include <utils/synchronousprocess.h>
|
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
#include <utils/debuggerlanguagechooser.h>
|
|
||||||
#include <utils/detailswidget.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <qt4projectmanager/qtversionmanager.h>
|
#include <qt4projectmanager/qtversionmanager.h>
|
||||||
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
|
||||||
#include <qt4projectmanager/qmlobservertool.h>
|
|
||||||
#include <qt4projectmanager/qtoutputformatter.h>
|
#include <qt4projectmanager/qtoutputformatter.h>
|
||||||
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QStringListModel>
|
|
||||||
|
|
||||||
using Core::EditorManager;
|
using Core::EditorManager;
|
||||||
using Core::ICore;
|
using Core::ICore;
|
||||||
using Core::IEditor;
|
using Core::IEditor;
|
||||||
using Utils::DebuggerLanguageChooser;
|
|
||||||
using Qt4ProjectManager::QtVersionManager;
|
using Qt4ProjectManager::QtVersionManager;
|
||||||
|
|
||||||
using namespace QmlProjectManager::Internal;
|
using namespace QmlProjectManager::Internal;
|
||||||
|
|
||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
const char * const CURRENT_FILE = QT_TRANSLATE_NOOP("QmlManager", "<Current File>");
|
|
||||||
const char * const M_CURRENT_FILE = "CurrentFile";
|
const char * const M_CURRENT_FILE = "CurrentFile";
|
||||||
|
|
||||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent) :
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent) :
|
||||||
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
|
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
|
||||||
m_qtVersionId(-1),
|
m_qtVersionId(-1),
|
||||||
m_fileListModel(new QStringListModel(this)),
|
|
||||||
m_projectTarget(parent),
|
m_projectTarget(parent),
|
||||||
m_usingCurrentFile(true),
|
m_usingCurrentFile(true),
|
||||||
m_isEnabled(false)
|
m_isEnabled(false)
|
||||||
@@ -85,7 +68,6 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent,
|
|||||||
ProjectExplorer::RunConfiguration(parent, source),
|
ProjectExplorer::RunConfiguration(parent, source),
|
||||||
m_qtVersionId(source->m_qtVersionId),
|
m_qtVersionId(source->m_qtVersionId),
|
||||||
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
||||||
m_fileListModel(new QStringListModel(this)),
|
|
||||||
m_projectTarget(parent)
|
m_projectTarget(parent)
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
@@ -180,6 +162,8 @@ void QmlProjectRunConfiguration::setQtVersionId(int id)
|
|||||||
|
|
||||||
m_qtVersionId = id;
|
m_qtVersionId = id;
|
||||||
qmlTarget()->qmlProject()->refresh(QmlProject::Configuration);
|
qmlTarget()->qmlProject()->refresh(QmlProject::Configuration);
|
||||||
|
if (m_configurationWidget)
|
||||||
|
m_configurationWidget.data()->updateQtVersionComboBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const
|
Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const
|
||||||
@@ -194,79 +178,11 @@ Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
|
||||||
{
|
|
||||||
return s1.toLower() < s2.toLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *QmlProjectRunConfiguration::createConfigurationWidget()
|
QWidget *QmlProjectRunConfiguration::createConfigurationWidget()
|
||||||
{
|
{
|
||||||
Utils::DetailsWidget *detailsWidget = new Utils::DetailsWidget();
|
QTC_ASSERT(m_configurationWidget.isNull(), return m_configurationWidget.data());
|
||||||
detailsWidget->setState(Utils::DetailsWidget::NoSummary);
|
m_configurationWidget = new QmlProjectRunConfigurationWidget(this);
|
||||||
|
return m_configurationWidget.data();
|
||||||
QWidget *formWidget = new QWidget(detailsWidget);
|
|
||||||
detailsWidget->setWidget(formWidget);
|
|
||||||
QFormLayout *form = new QFormLayout(formWidget);
|
|
||||||
form->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
||||||
|
|
||||||
m_fileListCombo = new QComboBox;
|
|
||||||
m_fileListCombo.data()->setModel(m_fileListModel);
|
|
||||||
updateFileComboBox();
|
|
||||||
|
|
||||||
connect(m_fileListCombo.data(), SIGNAL(activated(QString)),
|
|
||||||
this, SLOT(setMainScript(QString)));
|
|
||||||
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(fileListChanged()),
|
|
||||||
SLOT(updateFileComboBox()));
|
|
||||||
|
|
||||||
m_qtVersionComboBox = new QComboBox;
|
|
||||||
m_qtVersionComboBox.data()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
connect(m_qtVersionComboBox.data(), SIGNAL(activated(int)),
|
|
||||||
this, SLOT(onQtVersionSelectionChanged()));
|
|
||||||
|
|
||||||
QPushButton *pushButton = new QPushButton;
|
|
||||||
pushButton->setText(tr("Manage Qt versions"));
|
|
||||||
connect(pushButton, SIGNAL(clicked()), this, SLOT(manageQtVersions()));
|
|
||||||
|
|
||||||
QHBoxLayout *qtVersionLayout = new QHBoxLayout;
|
|
||||||
qtVersionLayout->addWidget(m_qtVersionComboBox.data());
|
|
||||||
qtVersionLayout->addWidget(pushButton);
|
|
||||||
|
|
||||||
QLineEdit *qmlViewerArgs = new QLineEdit;
|
|
||||||
qmlViewerArgs->setText(m_qmlViewerArgs);
|
|
||||||
connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onViewerArgsChanged()));
|
|
||||||
|
|
||||||
form->addRow(tr("Qt version:"), qtVersionLayout);
|
|
||||||
form->addRow(tr("Arguments:"), qmlViewerArgs);
|
|
||||||
|
|
||||||
QWidget *debuggerLabelWidget = new QWidget;
|
|
||||||
QVBoxLayout *debuggerLabelLayout = new QVBoxLayout(debuggerLabelWidget);
|
|
||||||
debuggerLabelLayout->setMargin(0);
|
|
||||||
debuggerLabelLayout->setSpacing(0);
|
|
||||||
debuggerLabelWidget->setLayout(debuggerLabelLayout);
|
|
||||||
QLabel *debuggerLabel = new QLabel(tr("Debugger:"));
|
|
||||||
debuggerLabelLayout->addWidget(debuggerLabel);
|
|
||||||
debuggerLabelLayout->addStretch(10);
|
|
||||||
|
|
||||||
DebuggerLanguageChooser *debuggerLanguageChooser = new DebuggerLanguageChooser(formWidget);
|
|
||||||
|
|
||||||
form->addRow(tr("Main QML file:"), m_fileListCombo.data());
|
|
||||||
form->addRow(debuggerLabelWidget, debuggerLanguageChooser);
|
|
||||||
|
|
||||||
debuggerLanguageChooser->setCppChecked(useCppDebugger());
|
|
||||||
debuggerLanguageChooser->setQmlChecked(useQmlDebugger());
|
|
||||||
debuggerLanguageChooser->setQmlDebugServerPort(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)));
|
|
||||||
|
|
||||||
updateQtVersions();
|
|
||||||
updateEnabled();
|
|
||||||
|
|
||||||
return detailsWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectExplorer::OutputFormatter *QmlProjectRunConfiguration::createOutputFormatter() const
|
ProjectExplorer::OutputFormatter *QmlProjectRunConfiguration::createOutputFormatter() const
|
||||||
@@ -282,38 +198,6 @@ QString QmlProjectRunConfiguration::mainScript() const
|
|||||||
return m_mainScriptFilename;
|
return m_mainScriptFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::setMainScript(const QString &scriptFile)
|
void QmlProjectRunConfiguration::setMainScript(const QString &scriptFile)
|
||||||
{
|
{
|
||||||
m_scriptFile = scriptFile;
|
m_scriptFile = scriptFile;
|
||||||
@@ -331,37 +215,6 @@ void QmlProjectRunConfiguration::setMainScript(const QString &scriptFile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::onQtVersionSelectionChanged()
|
|
||||||
{
|
|
||||||
QVariant data = m_qtVersionComboBox.data()->itemData(m_qtVersionComboBox.data()->currentIndex());
|
|
||||||
QTC_ASSERT(data.isValid() && data.canConvert(QVariant::Int), return)
|
|
||||||
setQtVersionId(data.toInt());
|
|
||||||
updateEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::onViewerArgsChanged()
|
|
||||||
{
|
|
||||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender()))
|
|
||||||
m_qmlViewerArgs = lineEdit->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::useCppDebuggerToggled(bool toggled)
|
|
||||||
{
|
|
||||||
setUseCppDebugger(toggled);
|
|
||||||
updateEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::useQmlDebuggerToggled(bool toggled)
|
|
||||||
{
|
|
||||||
setUseQmlDebugger(toggled);
|
|
||||||
updateEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::qmlDebugServerPortChanged(uint port)
|
|
||||||
{
|
|
||||||
setQmlDebugServerPort(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap QmlProjectRunConfiguration::toMap() const
|
QVariantMap QmlProjectRunConfiguration::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
||||||
@@ -451,37 +304,6 @@ void QmlProjectRunConfiguration::updateQtVersions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateEnabled();
|
updateEnabled();
|
||||||
|
|
||||||
if (!m_qtVersionComboBox)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//
|
|
||||||
// update combobox
|
|
||||||
//
|
|
||||||
m_qtVersionComboBox.data()->clear();
|
|
||||||
|
|
||||||
foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) {
|
|
||||||
if (isValidVersion(version)) {
|
|
||||||
m_qtVersionComboBox.data()->addItem(version->displayName(), version->uniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_qtVersionId != -1) {
|
|
||||||
int index = m_qtVersionComboBox.data()->findData(m_qtVersionId);
|
|
||||||
QTC_ASSERT(index >= 0, return);
|
|
||||||
m_qtVersionComboBox.data()->setCurrentIndex(index);
|
|
||||||
} else {
|
|
||||||
m_qtVersionComboBox.data()->addItem(tr("Invalid Qt version"), -1);
|
|
||||||
m_qtVersionComboBox.data()->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::manageQtVersions()
|
|
||||||
{
|
|
||||||
ICore *core = ICore::instance();
|
|
||||||
core->showOptionsDialog(Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY,
|
|
||||||
Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *version)
|
bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *version)
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ namespace QmlProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
class QmlProjectTarget;
|
class QmlProjectTarget;
|
||||||
class QmlProjectRunConfigurationFactory;
|
class QmlProjectRunConfigurationFactory;
|
||||||
|
class QmlProjectRunConfigurationWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
|
class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class Internal::QmlProjectRunConfigurationFactory;
|
friend class Internal::QmlProjectRunConfigurationFactory;
|
||||||
|
friend class Internal::QmlProjectRunConfigurationWidget;
|
||||||
|
|
||||||
// used in qmldumptool.cpp
|
// used in qmldumptool.cpp
|
||||||
Q_PROPERTY(int qtVersionId READ qtVersionId)
|
Q_PROPERTY(int qtVersionId READ qtVersionId)
|
||||||
@@ -67,8 +69,6 @@ public:
|
|||||||
|
|
||||||
Internal::QmlProjectTarget *qmlTarget() const;
|
Internal::QmlProjectTarget *qmlTarget() const;
|
||||||
|
|
||||||
bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
|
|
||||||
|
|
||||||
QString viewerPath() const;
|
QString viewerPath() const;
|
||||||
QString observerPath() const;
|
QString observerPath() const;
|
||||||
QString viewerArguments() const;
|
QString viewerArguments() const;
|
||||||
@@ -76,30 +76,21 @@ public:
|
|||||||
int qtVersionId() const;
|
int qtVersionId() const;
|
||||||
Qt4ProjectManager::QtVersion *qtVersion() const;
|
Qt4ProjectManager::QtVersion *qtVersion() const;
|
||||||
|
|
||||||
|
QString mainScript() const;
|
||||||
|
void setMainScript(const QString &scriptFile);
|
||||||
|
|
||||||
// RunConfiguration
|
// RunConfiguration
|
||||||
|
bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
|
||||||
virtual QWidget *createConfigurationWidget();
|
virtual QWidget *createConfigurationWidget();
|
||||||
|
|
||||||
ProjectExplorer::OutputFormatter *createOutputFormatter() const;
|
ProjectExplorer::OutputFormatter *createOutputFormatter() const;
|
||||||
|
|
||||||
QVariantMap toMap() const;
|
QVariantMap toMap() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeCurrentFile(Core::IEditor*);
|
void changeCurrentFile(Core::IEditor*);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
QString mainScript() const;
|
|
||||||
void setMainScript(const QString &scriptFile);
|
|
||||||
void updateFileComboBox();
|
|
||||||
|
|
||||||
void updateEnabled();
|
void updateEnabled();
|
||||||
|
|
||||||
void onQtVersionSelectionChanged();
|
|
||||||
void onViewerArgsChanged();
|
|
||||||
void useCppDebuggerToggled(bool toggled);
|
|
||||||
void useQmlDebuggerToggled(bool toggled);
|
|
||||||
void qmlDebugServerPortChanged(uint port);
|
|
||||||
void updateQtVersions();
|
void updateQtVersions();
|
||||||
void manageQtVersions();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent,
|
QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent,
|
||||||
@@ -121,13 +112,8 @@ private:
|
|||||||
QString m_scriptFile;
|
QString m_scriptFile;
|
||||||
QString m_qmlViewerArgs;
|
QString m_qmlViewerArgs;
|
||||||
|
|
||||||
QStringListModel *m_fileListModel;
|
|
||||||
// weakpointer is used to make sure we don't try to manipulate
|
|
||||||
// widget which was deleted already, as can be the case here.
|
|
||||||
QWeakPointer<QComboBox> m_qtVersionComboBox;
|
|
||||||
QWeakPointer<QComboBox> m_fileListCombo;
|
|
||||||
|
|
||||||
Internal::QmlProjectTarget *m_projectTarget;
|
Internal::QmlProjectTarget *m_projectTarget;
|
||||||
|
QWeakPointer<Internal::QmlProjectRunConfigurationWidget> m_configurationWidget;
|
||||||
|
|
||||||
bool m_usingCurrentFile;
|
bool m_usingCurrentFile;
|
||||||
bool m_isEnabled;
|
bool m_isEnabled;
|
||||||
|
|||||||
@@ -0,0 +1,233 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "qmlprojectrunconfigurationwidget.h"
|
||||||
|
#include "qmlprojectrunconfiguration.h"
|
||||||
|
#include "qmlprojecttarget.h"
|
||||||
|
#include "qmlproject.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
#include <utils/debuggerlanguagechooser.h>
|
||||||
|
#include <utils/detailswidget.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
||||||
|
#include <qt4projectmanager/qtversionmanager.h>
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QStringListModel>
|
||||||
|
|
||||||
|
using Core::ICore;
|
||||||
|
using Utils::DebuggerLanguageChooser;
|
||||||
|
using Qt4ProjectManager::QtVersionManager;
|
||||||
|
|
||||||
|
namespace QmlProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc) :
|
||||||
|
m_runConfiguration(rc),
|
||||||
|
m_qtVersionComboBox(0),
|
||||||
|
m_fileListCombo(0),
|
||||||
|
m_fileListModel(new QStringListModel(this))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
updateFileComboBox();
|
||||||
|
|
||||||
|
connect(m_fileListCombo, SIGNAL(activated(QString)), this, SLOT(setMainScript(QString)));
|
||||||
|
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;
|
||||||
|
pushButton->setText(tr("Manage Qt versions"));
|
||||||
|
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);
|
||||||
|
|
||||||
|
QWidget *debuggerLabelWidget = new QWidget;
|
||||||
|
QVBoxLayout *debuggerLabelLayout = new QVBoxLayout(debuggerLabelWidget);
|
||||||
|
debuggerLabelLayout->setMargin(0);
|
||||||
|
debuggerLabelLayout->setSpacing(0);
|
||||||
|
debuggerLabelWidget->setLayout(debuggerLabelLayout);
|
||||||
|
QLabel *debuggerLabel = new QLabel(tr("Debugger:"));
|
||||||
|
debuggerLabelLayout->addWidget(debuggerLabel);
|
||||||
|
debuggerLabelLayout->addStretch(10);
|
||||||
|
|
||||||
|
DebuggerLanguageChooser *debuggerLanguageChooser = new DebuggerLanguageChooser(formWidget);
|
||||||
|
|
||||||
|
form->addRow(tr("Main QML file:"), m_fileListCombo);
|
||||||
|
form->addRow(debuggerLabelWidget, debuggerLanguageChooser);
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
||||||
|
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)),
|
||||||
|
this, SLOT(updateQtVersionComboBox()));
|
||||||
|
|
||||||
|
updateQtVersionComboBox();
|
||||||
|
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
layout->addWidget(detailsWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
QStringList files;
|
||||||
|
|
||||||
|
files.append(CURRENT_FILE);
|
||||||
|
int currentIndex = -1;
|
||||||
|
QStringList sortedFiles = project->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_runConfiguration->m_scriptFile)
|
||||||
|
currentIndex = files.size();
|
||||||
|
|
||||||
|
files.append(fileName);
|
||||||
|
}
|
||||||
|
m_fileListModel->setStringList(files);
|
||||||
|
|
||||||
|
if (currentIndex != -1)
|
||||||
|
m_fileListCombo->setCurrentIndex(currentIndex);
|
||||||
|
else
|
||||||
|
m_fileListCombo->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProjectRunConfigurationWidget::setMainScript(const QString &file)
|
||||||
|
{
|
||||||
|
m_runConfiguration->setMainScript(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
m_runConfiguration->updateEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProjectRunConfigurationWidget::useQmlDebuggerToggled(bool toggled)
|
||||||
|
{
|
||||||
|
m_runConfiguration->setUseQmlDebugger(toggled);
|
||||||
|
m_runConfiguration->updateEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProjectRunConfigurationWidget::qmlDebugServerPortChanged(uint port)
|
||||||
|
{
|
||||||
|
m_runConfiguration->setQmlDebugServerPort(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProjectRunConfigurationWidget::manageQtVersions()
|
||||||
|
{
|
||||||
|
ICore *core = ICore::instance();
|
||||||
|
core->showOptionsDialog(Qt4ProjectManager::Constants::QT_SETTINGS_CATEGORY,
|
||||||
|
Qt4ProjectManager::Constants::QTVERSION_SETTINGS_PAGE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProjectRunConfigurationWidget::updateQtVersionComboBox()
|
||||||
|
{
|
||||||
|
m_qtVersionComboBox->clear();
|
||||||
|
|
||||||
|
QtVersionManager *qtVersions = QtVersionManager::instance();
|
||||||
|
foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace QmlProjectManager
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QMLPROJECTRUNCONFIGURATIONWIDGET_H
|
||||||
|
#define QMLPROJECTRUNCONFIGURATIONWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QComboBox);
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QStringListModel);
|
||||||
|
|
||||||
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
|
class QmlProjectRunConfiguration;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
const char * const CURRENT_FILE = QT_TRANSLATE_NOOP("QmlManager", "<Current File>");
|
||||||
|
|
||||||
|
class QmlProjectRunConfigurationWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateQtVersionComboBox();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateFileComboBox();
|
||||||
|
|
||||||
|
void setMainScript(const QString &file);
|
||||||
|
void onQtVersionSelectionChanged();
|
||||||
|
void onViewerArgsChanged();
|
||||||
|
void useCppDebuggerToggled(bool toggled);
|
||||||
|
void useQmlDebuggerToggled(bool toggled);
|
||||||
|
void qmlDebugServerPortChanged(uint port);
|
||||||
|
|
||||||
|
void manageQtVersions();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QmlProjectRunConfiguration *m_runConfiguration;
|
||||||
|
|
||||||
|
QComboBox *m_qtVersionComboBox;
|
||||||
|
QComboBox *m_fileListCombo;
|
||||||
|
QStringListModel *m_fileListModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace QmlProjectManager
|
||||||
|
|
||||||
|
#endif // QMLPROJECTRUNCONFIGURATIONWIDGET_H
|
||||||
Reference in New Issue
Block a user