Merge remote-tracking branch 'origin/3.0'

Conflicts:
	qtcreator.pri
	qtcreator.qbs

Change-Id: I91b9ceba836d01086e9ccdb4499436d17195b729
This commit is contained in:
Eike Ziller
2013-11-06 14:02:08 +01:00
358 changed files with 3130 additions and 107477 deletions

View File

@@ -50,16 +50,11 @@ static QStringList binaryFiles()
return result;
}
QString QmlApp::templateRootDirectory()
static QString templateRootDirectory()
{
return Core::ICore::resourcePath() + QLatin1String("/templates/qml/");
}
TemplateInfo::TemplateInfo()
: priority(5)
{
}
QmlApp::QmlApp(QObject *parent)
: QObject(parent)
{
@@ -100,18 +95,13 @@ QString QmlApp::creatorFileName() const
return m_creatorFileName;
}
const TemplateInfo &QmlApp::templateInfo() const
{
return m_templateInfo;
}
QString QmlApp::templateDirectory() const
{
const QDir dir(templateRootDirectory() + m_templateInfo.templateName);
return QDir::cleanPath(dir.absolutePath());
}
QStringList QmlApp::templateNames()
static QStringList templateNames()
{
QStringList templateNameList;
const QDir templateRoot(templateRootDirectory());
@@ -177,7 +167,7 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
if (reader.name() == tag_template) {
info->openFile = reader.attributes().value(attribute_openEditor).toString();
if (reader.attributes().hasAttribute(attribute_priority))
info->priority = reader.attributes().value(attribute_priority).toString().toInt();
info->priority = reader.attributes().value(attribute_priority).toString();
if (reader.attributes().hasAttribute(attribute_id))
info->wizardId = reader.attributes().value(attribute_id).toString();
@@ -201,24 +191,39 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
return true;
}
class TemplateInfoList
{
public:
TemplateInfoList()
{
QMultiMap<QString, TemplateInfo> multiMap;
foreach (const QString &templateName, templateNames()) {
const QString templatePath = templateRootDirectory() + templateName;
QFile xmlFile(templatePath + QLatin1String("/template.xml"));
if (!xmlFile.open(QIODevice::ReadOnly)) {
qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath()));
continue;
}
TemplateInfo info;
info.templateName = templateName;
info.templatePath = templatePath;
QXmlStreamReader reader(&xmlFile);
if (parseTemplateXml(reader, &info))
multiMap.insert(info.priority, info);
}
m_templateInfoList = multiMap.values();
}
QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; }
private:
QList<TemplateInfo> m_templateInfoList;
};
Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList)
QList<TemplateInfo> QmlApp::templateInfos()
{
QList<TemplateInfo> result;
foreach (const QString &templateName, templateNames()) {
const QString templatePath = templateRootDirectory() + templateName;
QFile xmlFile(templatePath + QLatin1String("/template.xml"));
if (!xmlFile.open(QIODevice::ReadOnly)) {
qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath()));
continue;
}
TemplateInfo info;
info.templateName = templateName;
info.templatePath = templatePath;
QXmlStreamReader reader(&xmlFile);
if (parseTemplateXml(reader, &info))
result.append(info);
}
return result;
return templateInfoList()->templateInfoList();
}
static QFileInfoList allFilesRecursive(const QString &path)
@@ -361,7 +366,6 @@ QString QmlApp::renameQmlFile(const QString &fileName) {
Core::GeneratedFiles QmlApp::generateFiles(QString *errorMessage)
{
Core::GeneratedFiles files;
QTC_ASSERT(errorMessage, return files);

View File

@@ -42,8 +42,6 @@ namespace Internal {
class TemplateInfo
{
public:
TemplateInfo();
QString templateName;
QString templatePath;
QString displayName;
@@ -51,8 +49,7 @@ public:
QString openFile;
QString wizardId;
QString featuresRequired;
int priority;
QString priority;
};
class QmlApp : public QObject
@@ -66,11 +63,8 @@ public:
QString mainQmlFileName() const;
QString projectDirectory() const;
QString projectName() const;
const TemplateInfo &templateInfo() const;
QString templateDirectory() const;
static QString templateRootDirectory();
static QStringList templateNames();
static QList<TemplateInfo> templateInfos();
Core::GeneratedFiles generateFiles(QString *errorMessage);

View File

@@ -41,6 +41,7 @@
#include "qmlprojectmanager.h"
#include "qmlproject.h"
#include "qmlapplicationwizardpages.h"
#include <QIcon>
@@ -52,20 +53,23 @@ using namespace QmakeProjectManager;
namespace QmlProjectManager {
namespace Internal {
QmlApplicationWizardDialog::QmlApplicationWizardDialog(QmlApp *qmlApp, QWidget *parent, const WizardDialogParameters &parameters)
: BaseProjectWizardDialog(parent, parameters),
m_qmlApp(qmlApp)
QmlApplicationWizardDialog::QmlApplicationWizardDialog(QWidget *parent, const WizardDialogParameters &parameters)
: BaseProjectWizardDialog(parent, parameters)
{
setWindowTitle(tr("New Qt Quick UI Project"));
setIntroDescription(tr("This wizard generates a Qt Quick UI project."));
m_componentSetPage = new QmlComponentSetPage;
const int pageId = addPage(m_componentSetPage);
wizardProgress()->item(pageId)->setTitle(tr("Component Set"));
}
QmlApp *QmlApplicationWizardDialog::qmlApp() const
TemplateInfo QmlApplicationWizardDialog::templateInfo() const
{
return m_qmlApp;
return m_componentSetPage->templateInfo();
}
QmlApplicationWizard::QmlApplicationWizard(const TemplateInfo &templateInfo)
QmlApplicationWizard::QmlApplicationWizard()
: m_qmlApp(new QmlApp(this))
{
setWizardKind(ProjectWizard);
@@ -74,47 +78,14 @@ QmlApplicationWizard::QmlApplicationWizard(const TemplateInfo &templateInfo)
setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
setDisplayCategory(
QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
setDisplayName(tr("Qt Quick Application"));
setDescription(tr("Creates a Qt Quick application project."));
m_qmlApp->setTemplateInfo(templateInfo);
}
void QmlApplicationWizard::createInstances(ExtensionSystem::IPlugin *plugin)
{
foreach (const TemplateInfo &templateInfo, QmlApp::templateInfos()) {
QmlApplicationWizard *wizard = new QmlApplicationWizard(templateInfo);
wizard->setDisplayName(templateInfo.displayName);
wizard->setDescription(templateInfo.description);
const QString imagePath = templateInfo.templatePath + QLatin1String("/template.png");
if (QFileInfo(imagePath).exists())
wizard->setDescriptionImage(imagePath);
wizard->setCategory(
QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
wizard->setDisplayCategory(
QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
wizard->setWizardKind(IWizard::ProjectWizard);
wizard->setId(templateInfo.wizardId);
QStringList stringList =
templateInfo.featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);
FeatureSet features;
foreach (const QString &string, stringList) {
Feature feature(Id::fromString(string.trimmed()));
features |= feature;
}
wizard->setRequiredFeatures(features);
wizard->setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
plugin->addAutoReleasedObject(wizard);
}
setDisplayName(tr("Qt Quick UI"));
setDescription(tr("Creates a Qt Quick UI project."));
}
QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
const WizardDialogParameters &wizardDialogParameters) const
{
QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(m_qmlApp,
parent, wizardDialogParameters);
QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(parent, wizardDialogParameters);
connect(wizardDialog, SIGNAL(projectParametersChanged(QString,QString)), m_qmlApp,
SLOT(setProjectNameAndBaseDirectory(QString,QString)));
@@ -129,9 +100,11 @@ QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
return wizardDialog;
}
GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard * /*wizard*/,
QString *errorMessage) const
GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
const QmlApplicationWizardDialog *wizard = qobject_cast<const QmlApplicationWizardDialog*>(w);
m_qmlApp->setTemplateInfo(wizard->templateInfo());
return m_qmlApp->generateFiles(errorMessage);
}

View File

@@ -42,18 +42,19 @@ namespace Internal {
class QmlApp;
class TemplateInfo;
class QmlComponentSetPage;
class QmlApplicationWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
Q_OBJECT
public:
QmlApplicationWizardDialog(QmlApp *qmlApp, QWidget *parent,
QmlApplicationWizardDialog(QWidget *parent,
const Core::WizardDialogParameters &parameters);
QmlApp *qmlApp() const;
TemplateInfo templateInfo() const;
private:
QmlApp *m_qmlApp;
QmlComponentSetPage *m_componentSetPage;
};
@@ -62,7 +63,7 @@ class QmlApplicationWizard : public Core::BaseFileWizard
Q_OBJECT
public:
explicit QmlApplicationWizard(const TemplateInfo &templateInfo);
explicit QmlApplicationWizard();
static void createInstances(ExtensionSystem::IPlugin *plugin);
@@ -74,7 +75,6 @@ private:
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
private:
// mutable QString m_id;
QmlApp *m_qmlApp;
};

View File

@@ -0,0 +1,96 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlapplicationwizardpages.h"
#include "qmlapp.h"
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
namespace QmlProjectManager {
namespace Internal {
class QmlComponentSetPagePrivate
{
public:
QComboBox *m_versionComboBox;
QLabel *m_detailedDescriptionLabel;
};
QmlComponentSetPage::QmlComponentSetPage(QWidget *parent)
: QWizardPage(parent)
, d(new QmlComponentSetPagePrivate)
{
setTitle(tr("Select Qt Quick Component Set"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QHBoxLayout *l = new QHBoxLayout();
QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
d->m_versionComboBox = new QComboBox(this);
foreach (const TemplateInfo &templateInfo, QmlApp::templateInfos())
d->m_versionComboBox->addItem(templateInfo.displayName);
l->addWidget(label);
l->addWidget(d->m_versionComboBox);
d->m_detailedDescriptionLabel = new QLabel(this);
d->m_detailedDescriptionLabel->setWordWrap(true);
d->m_detailedDescriptionLabel->setTextFormat(Qt::RichText);
connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(updateDescription(int)));
updateDescription(d->m_versionComboBox->currentIndex());
mainLayout->addLayout(l);
mainLayout->addWidget(d->m_detailedDescriptionLabel);
}
QmlComponentSetPage::~QmlComponentSetPage()
{
delete d;
}
TemplateInfo QmlComponentSetPage::templateInfo() const
{
if (QmlApp::templateInfos().isEmpty())
return TemplateInfo();
return QmlApp::templateInfos().at(d->m_versionComboBox->currentIndex());
}
void QmlComponentSetPage::updateDescription(int index)
{
if (QmlApp::templateInfos().isEmpty())
return;
const TemplateInfo templateInfo = QmlApp::templateInfos().at(index);
d->m_detailedDescriptionLabel->setText(templateInfo.description);
}
} // namespace Internal
} // namespace QmlProjectManager

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLAPPLICATIONWIZARDPAGES_H
#define QMLAPPLICATIONWIZARDPAGES_H
#include <QWizardPage>
namespace QmlProjectManager {
namespace Internal {
class TemplateInfo;
class QmlComponentSetPage : public QWizardPage
{
Q_OBJECT
public:
explicit QmlComponentSetPage(QWidget *parent = 0);
~QmlComponentSetPage();
TemplateInfo templateInfo() const;
private slots:
void updateDescription(int index);
private:
class QmlComponentSetPagePrivate *d;
};
} // namespace Internal
} // namespace QmlProjectManager
#endif // QMLAPPLICATIONWIZARDPAGES_H

View File

@@ -108,7 +108,8 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
: m_manager(manager),
m_fileName(fileName),
m_defaultImport(UnknownImport),
m_modelManager(QmlJS::ModelManagerInterface::instance())
m_modelManager(QmlJS::ModelManagerInterface::instance()),
m_activeTarget(0)
{
setId("QmlProjectManager.QmlProject");
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
@@ -143,7 +144,19 @@ void QmlProject::addedTarget(ProjectExplorer::Target *target)
addedRunConfiguration(rc);
}
void QmlProject::onActiveTargetChanged(ProjectExplorer::Target * /*target*/)
void QmlProject::onActiveTargetChanged(ProjectExplorer::Target *target)
{
if (m_activeTarget)
disconnect(m_activeTarget, SIGNAL(kitChanged()), this, SLOT(onKitChanged()));
m_activeTarget = target;
if (m_activeTarget)
connect(target, SIGNAL(kitChanged()), this, SLOT(onKitChanged()));
// make sure e.g. the default qml imports are adapted
refresh(Configuration);
}
void QmlProject::onKitChanged()
{
// make sure e.g. the default qml imports are adapted
refresh(Configuration);
@@ -398,6 +411,11 @@ bool QmlProject::fromMap(const QVariantMap &map)
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(onActiveTargetChanged(ProjectExplorer::Target*)));
// make sure we get updates on kit changes
m_activeTarget = activeTarget();
if (m_activeTarget)
connect(m_activeTarget, SIGNAL(kitChanged()), this, SLOT(onKitChanged()));
return true;
}

View File

@@ -97,6 +97,7 @@ private slots:
void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed);
void addedTarget(ProjectExplorer::Target *target);
void onActiveTargetChanged(ProjectExplorer::Target *target);
void onKitChanged();
void addedRunConfiguration(ProjectExplorer::RunConfiguration *);
protected:
@@ -113,6 +114,7 @@ private:
QString m_projectName;
QmlImport m_defaultImport;
QmlJS::ModelManagerInterface *m_modelManager;
ProjectExplorer::Target *m_activeTarget;
// plain format
QStringList m_files;

View File

@@ -17,7 +17,8 @@ HEADERS += qmlproject.h \
qmlprojectmanagerconstants.h \
qmlprojectrunconfigurationwidget.h \
qmlapp.h \
qmlapplicationwizard.h
qmlapplicationwizard.h \
qmlapplicationwizardpages.h
SOURCES += qmlproject.cpp \
qmlprojectenvironmentaspect.cpp \
@@ -29,6 +30,7 @@ SOURCES += qmlproject.cpp \
qmlprojectrunconfigurationfactory.cpp \
qmlprojectrunconfigurationwidget.cpp \
qmlapp.cpp \
qmlapplicationwizard.cpp
qmlapplicationwizard.cpp \
qmlapplicationwizardpages.cpp
RESOURCES += qmlproject.qrc

View File

@@ -21,6 +21,7 @@ QtcPlugin {
files: [
"qmlapp.cpp", "qmlapp.h",
"qmlapplicationwizard.cpp", "qmlapplicationwizard.h",
"qmlapplicationwizardpages.cpp", "qmlapplicationwizardpages.h",
"qmlproject.cpp", "qmlproject.h",
"qmlproject.qrc",
"qmlprojectconstants.h",

View File

@@ -66,8 +66,7 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
addAutoReleasedObject(new Internal::Manager);
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
Internal::QmlApplicationWizard::createInstances(this);
addAutoReleasedObject(new Internal::QmlApplicationWizard);
FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");
return true;
@@ -77,29 +76,6 @@ void QmlProjectPlugin::extensionsInitialized()
{
}
void QmlProjectPlugin::showQmlObserverToolWarning()
{
QMessageBox dialog(QApplication::activeWindow());
QPushButton *qtPref = dialog.addButton(tr("Open Qt Versions"),
QMessageBox::ActionRole);
dialog.addButton(QMessageBox::Cancel);
dialog.setDefaultButton(qtPref);
dialog.setWindowTitle(tr("QML Observer Missing"));
dialog.setText(tr("QML Observer could not be found for this Qt version."));
dialog.setInformativeText(tr(
"QML Observer is used to offer debugging features for "
"Qt Quick UI projects in the Qt 4.7 series.\n\n"
"To compile QML Observer, go to the Qt Versions page, "
"select the current Qt version, "
"and click Build in the Helpers section."));
dialog.exec();
if (dialog.clickedButton() == qtPref) {
Core::ICore::showOptionsDialog(
ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
}
}
} // namespace QmlProjectManager
Q_EXPORT_PLUGIN(QmlProjectManager::QmlProjectPlugin)

View File

@@ -47,8 +47,6 @@ public:
virtual bool initialize(const QStringList &arguments, QString *errorString);
virtual void extensionsInitialized();
static void showQmlObserverToolWarning();
};
} // namespace QmlProject

View File

@@ -60,6 +60,8 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(ProjectExplorer::Target *
m_scriptFile(QLatin1String(M_CURRENT_FILE)),
m_isEnabled(false)
{
addExtraAspect(new QmlProjectEnvironmentAspect(this));
ctor();
}
@@ -90,6 +92,8 @@ void QmlProjectRunConfiguration::ctor()
// reset default settings in constructor
connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(changeCurrentFile(Core::IEditor*)));
connect(EditorManager::instance(), SIGNAL(currentDocumentStateChanged()),
this, SLOT(changeCurrentFile()));
connect(target(), SIGNAL(kitChanged()),
this, SLOT(updateEnabled()));
@@ -98,8 +102,6 @@ void QmlProjectRunConfiguration::ctor()
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
else
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
addExtraAspect(new QmlProjectEnvironmentAspect(this));
}
QString QmlProjectRunConfiguration::executable() const
@@ -110,10 +112,7 @@ QString QmlProjectRunConfiguration::executable() const
if (id() == Constants::QML_SCENE_RC_ID)
return version->qmlsceneCommand();
if (!version->needsQmlDebuggingLibrary())
return version->qmlviewerCommand();
return version->qmlObserverTool();
return version->qmlviewerCommand();
}
ProjectExplorer::LocalApplicationRunConfiguration::RunMode QmlProjectRunConfiguration::runMode() const
@@ -266,6 +265,9 @@ bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
void QmlProjectRunConfiguration::changeCurrentFile(IEditor *editor)
{
if (!editor)
editor = EditorManager::currentEditor();
if (editor)
m_currentFileFilename = editor->document()->filePath();
updateEnabled();

View File

@@ -91,7 +91,7 @@ public:
ProjectExplorer::Abi abi() const;
private slots:
void changeCurrentFile(Core::IEditor*);
void changeCurrentFile(Core::IEditor* = 0);
void updateEnabled();
protected: