QmakeProjectManager: Use ArgumentsAspect in qmake step widget

Change-Id: I7e12a571841f85f80c6439d5e7e834ff7c53305d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-10-06 14:59:53 +02:00
parent b1d3eee42d
commit 3ab54e91b1
2 changed files with 24 additions and 53 deletions

View File

@@ -41,6 +41,7 @@
#include <projectexplorer/gnumakeparser.h> #include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
@@ -57,11 +58,8 @@
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <utils/variablechooser.h> #include <utils/variablechooser.h>
#include <QComboBox>
#include <QDir> #include <QDir>
#include <QFormLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QListWidget> #include <QListWidget>
#include <QMessageBox> #include <QMessageBox>
#include <QPlainTextEdit> #include <QPlainTextEdit>
@@ -89,6 +87,10 @@ QMakeStep::QMakeStep(BuildStepList *bsl, Utils::Id id)
m_buildType->addOption(tr("Debug")); m_buildType->addOption(tr("Debug"));
m_buildType->addOption(tr("Release")); m_buildType->addOption(tr("Release"));
m_userArgs = addAspect<ArgumentsAspect>();
m_userArgs->setSettingsKey(QMAKE_ARGUMENTS_KEY);
m_userArgs->setLabelText(tr("Additional arguments:"));
auto updateSummary = [this] { auto updateSummary = [this] {
BaseQtVersion *qtVersion = QtKitAspect::qtVersion(target()->kit()); BaseQtVersion *qtVersion = QtKitAspect::qtVersion(target()->kit());
if (!qtVersion) if (!qtVersion)
@@ -133,7 +135,7 @@ QString QMakeStep::allArguments(const BaseQtVersion *v, ArgumentFlags flags) con
if (v->qtVersion() < QtVersionNumber(5, 0, 0)) if (v->qtVersion() < QtVersionNumber(5, 0, 0))
arguments << "-r"; arguments << "-r";
bool userProvidedMkspec = false; bool userProvidedMkspec = false;
for (QtcProcess::ConstArgIterator ait(m_userArgs); ait.next(); ) { for (QtcProcess::ConstArgIterator ait(userArguments()); ait.next(); ) {
if (ait.value() == "-spec") { if (ait.value() == "-spec") {
if (ait.next()) { if (ait.next()) {
userProvidedMkspec = true; userProvidedMkspec = true;
@@ -152,7 +154,7 @@ QString QMakeStep::allArguments(const BaseQtVersion *v, ArgumentFlags flags) con
QString args = QtcProcess::joinArgs(arguments); QString args = QtcProcess::joinArgs(arguments);
// User arguments // User arguments
QtcProcess::addArgs(&args, m_userArgs); QtcProcess::addArgs(&args, userArguments());
foreach (QString arg, m_extraArgs) foreach (QString arg, m_extraArgs)
QtcProcess::addArgs(&args, arg); QtcProcess::addArgs(&args, arg);
return (flags & ArgumentFlag::Expand) ? bc->macroExpander()->expand(args) : args; return (flags & ArgumentFlag::Expand) ? bc->macroExpander()->expand(args) : args;
@@ -372,14 +374,7 @@ void QMakeStep::runNextCommand()
void QMakeStep::setUserArguments(const QString &arguments) void QMakeStep::setUserArguments(const QString &arguments)
{ {
if (m_userArgs == arguments) m_userArgs->setArguments(arguments);
return;
m_userArgs = arguments;
emit userArgumentsChanged();
emit qmakeBuildConfiguration()->qmakeBuildConfigurationChanged();
qmakeBuildSystem()->scheduleUpdateAllNowOrLater();
} }
QStringList QMakeStep::extraArguments() const QStringList QMakeStep::extraArguments() const
@@ -458,14 +453,14 @@ QStringList QMakeStep::parserArguments()
return result; return result;
} }
QString QMakeStep::userArguments() QString QMakeStep::userArguments() const
{ {
return m_userArgs; return m_userArgs->arguments(macroExpander());
} }
QString QMakeStep::mkspec() const QString QMakeStep::mkspec() const
{ {
QString additionalArguments = m_userArgs; QString additionalArguments = userArguments();
QtcProcess::addArgs(&additionalArguments, m_extraArgs); QtcProcess::addArgs(&additionalArguments, m_extraArgs);
for (QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) { for (QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) {
if (ait.value() == "-spec") { if (ait.value() == "-spec") {
@@ -480,7 +475,6 @@ QString QMakeStep::mkspec() const
QVariantMap QMakeStep::toMap() const QVariantMap QMakeStep::toMap() const
{ {
QVariantMap map(AbstractProcessStep::toMap()); QVariantMap map(AbstractProcessStep::toMap());
map.insert(QMAKE_ARGUMENTS_KEY, m_userArgs);
map.insert(QMAKE_FORCED_KEY, m_forced); map.insert(QMAKE_FORCED_KEY, m_forced);
map.insert(QMAKE_SELECTED_ABIS_KEY, m_selectedAbis); map.insert(QMAKE_SELECTED_ABIS_KEY, m_selectedAbis);
return map; return map;
@@ -488,7 +482,6 @@ QVariantMap QMakeStep::toMap() const
bool QMakeStep::fromMap(const QVariantMap &map) bool QMakeStep::fromMap(const QVariantMap &map)
{ {
m_userArgs = map.value(QMAKE_ARGUMENTS_KEY).toString();
m_forced = map.value(QMAKE_FORCED_KEY, false).toBool(); m_forced = map.value(QMAKE_FORCED_KEY, false).toBool();
m_selectedAbis = map.value(QMAKE_SELECTED_ABIS_KEY).toStringList(); m_selectedAbis = map.value(QMAKE_SELECTED_ABIS_KEY).toStringList();
@@ -513,10 +506,6 @@ QWidget *QMakeStep::createConfigWidget()
{ {
auto widget = new QWidget; auto widget = new QWidget;
auto qmakeArgsLabel = new QLabel(tr("Additional arguments:"), widget);
qmakeAdditonalArgumentsLineEdit = new QLineEdit(widget);
auto label = new QLabel(tr("Effective qmake call:"), widget); auto label = new QLabel(tr("Effective qmake call:"), widget);
label->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); label->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
@@ -529,11 +518,10 @@ QWidget *QMakeStep::createConfigWidget()
abisLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); abisLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
abisListWidget = new QListWidget(widget); abisListWidget = new QListWidget(widget);
qmakeAdditonalArgumentsLineEdit->setText(m_userArgs);
LayoutBuilder builder(widget); LayoutBuilder builder(widget);
builder.addRow(m_buildType); builder.addRow(m_buildType);
builder.addRow({qmakeArgsLabel, qmakeAdditonalArgumentsLineEdit}); builder.addRow(m_userArgs);
builder.addRow({label, qmakeArgumentsEdit}); builder.addRow({label, qmakeArgumentsEdit});
builder.addRow({abisLabel, abisListWidget}); builder.addRow({abisLabel, abisListWidget});
@@ -543,8 +531,14 @@ QWidget *QMakeStep::createConfigWidget()
updateAbiWidgets(); updateAbiWidgets();
updateEffectiveQMakeCall(); updateEffectiveQMakeCall();
connect(qmakeAdditonalArgumentsLineEdit, &QLineEdit::textEdited, connect(m_userArgs, &BaseAspect::changed, widget, [this] {
this, &QMakeStep::qmakeArgumentsLineEdited); updateAbiWidgets();
updateEffectiveQMakeCall();
emit qmakeBuildConfiguration()->qmakeBuildConfigurationChanged();
qmakeBuildSystem()->scheduleUpdateAllNowOrLater();
});
connect(m_buildType, &BaseAspect::changed, connect(m_buildType, &BaseAspect::changed,
widget, [this] { buildConfigurationSelected(); }); widget, [this] { buildConfigurationSelected(); });
@@ -573,9 +567,7 @@ QWidget *QMakeStep::createConfigWidget()
BuildManager::buildLists({bc->cleanSteps()}); BuildManager::buildLists({bc->cleanSteps()});
}); });
auto chooser = new VariableChooser(qmakeAdditonalArgumentsLineEdit); VariableChooser::addSupportForChildWidgets(widget, macroExpander());
chooser->addMacroExpanderProvider([this] { return macroExpander(); });
chooser->addSupportedWidget(qmakeAdditonalArgumentsLineEdit);
return widget; return widget;
} }
@@ -597,16 +589,6 @@ void QMakeStep::qmakeBuildConfigChanged()
updateEffectiveQMakeCall(); updateEffectiveQMakeCall();
} }
void QMakeStep::userArgumentsChanged()
{
if (m_ignoreChange)
return;
if (qmakeAdditonalArgumentsLineEdit)
qmakeAdditonalArgumentsLineEdit->setText(m_userArgs);
updateAbiWidgets();
updateEffectiveQMakeCall();
}
void QMakeStep::linkQmlDebuggingLibraryChanged() void QMakeStep::linkQmlDebuggingLibraryChanged()
{ {
updateAbiWidgets(); updateAbiWidgets();
@@ -657,16 +639,6 @@ void QMakeStep::abisChanged()
updateEffectiveQMakeCall(); updateEffectiveQMakeCall();
} }
void QMakeStep::qmakeArgumentsLineEdited()
{
m_ignoreChange = true;
setUserArguments(qmakeAdditonalArgumentsLineEdit->text());
m_ignoreChange = false;
updateAbiWidgets();
updateEffectiveQMakeCall();
}
void QMakeStep::buildConfigurationSelected() void QMakeStep::buildConfigurationSelected()
{ {
if (m_ignoreChange) if (m_ignoreChange)

View File

@@ -44,6 +44,7 @@ QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer {
class Abi; class Abi;
class ArgumentsAspect;
} // namespace ProjectExplorer } // namespace ProjectExplorer
namespace QtSupport { class BaseQtVersion; } namespace QtSupport { class BaseQtVersion; }
@@ -138,7 +139,7 @@ public:
// arguments passed to the pro file parser // arguments passed to the pro file parser
QStringList parserArguments(); QStringList parserArguments();
// arguments set by the user // arguments set by the user
QString userArguments(); QString userArguments() const;
void setUserArguments(const QString &arguments); void setUserArguments(const QString &arguments);
// Extra arguments for qmake and pro file parser. Not user editable via UI. // Extra arguments for qmake and pro file parser. Not user editable via UI.
QStringList extraArguments() const; QStringList extraArguments() const;
@@ -170,7 +171,6 @@ private:
// slots for handling buildconfiguration/step signals // slots for handling buildconfiguration/step signals
void qtVersionChanged(); void qtVersionChanged();
void qmakeBuildConfigChanged(); void qmakeBuildConfigChanged();
void userArgumentsChanged();
void linkQmlDebuggingLibraryChanged(); void linkQmlDebuggingLibraryChanged();
void useQtQuickCompilerChanged(); void useQtQuickCompilerChanged();
void separateDebugInfoChanged(); void separateDebugInfoChanged();
@@ -189,7 +189,7 @@ private:
Utils::CommandLine m_qmakeCommand; Utils::CommandLine m_qmakeCommand;
Utils::CommandLine m_makeCommand; Utils::CommandLine m_makeCommand;
QString m_userArgs; ProjectExplorer::ArgumentsAspect *m_userArgs = nullptr;
// Extra arguments for qmake and pro file parser // Extra arguments for qmake and pro file parser
QStringList m_extraArgs; QStringList m_extraArgs;
// Extra arguments for pro file parser only // Extra arguments for pro file parser only
@@ -211,7 +211,6 @@ private:
QLabel *abisLabel = nullptr; QLabel *abisLabel = nullptr;
Utils::SelectionAspect *m_buildType = nullptr; Utils::SelectionAspect *m_buildType = nullptr;
QLineEdit *qmakeAdditonalArgumentsLineEdit = nullptr;
QPlainTextEdit *qmakeArgumentsEdit = nullptr; QPlainTextEdit *qmakeArgumentsEdit = nullptr;
QListWidget *abisListWidget = nullptr; QListWidget *abisListWidget = nullptr;
}; };