From ec7e9e649b3465449b0447b4e8eff8f1ec1208c5 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 9 Jul 2020 17:25:55 +0200 Subject: [PATCH] ProjectExplorer: Inline makestep.ui A step towards aspectification. Change-Id: I1eeb0ff3623b6cfd0b564825548309a1307846ac Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/CMakeLists.txt | 2 +- src/plugins/projectexplorer/makestep.cpp | 379 +++++++++++------- src/plugins/projectexplorer/makestep.h | 26 -- src/plugins/projectexplorer/makestep.ui | 136 ------- .../projectexplorer/projectexplorer.pro | 1 - .../projectexplorer/projectexplorer.qbs | 2 +- 6 files changed, 227 insertions(+), 319 deletions(-) delete mode 100644 src/plugins/projectexplorer/makestep.ui diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index 81559e66f8f..c44faf7f0d9 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -115,7 +115,7 @@ add_qtc_plugin(ProjectExplorer lldparser.cpp lldparser.h linuxiccparser.cpp linuxiccparser.h localenvironmentaspect.cpp localenvironmentaspect.h - makestep.cpp makestep.h makestep.ui + makestep.cpp makestep.h miniprojecttargetselector.cpp miniprojecttargetselector.h msvcparser.cpp msvcparser.h msvctoolchain.cpp msvctoolchain.h diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index fef7acd52db..279ed71910d 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "makestep.h" -#include "ui_makestep.h" #include "buildconfiguration.h" #include "gnumakeparser.h" @@ -40,9 +39,16 @@ #include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include #include using namespace Core; @@ -58,6 +64,222 @@ const char JOBCOUNT_SUFFIX[] = ".JobCount"; const char MAKEFLAGS[] = "MAKEFLAGS"; namespace ProjectExplorer { +namespace Internal { + +class MakeStepConfigWidget : public BuildStepConfigWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::MakeStep) + +public: + explicit MakeStepConfigWidget(MakeStep *makeStep); + +private: + void itemChanged(QListWidgetItem *item); + void makeLineEditTextEdited(); + void makeArgumentsLineEditTextEdited(); + void updateDetails(); + void setUserJobCountVisible(bool visible); + void setUserJobCountEnabled(bool enabled); + + MakeStep *m_makeStep; + + QLabel *m_makeLabel; + Utils::PathChooser *m_makeLineEdit; + QLabel *m_makeArgumentsLabel; + QLineEdit *m_makeArgumentsLineEdit; + QLabel *m_jobsLabel; + QLabel *m_targetsLabel; + QListWidget *m_targetsList; + QSpinBox *m_userJobCount; + QCheckBox *m_overrideMakeflags; + QLabel *m_nonOverrideWarning; + QCheckBox *m_disableInSubDirsCheckBox; +}; + + +MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) + : BuildStepConfigWidget(makeStep), m_makeStep(makeStep) +{ + m_makeLabel = new QLabel(tr("Override %1:"), this); + + m_makeLineEdit = new PathChooser(this); + m_makeLineEdit->setExpectedKind(PathChooser::ExistingCommand); + m_makeLineEdit->setBaseDirectory(FilePath::fromString(PathChooser::homePath())); + m_makeLineEdit->setHistoryCompleter("PE.MakeCommand.History"); + m_makeLineEdit->setPath(m_makeStep->makeCommand().toString()); + + auto makeArgumentsLabel = new QLabel(tr("Make arguments:"), this); + + m_makeArgumentsLineEdit = new QLineEdit(this); + m_makeArgumentsLineEdit->setText(m_makeStep->userArguments()); + + m_jobsLabel = new QLabel(this); + m_jobsLabel->setText(tr("Parallel jobs:")); + + m_targetsLabel = new QLabel(this); + m_targetsLabel->setText(tr("Targets:")); + + m_targetsList = new QListWidget(this); + + m_userJobCount = new QSpinBox(this); + m_userJobCount->setMinimum(1); + m_userJobCount->setMaximum(999); + + m_overrideMakeflags = new QCheckBox(tr("Override MAKEFLAGS"), this); + + m_nonOverrideWarning = new QLabel(this); + m_nonOverrideWarning->setToolTip("

" + + tr("MAKEFLAGS specifies parallel jobs. Check \"%1\" to override.") + .arg(m_overrideMakeflags->text()) + "

