Qbs: Use aspects in QbsInstallStep more directly

Change-Id: I5fca944d8c2c93e0f7249cc9c0532f66e5b9b33c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-07-14 11:55:00 +02:00
parent 381ff44f66
commit f65cffdfa2
2 changed files with 21 additions and 33 deletions

View File

@@ -10,7 +10,6 @@
#include "qbsprojectmanagertr.h" #include "qbsprojectmanagertr.h"
#include "qbssession.h" #include "qbssession.h"
#include <coreplugin/icore.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
@@ -30,36 +29,25 @@ using namespace Utils;
namespace QbsProjectManager { namespace QbsProjectManager {
namespace Internal { namespace Internal {
// --------------------------------------------------------------------
// Constants:
// --------------------------------------------------------------------
const char QBS_REMOVE_FIRST[] = "Qbs.RemoveFirst";
const char QBS_DRY_RUN[] = "Qbs.DryRun";
const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// QbsInstallStep: // QbsInstallStep:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Utils::Id id) QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Id id)
: BuildStep(bsl, id) : BuildStep(bsl, id)
{ {
setDisplayName(Tr::tr("Qbs Install")); setDisplayName(Tr::tr("Qbs Install"));
setSummaryText(Tr::tr("<b>Qbs:</b> %1").arg("install")); setSummaryText(Tr::tr("<b>Qbs:</b> %1").arg("install"));
const auto labelPlacement = BoolAspect::LabelPlacement::AtCheckBox; const auto labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
m_dryRun = addAspect<BoolAspect>(); dryRun.setSettingsKey("Qbs.DryRun");
m_dryRun->setSettingsKey(QBS_DRY_RUN); dryRun.setLabel(Tr::tr("Dry run"), labelPlacement);
m_dryRun->setLabel(Tr::tr("Dry run"), labelPlacement);
m_keepGoing = addAspect<BoolAspect>(); keepGoing.setSettingsKey("Qbs.DryKeepGoing");
m_keepGoing->setSettingsKey(QBS_KEEP_GOING); keepGoing.setLabel(Tr::tr("Keep going"), labelPlacement);
m_keepGoing->setLabel(Tr::tr("Keep going"), labelPlacement);
m_cleanInstallRoot = addAspect<BoolAspect>(); cleanInstallRoot.setSettingsKey("Qbs.RemoveFirst");
m_cleanInstallRoot->setSettingsKey(QBS_REMOVE_FIRST); cleanInstallRoot.setLabel(Tr::tr("Remove first"), labelPlacement);
m_cleanInstallRoot->setLabel(Tr::tr("Remove first"), labelPlacement);
} }
QbsInstallStep::~QbsInstallStep() QbsInstallStep::~QbsInstallStep()
@@ -82,9 +70,9 @@ void QbsInstallStep::doRun()
QJsonObject request; QJsonObject request;
request.insert("type", "install-project"); request.insert("type", "install-project");
request.insert("install-root", installRoot().path()); request.insert("install-root", installRoot().path());
request.insert("clean-install-root", m_cleanInstallRoot->value()); request.insert("clean-install-root", cleanInstallRoot());
request.insert("keep-going", m_keepGoing->value()); request.insert("keep-going", keepGoing());
request.insert("dry-run", m_dryRun->value()); request.insert("dry-run", dryRun());
m_session->sendRequest(request); m_session->sendRequest(request);
m_maxProgress = 0; m_maxProgress = 0;
@@ -137,7 +125,7 @@ void QbsInstallStep::handleProgress(int value)
} }
void QbsInstallStep::createTaskAndOutput(Task::TaskType type, const QString &message, void QbsInstallStep::createTaskAndOutput(Task::TaskType type, const QString &message,
const Utils::FilePath &file, int line) const FilePath &file, int line)
{ {
emit addOutput(message, OutputFormat::Stdout); emit addOutput(message, OutputFormat::Stdout);
emit addTask(CompileTask(type, message, file, line), 1); emit addTask(CompileTask(type, message, file, line), 1);
@@ -147,10 +135,10 @@ QbsBuildStepData QbsInstallStep::stepData() const
{ {
QbsBuildStepData data; QbsBuildStepData data;
data.command = "install"; data.command = "install";
data.dryRun = m_dryRun->value(); data.dryRun = dryRun();
data.keepGoing = m_keepGoing->value(); data.keepGoing = keepGoing();
data.noBuild = true; data.noBuild = true;
data.cleanInstallRoot = m_cleanInstallRoot->value(); data.cleanInstallRoot = cleanInstallRoot();
data.isInstallStep = true; data.isInstallStep = true;
auto bs = static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration())->qbsStep(); auto bs = static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration())->qbsStep();
if (bs) if (bs)
@@ -175,7 +163,7 @@ QWidget *QbsInstallStep::createConfigWidget()
using namespace Layouting; using namespace Layouting;
Form { Form {
Tr::tr("Install root:"), installRootValueLabel, br, Tr::tr("Install root:"), installRootValueLabel, br,
Tr::tr("Flags:"), m_dryRun, m_keepGoing, m_cleanInstallRoot, br, Tr::tr("Flags:"), dryRun, keepGoing, cleanInstallRoot, br,
commandLineKeyLabel, commandLineTextEdit commandLineKeyLabel, commandLineTextEdit
}.attachTo(widget); }.attachTo(widget);
@@ -187,9 +175,9 @@ QWidget *QbsInstallStep::createConfigWidget()
connect(target(), &Target::parsingFinished, this, updateState); connect(target(), &Target::parsingFinished, this, updateState);
connect(this, &ProjectConfiguration::displayNameChanged, this, updateState); connect(this, &ProjectConfiguration::displayNameChanged, this, updateState);
connect(m_dryRun, &BoolAspect::changed, this, updateState); connect(&dryRun, &BaseAspect::changed, this, updateState);
connect(m_keepGoing, &BoolAspect::changed, this, updateState); connect(&keepGoing, &BaseAspect::changed, this, updateState);
connect(m_cleanInstallRoot, &BoolAspect::changed, this, updateState); connect(&cleanInstallRoot, &BaseAspect::changed, this, updateState);
const QbsBuildConfiguration * const bc = buildConfig(); const QbsBuildConfiguration * const bc = buildConfig();
connect(bc, &QbsBuildConfiguration::qbsConfigurationChanged, this, updateState); connect(bc, &QbsBuildConfiguration::qbsConfigurationChanged, this, updateState);

View File

@@ -42,9 +42,9 @@ private:
void createTaskAndOutput(ProjectExplorer::Task::TaskType type, void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
const QString &message, const Utils::FilePath &file, int line); const QString &message, const Utils::FilePath &file, int line);
Utils::BoolAspect *m_cleanInstallRoot = nullptr; Utils::BoolAspect cleanInstallRoot{this};
Utils::BoolAspect *m_dryRun = nullptr; Utils::BoolAspect dryRun{this};
Utils::BoolAspect *m_keepGoing = nullptr; Utils::BoolAspect keepGoing{this};
QbsSession *m_session = nullptr; QbsSession *m_session = nullptr;
QString m_description; QString m_description;