diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index c22b05817a7..e18ff27e6db 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -66,6 +66,7 @@ const char QMAKE_BS_ID[] = "QtProjectManager.QMakeBuildStep"; const char QMAKE_ARGUMENTS_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeArguments"; const char QMAKE_FORCED_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeForced"; +const char QMAKE_USE_qtQuickCompiler[] = "QtProjectManager.QMakeBuildStep.UseqtQuickCompiler"; const char QMAKE_QMLDEBUGLIBAUTO_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto"; const char QMAKE_QMLDEBUGLIB_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"; } @@ -74,7 +75,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Core::Id(QMAKE_BS_ID)), m_forced(false), m_needToRunQMake(false), - m_linkQmlDebuggingLibrary(DebugLink) + m_linkQmlDebuggingLibrary(DebugLink), + m_useQtQuickCompiler(false) { ctor(); } @@ -82,7 +84,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl) : QMakeStep::QMakeStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id), m_forced(false), - m_linkQmlDebuggingLibrary(DebugLink) + m_linkQmlDebuggingLibrary(DebugLink), + m_useQtQuickCompiler(false) { ctor(); } @@ -91,7 +94,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl, QMakeStep *bs) : AbstractProcessStep(bsl, bs), m_forced(bs->m_forced), m_userArgs(bs->m_userArgs), - m_linkQmlDebuggingLibrary(bs->m_linkQmlDebuggingLibrary) + m_linkQmlDebuggingLibrary(bs->m_linkQmlDebuggingLibrary), + m_useQtQuickCompiler(bs->m_useQtQuickCompiler) { ctor(); } @@ -180,6 +184,8 @@ QStringList QMakeStep::deducedArguments() arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG); } + if (useQtQuickCompiler() && version) + arguments << QLatin1String("CONFIG+=qtquickcompiler"); return arguments; } @@ -369,6 +375,27 @@ void QMakeStep::setLinkQmlDebuggingLibrary(bool enable) qmakeBuildConfiguration()->emitProFileEvaluateNeeded(); } +bool QMakeStep::useQtQuickCompiler() const +{ + const Core::Context languages = project()->projectLanguages(); + if (!languages.contains(ProjectExplorer::Constants::LANG_QMLJS)) + return false; + return m_useQtQuickCompiler; +} + +void QMakeStep::setUseQtQuickCompiler(bool enable) +{ + if (enable == m_useQtQuickCompiler) + return; + + m_useQtQuickCompiler = enable; + + emit useQtQuickCompilerChanged(); + + qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged(); + qmakeBuildConfiguration()->emitProFileEvaluateNeeded(); +} + QStringList QMakeStep::parserArguments() { QStringList result; @@ -403,6 +430,7 @@ QVariantMap QMakeStep::toMap() const map.insert(QLatin1String(QMAKE_QMLDEBUGLIBAUTO_KEY), m_linkQmlDebuggingLibrary == DebugLink); map.insert(QLatin1String(QMAKE_QMLDEBUGLIB_KEY), m_linkQmlDebuggingLibrary == DoLink); map.insert(QLatin1String(QMAKE_FORCED_KEY), m_forced); + map.insert(QLatin1String(QMAKE_USE_qtQuickCompiler), m_useQtQuickCompiler); return map; } @@ -410,6 +438,7 @@ bool QMakeStep::fromMap(const QVariantMap &map) { m_userArgs = map.value(QLatin1String(QMAKE_ARGUMENTS_KEY)).toString(); m_forced = map.value(QLatin1String(QMAKE_FORCED_KEY), false).toBool(); + m_useQtQuickCompiler = map.value(QLatin1String(QMAKE_USE_qtQuickCompiler), false).toBool(); if (map.value(QLatin1String(QMAKE_QMLDEBUGLIBAUTO_KEY), false).toBool()) { m_linkQmlDebuggingLibrary = DebugLink; } else { @@ -434,12 +463,14 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) m_ui->qmakeAdditonalArgumentsLineEdit->setText(m_step->userArguments()); m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary()); + m_ui->qtQuickCompilerCheckBox->setChecked(m_step->useQtQuickCompiler()); qmakeBuildConfigChanged(); updateSummaryLabel(); updateEffectiveQMakeCall(); updateQmlDebuggingOption(); + updateQtQuickCompilerOption(); connect(m_ui->qmakeAdditonalArgumentsLineEdit, SIGNAL(textEdited(QString)), this, SLOT(qmakeArgumentsLineEdited())); @@ -447,10 +478,14 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) this, SLOT(buildConfigurationSelected())); connect(m_ui->qmlDebuggingLibraryCheckBox, SIGNAL(toggled(bool)), this, SLOT(linkQmlDebuggingLibraryChecked(bool))); + connect(m_ui->qtQuickCompilerCheckBox, &QAbstractButton::toggled, + this, &QMakeStepConfigWidget::useQtQuickCompilerChecked); connect(step, SIGNAL(userArgumentsChanged()), this, SLOT(userArgumentsChanged())); connect(step, SIGNAL(linkQmlDebuggingLibraryChanged()), this, SLOT(linkQmlDebuggingLibraryChanged())); + connect(step, &QMakeStep::useQtQuickCompilerChanged, + this, &QMakeStepConfigWidget::useQtQuickCompilerChanged); connect(step->qmakeBuildConfiguration(), SIGNAL(qmakeBuildConfigurationChanged()), this, SLOT(qmakeBuildConfigChanged())); connect(step->target(), SIGNAL(kitChanged()), this, SLOT(qtVersionChanged())); @@ -516,6 +551,17 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged() updateQmlDebuggingOption(); } +void QMakeStepConfigWidget::useQtQuickCompilerChanged() +{ + if (m_ignoreChange) + return; +// m_ui->qtQuickCompilerCheckBox->setChecked(m_step->useQtQuickCompiler()); + + updateSummaryLabel(); + updateEffectiveQMakeCall(); + updateQtQuickCompilerOption(); +} + void QMakeStepConfigWidget::qmakeArgumentsLineEdited() { m_ignoreChange = true; @@ -557,7 +603,11 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) updateSummaryLabel(); updateEffectiveQMakeCall(); updateQmlDebuggingOption(); + askForRebuild(); +} +void QMakeStepConfigWidget::askForRebuild() +{ QMessageBox *question = new QMessageBox(Core::ICore::mainWindow()); question->setWindowTitle(tr("QML Debugging")); question->setText(tr("The option will only take effect if the project is recompiled. Do you want to recompile now?")); @@ -567,6 +617,21 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) question->show(); } +void QMakeStepConfigWidget::useQtQuickCompilerChecked(bool checked) +{ + if (m_ignoreChange) + return; + + m_ignoreChange = true; + m_step->setUseQtQuickCompiler(checked); + m_ignoreChange = false; + + updateSummaryLabel(); + updateEffectiveQMakeCall(); + updateQtQuickCompilerOption(); + askForRebuild(); +} + void QMakeStepConfigWidget::updateSummaryLabel() { QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(m_step->target()->kit()); @@ -596,6 +661,17 @@ void QMakeStepConfigWidget::updateQmlDebuggingOption() m_ui->qmlDebuggingWarningIcon->setVisible(!warningText.isEmpty()); } +void QMakeStepConfigWidget::updateQtQuickCompilerOption() +{ + QString warningText; + bool supported = QtSupport::BaseQtVersion::isQtQuickCompilerSupported(m_step->target()->kit(), + &warningText); + m_ui->qtQuickCompilerCheckBox->setEnabled(supported); + m_ui->qtQuickCompilerLabel->setText(tr("Enable Qt Quick Compiler:")); + m_ui->qtQuickCompilerWarningText->setText(warningText); + m_ui->qtQuickCompilerWarningIcon->setVisible(!warningText.isEmpty()); +} + void QMakeStepConfigWidget::updateEffectiveQMakeCall() { QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(m_step->target()->kit()); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.h b/src/plugins/qmakeprojectmanager/qmakestep.h index 4b091eef25d..ee8bbf67edb 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.h +++ b/src/plugins/qmakeprojectmanager/qmakestep.h @@ -112,12 +112,15 @@ public: void setUserArguments(const QString &arguments); bool linkQmlDebuggingLibrary() const; void setLinkQmlDebuggingLibrary(bool enable); + bool useQtQuickCompiler() const; + void setUseQtQuickCompiler(bool enable); QVariantMap toMap() const; signals: void userArgumentsChanged(); void linkQmlDebuggingLibraryChanged(); + void useQtQuickCompilerChanged(); protected: QMakeStep(ProjectExplorer::BuildStepList *parent, QMakeStep *source); @@ -135,6 +138,7 @@ private: bool m_needToRunQMake; // set in init(), read in run() QString m_userArgs; QmlLibraryLink m_linkQmlDebuggingLibrary; + bool m_useQtQuickCompiler; bool m_scriptTemplate; }; @@ -154,11 +158,13 @@ private slots: void qmakeBuildConfigChanged(); void userArgumentsChanged(); void linkQmlDebuggingLibraryChanged(); + void useQtQuickCompilerChanged(); // slots for dealing with user changes in our UI void qmakeArgumentsLineEdited(); void buildConfigurationSelected(); void linkQmlDebuggingLibraryChecked(bool checked); + void useQtQuickCompilerChecked(bool checked); private slots: void recompileMessageBoxFinished(int button); @@ -166,7 +172,9 @@ private slots: private: void updateSummaryLabel(); void updateQmlDebuggingOption(); + void updateQtQuickCompilerOption(); void updateEffectiveQMakeCall(); + void askForRebuild(); void setSummaryText(const QString &); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.ui b/src/plugins/qmakeprojectmanager/qmakestep.ui index 0aeed59dfb2..721bc2d112a 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.ui +++ b/src/plugins/qmakeprojectmanager/qmakestep.ui @@ -154,6 +154,65 @@ + + + Use QML compiler + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + :/core/images/warning.png + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Effective qmake call: @@ -163,7 +222,7 @@ - + true @@ -183,6 +242,7 @@ + diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 93ec6158c38..ef766aab62a 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1501,6 +1501,35 @@ bool BaseQtVersion::isQmlDebuggingSupported(QString *reason) const return true; } +bool BaseQtVersion::isQtQuickCompilerSupported(Kit *k, QString *reason) +{ + QTC_ASSERT(k, return false); + BaseQtVersion *version = QtKitInformation::qtVersion(k); + if (!version) { + if (reason) + *reason = QCoreApplication::translate("BaseQtVersion", "No Qt version."); + return false; + } + return version->isQtQuickCompilerSupported(reason); +} + +bool BaseQtVersion::isQtQuickCompilerSupported(QString *reason) const +{ + if (!isValid()) { + if (reason) + *reason = QCoreApplication::translate("BaseQtVersion", "Invalid Qt version."); + return false; + } + + if (qtVersion() < QtVersionNumber(5, 3, 0)) { + if (reason) + *reason = QCoreApplication::translate("BaseQtVersion", "Requires Qt 5.3.0 or newer."); + return false; + } + + return true; +} + void BaseQtVersion::buildDebuggingHelper(Kit *k, int tools) { BaseQtVersion *version = QtKitInformation::qtVersion(k); diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index d6f3d757c21..e2016cf47ca 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -184,6 +184,8 @@ public: static bool isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason = 0); bool isQmlDebuggingSupported(QString *reason = 0) const; + static bool isQtQuickCompilerSupported(ProjectExplorer::Kit *k, QString *reason = 0); + bool isQtQuickCompilerSupported(QString *reason = 0) const; static void buildDebuggingHelper(ProjectExplorer::Kit *k, int tools); void buildDebuggingHelper(ProjectExplorer::ToolChain *tc, int tools);