"); + m_nonOverrideWarning->setPixmap(Icons::WARNING.pixmap()); + + auto disableInSubDirsLabel = new QLabel(tr("Disable in subdirectories:"), this); + m_disableInSubDirsCheckBox = new QCheckBox(this); + m_disableInSubDirsCheckBox->setToolTip(tr("Runs this step only for a top-level build.")); + + auto jobLayout = new QHBoxLayout; + jobLayout->addWidget(m_userJobCount); + jobLayout->addWidget(m_overrideMakeflags); + jobLayout->addWidget(m_nonOverrideWarning); + + auto formLayout = new QFormLayout(this); + formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + formLayout->setContentsMargins(0, 0, 0, 0); + + formLayout->addRow(m_makeLabel, m_makeLineEdit); + formLayout->addRow(makeArgumentsLabel, m_makeArgumentsLineEdit); + formLayout->addRow(m_jobsLabel, jobLayout); + formLayout->addRow(disableInSubDirsLabel, m_disableInSubDirsCheckBox); + formLayout->addRow(m_targetsLabel, m_targetsList); + + if (!makeStep->disablingForSubdirsSupported()) { + disableInSubDirsLabel->hide(); + m_disableInSubDirsCheckBox->hide(); + } else { + connect(m_disableInSubDirsCheckBox, &QCheckBox::toggled, this, [this] { + m_makeStep->setEnabledForSubDirs(!m_disableInSubDirsCheckBox->isChecked()); + }); + } + + const auto availableTargets = makeStep->availableTargets(); + for (const QString &target : availableTargets) { + auto item = new QListWidgetItem(target, m_targetsList); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked); + } + if (availableTargets.isEmpty()) { + m_targetsLabel->hide(); + m_targetsList->hide(); + } + + updateDetails(); + + connect(m_targetsList, &QListWidget::itemChanged, + this, &MakeStepConfigWidget::itemChanged); + connect(m_makeLineEdit, &Utils::PathChooser::rawPathChanged, + this, &MakeStepConfigWidget::makeLineEditTextEdited); + connect(m_makeArgumentsLineEdit, &QLineEdit::textEdited, + this, &MakeStepConfigWidget::makeArgumentsLineEditTextEdited); + connect(m_userJobCount, QOverload::of(&QSpinBox::valueChanged), this, [this](int value) { + m_makeStep->setJobCount(value); + updateDetails(); + }); + connect(m_overrideMakeflags, &QCheckBox::stateChanged, this, [this](int state) { + m_makeStep->setJobCountOverrideMakeflags(state == Qt::Checked); + updateDetails(); + }); + + connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged, + this, &MakeStepConfigWidget::updateDetails); + + connect(m_makeStep->target(), &Target::kitChanged, + this, &MakeStepConfigWidget::updateDetails); + + connect(m_makeStep->buildConfiguration(), &BuildConfiguration::environmentChanged, + this, &MakeStepConfigWidget::updateDetails); + connect(m_makeStep->buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, + this, &MakeStepConfigWidget::updateDetails); + connect(m_makeStep->target(), &Target::parsingFinished, + this, &MakeStepConfigWidget::updateDetails); + + Core::VariableChooser::addSupportForChildWidgets(this, m_makeStep->macroExpander()); +} + +void MakeStepConfigWidget::setUserJobCountVisible(bool visible) +{ + m_jobsLabel->setVisible(visible); + m_userJobCount->setVisible(visible); + m_overrideMakeflags->setVisible(visible); +} + +void MakeStepConfigWidget::setUserJobCountEnabled(bool enabled) +{ + m_jobsLabel->setEnabled(enabled); + m_userJobCount->setEnabled(enabled); + m_overrideMakeflags->setEnabled(enabled); +} + +void MakeStepConfigWidget::updateDetails() +{ + BuildConfiguration *bc = m_makeStep->buildConfiguration(); + + const QString defaultMake = m_makeStep->defaultMakeCommand().toString(); + if (defaultMake.isEmpty()) + m_makeLabel->setText(tr("Make:")); + else + m_makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake))); + + const CommandLine make = m_makeStep->effectiveMakeCommand(MakeStep::Display); + if (make.executable().isEmpty()) { + setSummaryText(tr("Make: %1").arg(MakeStep::msgNoMakeCommand())); + return; + } + if (!bc) { + setSummaryText(tr("Make: No build configuration.")); + return; + } + + setUserJobCountVisible(m_makeStep->isJobCountSupported()); + setUserJobCountEnabled(!m_makeStep->userArgsContainsJobCount()); + m_userJobCount->setValue(m_makeStep->jobCount()); + m_overrideMakeflags->setCheckState( + m_makeStep->jobCountOverridesMakeflags() ? Qt::Checked : Qt::Unchecked); + m_nonOverrideWarning->setVisible(m_makeStep->makeflagsJobCountMismatch() + && !m_makeStep->jobCountOverridesMakeflags()); + m_disableInSubDirsCheckBox->setChecked(!m_makeStep->enabledForSubDirs()); + + ProcessParameters param; + param.setMacroExpander(m_makeStep->macroExpander()); + param.setWorkingDirectory(m_makeStep->buildDirectory()); + param.setCommandLine(make); + param.setEnvironment(m_makeStep->buildEnvironment()); + + if (param.commandMissing()) + setSummaryText(tr("Make: %1 not found in the environment.") + .arg(param.command().executable().toUserOutput())); // Override display text + else + setSummaryText(param.summaryInWorkdir(displayName())); +} + +void MakeStepConfigWidget::itemChanged(QListWidgetItem *item) +{ + m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked); + updateDetails(); +} + +void MakeStepConfigWidget::makeLineEditTextEdited() +{ + m_makeStep->setMakeCommand(FilePath::fromString(m_makeLineEdit->rawPath())); + updateDetails(); +} + +void MakeStepConfigWidget::makeArgumentsLineEditTextEdited() +{ + m_makeStep->setUserArguments(m_makeArgumentsLineEdit->text()); + updateDetails(); +} +} // Internal + MakeStep::MakeStep(BuildStepList *parent, Utils::Id id) : AbstractProcessStep(parent, id), @@ -346,7 +568,7 @@ CommandLine MakeStep::effectiveMakeCommand(MakeCommandType type) const BuildStepConfigWidget *MakeStep::createConfigWidget() { - return new MakeStepConfigWidget(this); + return new Internal::MakeStepConfigWidget(this); } bool MakeStep::buildsTarget(const QString &target) const @@ -370,155 +592,4 @@ QStringList MakeStep::availableTargets() const return m_availableTargets; } -// -// GenericMakeStepConfigWidget -// - -MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) - : BuildStepConfigWidget(makeStep), m_makeStep(makeStep) -{ - m_ui = new Internal::Ui::MakeStep; - m_ui->setupUi(this); - - if (!makeStep->disablingForSubdirsSupported()) { - m_ui->disableInSubDirsLabel->hide(); - m_ui->disableInSubDirsCheckBox->hide(); - } else { - connect(m_ui->disableInSubDirsCheckBox, &QCheckBox::toggled, this, [this] { - m_makeStep->setEnabledForSubDirs(!m_ui->disableInSubDirsCheckBox->isChecked()); - }); - } - - const auto availableTargets = makeStep->availableTargets(); - for (const QString &target : availableTargets) { - auto item = new QListWidgetItem(target, m_ui->targetsList); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked); - } - if (availableTargets.isEmpty()) { - m_ui->targetsLabel->hide(); - m_ui->targetsList->hide(); - } - - m_ui->makeLineEdit->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_ui->makeLineEdit->setBaseDirectory(FilePath::fromString(PathChooser::homePath())); - m_ui->makeLineEdit->setHistoryCompleter("PE.MakeCommand.History"); - m_ui->makeLineEdit->setPath(m_makeStep->makeCommand().toString()); - m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments()); - m_ui->nonOverrideWarning->setToolTip("

