diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index 1830270bed6..49a854d0e6a 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -43,6 +43,7 @@ #include #include #include +#include using namespace Utils; @@ -76,6 +77,7 @@ public: QPointer m_labelDisplay; QPointer m_lineEditDisplay; QPointer m_pathChooserDisplay; + QPointer m_textEditDisplay; QPixmap m_labelPixmap; }; @@ -178,6 +180,8 @@ void BaseStringAspect::setPlaceHolderText(const QString &placeHolderText) d->m_placeHolderText = placeHolderText; if (d->m_lineEditDisplay) d->m_lineEditDisplay->setPlaceholderText(placeHolderText); + if (d->m_textEditDisplay) + d->m_textEditDisplay->setPlaceholderText(placeHolderText); } void BaseStringAspect::setHistoryCompleter(const QString &historyCompleterKey) @@ -234,6 +238,18 @@ void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout) this, &BaseStringAspect::setValue); hbox->addWidget(d->m_lineEditDisplay); break; + case TextEditDisplay: + d->m_textEditDisplay = new QTextEdit(parent); + d->m_textEditDisplay->setPlaceholderText(d->m_placeHolderText); + connect(d->m_textEditDisplay, &QTextEdit::textChanged, this, [this] { + const QString value = d->m_textEditDisplay->document()->toPlainText(); + if (value != d->m_value) { + d->m_value = value; + emit changed(); + } + }); + hbox->addWidget(d->m_textEditDisplay); + break; case LabelDisplay: d->m_labelDisplay = new QLabel(parent); d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse); @@ -270,6 +286,11 @@ void BaseStringAspect::update() d->m_lineEditDisplay->setEnabled(enabled); } + if (d->m_textEditDisplay) { + d->m_textEditDisplay->setText(displayedString); + d->m_textEditDisplay->setEnabled(enabled); + } + if (d->m_labelDisplay) d->m_labelDisplay->setText(displayedString); diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index d494f0bcb33..593f6d3ed57 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -93,7 +93,12 @@ public: bool isChecked() const; void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey); - enum DisplayStyle { LabelDisplay, LineEditDisplay, PathChooserDisplay }; + enum DisplayStyle { + LabelDisplay, + LineEditDisplay, + TextEditDisplay, + PathChooserDisplay + }; void setDisplayStyle(DisplayStyle style); void fromMap(const QVariantMap &map) override; diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.cpp b/src/plugins/qbsprojectmanager/qbscleanstep.cpp index 0ec62cb0164..4bb5cd73047 100644 --- a/src/plugins/qbsprojectmanager/qbscleanstep.cpp +++ b/src/plugins/qbsprojectmanager/qbscleanstep.cpp @@ -29,8 +29,6 @@ #include "qbsproject.h" #include "qbsprojectmanagerconstants.h" -#include "ui_qbscleanstepconfigwidget.h" - #include #include #include @@ -38,8 +36,7 @@ #include #include -static const char QBS_DRY_RUN[] = "Qbs.DryRun"; -static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing"; +using namespace ProjectExplorer; namespace QbsProjectManager { namespace Internal { @@ -53,6 +50,27 @@ QbsCleanStep::QbsCleanStep(ProjectExplorer::BuildStepList *bsl) : { setDisplayName(tr("Qbs Clean")); setRunInGuiThread(true); + + m_dryRunAspect = addAspect(); + m_dryRunAspect->setSettingsKey("Qbs.DryRun"); + m_dryRunAspect->setLabel(tr("Dry run")); + + m_keepGoingAspect = addAspect(); + m_keepGoingAspect->setSettingsKey("Qbs.DryKeepGoing"); + m_keepGoingAspect->setLabel(tr("Keep going")); + + m_effectiveCommandAspect = addAspect(); + m_effectiveCommandAspect->setDisplayStyle(BaseStringAspect::TextEditDisplay); + m_effectiveCommandAspect->setLabelText(tr("Equivalent command line:")); + + updateState(); + + connect(this, &ProjectExplorer::ProjectConfiguration::displayNameChanged, + this, &QbsCleanStep::updateState); + connect(m_dryRunAspect, &BaseBoolAspect::changed, + this, &QbsCleanStep::updateState); + connect(m_keepGoingAspect, &BaseBoolAspect::changed, + this, &QbsCleanStep::updateState); } QbsCleanStep::~QbsCleanStep() @@ -83,7 +101,9 @@ void QbsCleanStep::run(QFutureInterface &fi) m_fi = &fi; auto pro = static_cast(project()); - qbs::CleanOptions options(m_qbsCleanOptions); + qbs::CleanOptions options; + options.setDryRun(m_dryRunAspect->value()); + options.setKeepGoing(m_keepGoingAspect->value()); QString error; m_job = pro->clean(options, m_products, error); @@ -104,7 +124,11 @@ void QbsCleanStep::run(QFutureInterface &fi) ProjectExplorer::BuildStepConfigWidget *QbsCleanStep::createConfigWidget() { - return new QbsCleanStepConfigWidget(this); + auto w = BuildStep::createConfigWidget(); + connect(this, &QbsCleanStep::stateChanged, w, [this, w] { + w->setSummaryText(tr("Qbs: %1").arg(m_effectiveCommandAspect->value())); + }); + return w; } void QbsCleanStep::cancel() @@ -113,36 +137,6 @@ void QbsCleanStep::cancel() m_job->cancel(); } -bool QbsCleanStep::dryRun() const -{ - return m_qbsCleanOptions.dryRun(); -} - -bool QbsCleanStep::keepGoing() const -{ - return m_qbsCleanOptions.keepGoing(); -} - -bool QbsCleanStep::fromMap(const QVariantMap &map) -{ - if (!ProjectExplorer::BuildStep::fromMap(map)) - return false; - - m_qbsCleanOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool()); - m_qbsCleanOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool()); - - return true; -} - -QVariantMap QbsCleanStep::toMap() const -{ - QVariantMap map = ProjectExplorer::BuildStep::toMap(); - map.insert(QLatin1String(QBS_DRY_RUN), m_qbsCleanOptions.dryRun()); - map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsCleanOptions.keepGoing()); - - return map; -} - void QbsCleanStep::cleaningDone(bool success) { // Report errors: @@ -172,6 +166,14 @@ void QbsCleanStep::handleProgress(int value) m_fi->setProgressValue(m_progressBase + value); } +void QbsCleanStep::updateState() +{ + QString command = static_cast(buildConfiguration()) + ->equivalentCommandLine(this); + m_effectiveCommandAspect->setValue(command); + emit stateChanged(); +} + void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line) { ProjectExplorer::Task task = ProjectExplorer::Task(type, message, @@ -181,75 +183,6 @@ void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, con emit addOutput(message, OutputFormat::Stdout); } -void QbsCleanStep::setDryRun(bool dr) -{ - if (m_qbsCleanOptions.dryRun() == dr) - return; - m_qbsCleanOptions.setDryRun(dr); - emit changed(); -} - -void QbsCleanStep::setKeepGoing(bool kg) -{ - if (m_qbsCleanOptions.keepGoing() == kg) - return; - m_qbsCleanOptions.setKeepGoing(kg); - emit changed(); -} - - -// -------------------------------------------------------------------- -// QbsCleanStepConfigWidget: -// -------------------------------------------------------------------- - -QbsCleanStepConfigWidget::QbsCleanStepConfigWidget(QbsCleanStep *step) : - BuildStepConfigWidget(step), m_step(step) -{ - connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, - this, &QbsCleanStepConfigWidget::updateState); - connect(m_step, &QbsCleanStep::changed, - this, &QbsCleanStepConfigWidget::updateState); - - setContentsMargins(0, 0, 0, 0); - - m_ui = new Ui::QbsCleanStepConfigWidget; - m_ui->setupUi(this); - - connect(m_ui->dryRunCheckBox, &QAbstractButton::toggled, - this, &QbsCleanStepConfigWidget::changeDryRun); - connect(m_ui->keepGoingCheckBox, &QAbstractButton::toggled, - this, &QbsCleanStepConfigWidget::changeKeepGoing); - - updateState(); -} - -QbsCleanStepConfigWidget::~QbsCleanStepConfigWidget() -{ - delete m_ui; -} - -void QbsCleanStepConfigWidget::updateState() -{ - m_ui->dryRunCheckBox->setChecked(m_step->dryRun()); - m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing()); - - QString command = static_cast(m_step->buildConfiguration()) - ->equivalentCommandLine(m_step); - m_ui->commandLineTextEdit->setPlainText(command); - - setSummaryText(tr("Qbs: %1").arg(command)); -} - -void QbsCleanStepConfigWidget::changeDryRun(bool dr) -{ - m_step->setDryRun(dr); -} - -void QbsCleanStepConfigWidget::changeKeepGoing(bool kg) -{ - m_step->setKeepGoing(kg); -} - // -------------------------------------------------------------------- // QbsCleanStepFactory: // -------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.h b/src/plugins/qbsprojectmanager/qbscleanstep.h index 06e8cb85e08..2029216645f 100644 --- a/src/plugins/qbsprojectmanager/qbscleanstep.h +++ b/src/plugins/qbsprojectmanager/qbscleanstep.h @@ -28,6 +28,7 @@ #include "qbsbuildconfiguration.h" #include +#include #include #include @@ -35,8 +36,6 @@ namespace QbsProjectManager { namespace Internal { -class QbsCleanStepConfigWidget; - class QbsCleanStep : public ProjectExplorer::BuildStep { Q_OBJECT @@ -52,27 +51,25 @@ public: void cancel() override; - bool fromMap(const QVariantMap &map) override; - QVariantMap toMap() const override; - - bool dryRun() const; - bool keepGoing() const; + bool dryRun() const { return m_dryRunAspect->value(); } + bool keepGoing() const { return m_keepGoingAspect->value(); } signals: - void changed(); + void stateChanged(); private: void cleaningDone(bool success); void handleTaskStarted(const QString &desciption, int max); void handleProgress(int value); + void updateState(); void createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line); - void setDryRun(bool dr); - void setKeepGoing(bool kg); + ProjectExplorer::BaseBoolAspect *m_dryRunAspect = nullptr; + ProjectExplorer::BaseBoolAspect *m_keepGoingAspect = nullptr; + ProjectExplorer::BaseStringAspect *m_effectiveCommandAspect = nullptr; - qbs::CleanOptions m_qbsCleanOptions; QStringList m_products; QFutureInterface *m_fi = nullptr; @@ -80,28 +77,6 @@ private: int m_progressBase; bool m_showCompilerOutput = true; ProjectExplorer::IOutputParser *m_parser = nullptr; - - friend class QbsCleanStepConfigWidget; -}; - -namespace Ui { class QbsCleanStepConfigWidget; } - -class QbsCleanStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT -public: - QbsCleanStepConfigWidget(QbsCleanStep *step); - ~QbsCleanStepConfigWidget() override; - -private: - void updateState(); - - void changeDryRun(bool dr); - void changeKeepGoing(bool kg); - - Ui::QbsCleanStepConfigWidget *m_ui; - - QbsCleanStep *m_step; }; class QbsCleanStepFactory : public ProjectExplorer::BuildStepFactory