" + - tr("MAKEFLAGS specifies parallel jobs. Check \"%1\" to override.") - .arg(m_ui->overrideMakeflags->text()) + "

"); - m_ui->nonOverrideWarning->setPixmap(Utils::Icons::WARNING.pixmap()); - updateDetails(); - - connect(m_ui->targetsList, &QListWidget::itemChanged, - this, &MakeStepConfigWidget::itemChanged); - connect(m_ui->makeLineEdit, &Utils::PathChooser::rawPathChanged, - this, &MakeStepConfigWidget::makeLineEditTextEdited); - connect(m_ui->makeArgumentsLineEdit, &QLineEdit::textEdited, - this, &MakeStepConfigWidget::makeArgumentsLineEditTextEdited); - connect(m_ui->userJobCount, QOverload::of(&QSpinBox::valueChanged), this, [this](int value) { - m_makeStep->setJobCount(value); - updateDetails(); - }); - connect(m_ui->overrideMakeflags, &QCheckBox::stateChanged, this, [this](int state) { - m_makeStep->setJobCountOverrideMakeflags(state == Qt::Checked); - updateDetails(); - }); - - connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged, - this, &MakeStepConfigWidget::updateDetails); - - connect(m_makeStep->target(), &Target::kitChanged, - this, &MakeStepConfigWidget::updateDetails); - - connect(m_makeStep->buildConfiguration(), &BuildConfiguration::environmentChanged, - this, &MakeStepConfigWidget::updateDetails); - connect(m_makeStep->buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, - this, &MakeStepConfigWidget::updateDetails); - connect(m_makeStep->target(), &Target::parsingFinished, - this, &MakeStepConfigWidget::updateDetails); - - Core::VariableChooser::addSupportForChildWidgets(this, m_makeStep->macroExpander()); -} - -MakeStepConfigWidget::~MakeStepConfigWidget() -{ - delete m_ui; -} - -void MakeStepConfigWidget::setUserJobCountVisible(bool visible) -{ - m_ui->jobsLabel->setVisible(visible); - m_ui->userJobCount->setVisible(visible); - m_ui->overrideMakeflags->setVisible(visible); -} - -void MakeStepConfigWidget::setUserJobCountEnabled(bool enabled) -{ - m_ui->jobsLabel->setEnabled(enabled); - m_ui->userJobCount->setEnabled(enabled); - m_ui->overrideMakeflags->setEnabled(enabled); -} - -void MakeStepConfigWidget::updateDetails() -{ - BuildConfiguration *bc = m_makeStep->buildConfiguration(); - - const QString defaultMake = m_makeStep->defaultMakeCommand().toString(); - if (defaultMake.isEmpty()) - m_ui->makeLabel->setText(tr("Make:")); - else - m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake))); - - const CommandLine make = m_makeStep->effectiveMakeCommand(MakeStep::Display); - if (make.executable().isEmpty()) { - setSummaryText(tr("Make: %1").arg(MakeStep::msgNoMakeCommand())); - return; - } - if (!bc) { - setSummaryText(tr("Make: No build configuration.")); - return; - } - - setUserJobCountVisible(m_makeStep->isJobCountSupported()); - setUserJobCountEnabled(!m_makeStep->userArgsContainsJobCount()); - m_ui->userJobCount->setValue(m_makeStep->jobCount()); - m_ui->overrideMakeflags->setCheckState( - m_makeStep->jobCountOverridesMakeflags() ? Qt::Checked : Qt::Unchecked); - m_ui->nonOverrideWarning->setVisible(m_makeStep->makeflagsJobCountMismatch() - && !m_makeStep->jobCountOverridesMakeflags()); - m_ui->disableInSubDirsCheckBox->setChecked(!m_makeStep->enabledForSubDirs()); - - ProcessParameters param; - param.setMacroExpander(m_makeStep->macroExpander()); - param.setWorkingDirectory(m_makeStep->buildDirectory()); - param.setCommandLine(make); - param.setEnvironment(m_makeStep->buildEnvironment()); - - if (param.commandMissing()) - setSummaryText(tr("Make: %1 not found in the environment.") - .arg(param.command().executable().toUserOutput())); // Override display text - else - setSummaryText(param.summaryInWorkdir(displayName())); -} - -void MakeStepConfigWidget::itemChanged(QListWidgetItem *item) -{ - m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked); - updateDetails(); -} - -void MakeStepConfigWidget::makeLineEditTextEdited() -{ - m_makeStep->setMakeCommand(FilePath::fromString(m_ui->makeLineEdit->rawPath())); - updateDetails(); -} - -void MakeStepConfigWidget::makeArgumentsLineEditTextEdited() -{ - m_makeStep->setUserArguments(m_ui->makeArgumentsLineEdit->text()); - updateDetails(); -} - -} // namespace GenericProjectManager +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/makestep.h b/src/plugins/projectexplorer/makestep.h index 8c58748e61c..ca73df2045f 100644 --- a/src/plugins/projectexplorer/makestep.h +++ b/src/plugins/projectexplorer/makestep.h @@ -29,16 +29,10 @@ #include -QT_FORWARD_DECLARE_CLASS(QListWidgetItem); - namespace Utils { class Environment; } namespace ProjectExplorer { -namespace Internal { -namespace Ui { class MakeStep; } -} // namespace Internal - class PROJECTEXPLORER_EXPORT MakeStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT @@ -111,24 +105,4 @@ private: bool m_enabledForSubDirs = true; }; -class PROJECTEXPLORER_EXPORT MakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT - -public: - explicit MakeStepConfigWidget(MakeStep *makeStep); - ~MakeStepConfigWidget() override; - -private: - void itemChanged(QListWidgetItem *item); - void makeLineEditTextEdited(); - void makeArgumentsLineEditTextEdited(); - void updateDetails(); - void setUserJobCountVisible(bool visible); - void setUserJobCountEnabled(bool enabled); - - Internal::Ui::MakeStep *m_ui; - MakeStep *m_makeStep; -}; - } // namespace GenericProjectManager diff --git a/src/plugins/projectexplorer/makestep.ui b/src/plugins/projectexplorer/makestep.ui deleted file mode 100644 index 94f55738da5..00000000000 --- a/src/plugins/projectexplorer/makestep.ui +++ /dev/null @@ -1,136 +0,0 @@ - - - ProjectExplorer::Internal::MakeStep - - - - 0 - 0 - 422 - 279 - - - - - QFormLayout::ExpandingFieldsGrow - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Override %1: - - - makeLineEdit - - - - - - - - - - Make arguments: - - - makeArgumentsLineEdit - - - - - - - - - - Parallel jobs: - - - - - - - Targets: - - - targetsList - - - - - - - - - - - - 1 - - - 999 - - - - - - - Override MAKEFLAGS - - - - - - - - - - - - - - - - - - - Disable in subdirectories: - - - - - - - Runs this step only for a top-level build. - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - -
diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index d9f7cbf55be..1e6a4274304 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -325,7 +325,6 @@ FORMS += \ devicesupport/devicesettingswidget.ui \ devicesupport/devicetestdialog.ui \ customparserconfigdialog.ui \ - makestep.ui WINSOURCES += \ windebuginterface.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index d6429ca9d86..2befdbabfa3 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -96,7 +96,7 @@ Project { "lldparser.cpp", "lldparser.h", "linuxiccparser.cpp", "linuxiccparser.h", "localenvironmentaspect.cpp", "localenvironmentaspect.h", - "makestep.cpp", "makestep.h", "makestep.ui", + "makestep.cpp", "makestep.h", "miniprojecttargetselector.cpp", "miniprojecttargetselector.h", "msvcparser.cpp", "msvcparser.h", "namedwidget.cpp", "namedwidget.h",