forked from qt-creator/qt-creator
ProjectExplorer: Add a QTextEdit based variant for BaseStringAspect
... and use the QbsCleanStep as guinea pig. Change-Id: Ic0d62700bf48fc7971a290c90394c74b8860b9ff Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
QPointer<QLabel> m_labelDisplay;
|
QPointer<QLabel> m_labelDisplay;
|
||||||
QPointer<FancyLineEdit> m_lineEditDisplay;
|
QPointer<FancyLineEdit> m_lineEditDisplay;
|
||||||
QPointer<PathChooser> m_pathChooserDisplay;
|
QPointer<PathChooser> m_pathChooserDisplay;
|
||||||
|
QPointer<QTextEdit> m_textEditDisplay;
|
||||||
QPixmap m_labelPixmap;
|
QPixmap m_labelPixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -178,6 +180,8 @@ void BaseStringAspect::setPlaceHolderText(const QString &placeHolderText)
|
|||||||
d->m_placeHolderText = placeHolderText;
|
d->m_placeHolderText = placeHolderText;
|
||||||
if (d->m_lineEditDisplay)
|
if (d->m_lineEditDisplay)
|
||||||
d->m_lineEditDisplay->setPlaceholderText(placeHolderText);
|
d->m_lineEditDisplay->setPlaceholderText(placeHolderText);
|
||||||
|
if (d->m_textEditDisplay)
|
||||||
|
d->m_textEditDisplay->setPlaceholderText(placeHolderText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseStringAspect::setHistoryCompleter(const QString &historyCompleterKey)
|
void BaseStringAspect::setHistoryCompleter(const QString &historyCompleterKey)
|
||||||
@@ -234,6 +238,18 @@ void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout)
|
|||||||
this, &BaseStringAspect::setValue);
|
this, &BaseStringAspect::setValue);
|
||||||
hbox->addWidget(d->m_lineEditDisplay);
|
hbox->addWidget(d->m_lineEditDisplay);
|
||||||
break;
|
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:
|
case LabelDisplay:
|
||||||
d->m_labelDisplay = new QLabel(parent);
|
d->m_labelDisplay = new QLabel(parent);
|
||||||
d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
@@ -270,6 +286,11 @@ void BaseStringAspect::update()
|
|||||||
d->m_lineEditDisplay->setEnabled(enabled);
|
d->m_lineEditDisplay->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d->m_textEditDisplay) {
|
||||||
|
d->m_textEditDisplay->setText(displayedString);
|
||||||
|
d->m_textEditDisplay->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
if (d->m_labelDisplay)
|
if (d->m_labelDisplay)
|
||||||
d->m_labelDisplay->setText(displayedString);
|
d->m_labelDisplay->setText(displayedString);
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,12 @@ public:
|
|||||||
bool isChecked() const;
|
bool isChecked() const;
|
||||||
void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey);
|
void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey);
|
||||||
|
|
||||||
enum DisplayStyle { LabelDisplay, LineEditDisplay, PathChooserDisplay };
|
enum DisplayStyle {
|
||||||
|
LabelDisplay,
|
||||||
|
LineEditDisplay,
|
||||||
|
TextEditDisplay,
|
||||||
|
PathChooserDisplay
|
||||||
|
};
|
||||||
void setDisplayStyle(DisplayStyle style);
|
void setDisplayStyle(DisplayStyle style);
|
||||||
|
|
||||||
void fromMap(const QVariantMap &map) override;
|
void fromMap(const QVariantMap &map) override;
|
||||||
|
|||||||
@@ -29,8 +29,6 @@
|
|||||||
#include "qbsproject.h"
|
#include "qbsproject.h"
|
||||||
#include "qbsprojectmanagerconstants.h"
|
#include "qbsprojectmanagerconstants.h"
|
||||||
|
|
||||||
#include "ui_qbscleanstepconfigwidget.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
@@ -38,8 +36,7 @@
|
|||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
static const char QBS_DRY_RUN[] = "Qbs.DryRun";
|
using namespace ProjectExplorer;
|
||||||
static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
|
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -53,6 +50,27 @@ QbsCleanStep::QbsCleanStep(ProjectExplorer::BuildStepList *bsl) :
|
|||||||
{
|
{
|
||||||
setDisplayName(tr("Qbs Clean"));
|
setDisplayName(tr("Qbs Clean"));
|
||||||
setRunInGuiThread(true);
|
setRunInGuiThread(true);
|
||||||
|
|
||||||
|
m_dryRunAspect = addAspect<BaseBoolAspect>();
|
||||||
|
m_dryRunAspect->setSettingsKey("Qbs.DryRun");
|
||||||
|
m_dryRunAspect->setLabel(tr("Dry run"));
|
||||||
|
|
||||||
|
m_keepGoingAspect = addAspect<BaseBoolAspect>();
|
||||||
|
m_keepGoingAspect->setSettingsKey("Qbs.DryKeepGoing");
|
||||||
|
m_keepGoingAspect->setLabel(tr("Keep going"));
|
||||||
|
|
||||||
|
m_effectiveCommandAspect = addAspect<BaseStringAspect>();
|
||||||
|
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()
|
QbsCleanStep::~QbsCleanStep()
|
||||||
@@ -83,7 +101,9 @@ void QbsCleanStep::run(QFutureInterface<bool> &fi)
|
|||||||
m_fi = &fi;
|
m_fi = &fi;
|
||||||
|
|
||||||
auto pro = static_cast<QbsProject *>(project());
|
auto pro = static_cast<QbsProject *>(project());
|
||||||
qbs::CleanOptions options(m_qbsCleanOptions);
|
qbs::CleanOptions options;
|
||||||
|
options.setDryRun(m_dryRunAspect->value());
|
||||||
|
options.setKeepGoing(m_keepGoingAspect->value());
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
m_job = pro->clean(options, m_products, error);
|
m_job = pro->clean(options, m_products, error);
|
||||||
@@ -104,7 +124,11 @@ void QbsCleanStep::run(QFutureInterface<bool> &fi)
|
|||||||
|
|
||||||
ProjectExplorer::BuildStepConfigWidget *QbsCleanStep::createConfigWidget()
|
ProjectExplorer::BuildStepConfigWidget *QbsCleanStep::createConfigWidget()
|
||||||
{
|
{
|
||||||
return new QbsCleanStepConfigWidget(this);
|
auto w = BuildStep::createConfigWidget();
|
||||||
|
connect(this, &QbsCleanStep::stateChanged, w, [this, w] {
|
||||||
|
w->setSummaryText(tr("<b>Qbs:</b> %1").arg(m_effectiveCommandAspect->value()));
|
||||||
|
});
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsCleanStep::cancel()
|
void QbsCleanStep::cancel()
|
||||||
@@ -113,36 +137,6 @@ void QbsCleanStep::cancel()
|
|||||||
m_job->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)
|
void QbsCleanStep::cleaningDone(bool success)
|
||||||
{
|
{
|
||||||
// Report errors:
|
// Report errors:
|
||||||
@@ -172,6 +166,14 @@ void QbsCleanStep::handleProgress(int value)
|
|||||||
m_fi->setProgressValue(m_progressBase + value);
|
m_fi->setProgressValue(m_progressBase + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QbsCleanStep::updateState()
|
||||||
|
{
|
||||||
|
QString command = static_cast<QbsBuildConfiguration *>(buildConfiguration())
|
||||||
|
->equivalentCommandLine(this);
|
||||||
|
m_effectiveCommandAspect->setValue(command);
|
||||||
|
emit stateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line)
|
void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Task task = ProjectExplorer::Task(type, message,
|
ProjectExplorer::Task task = ProjectExplorer::Task(type, message,
|
||||||
@@ -181,75 +183,6 @@ void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, con
|
|||||||
emit addOutput(message, OutputFormat::Stdout);
|
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<QbsBuildConfiguration *>(m_step->buildConfiguration())
|
|
||||||
->equivalentCommandLine(m_step);
|
|
||||||
m_ui->commandLineTextEdit->setPlainText(command);
|
|
||||||
|
|
||||||
setSummaryText(tr("<b>Qbs:</b> %1").arg(command));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsCleanStepConfigWidget::changeDryRun(bool dr)
|
|
||||||
{
|
|
||||||
m_step->setDryRun(dr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsCleanStepConfigWidget::changeKeepGoing(bool kg)
|
|
||||||
{
|
|
||||||
m_step->setKeepGoing(kg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsCleanStepFactory:
|
// QbsCleanStepFactory:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "qbsbuildconfiguration.h"
|
#include "qbsbuildconfiguration.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
|
#include <projectexplorer/projectconfigurationaspects.h>
|
||||||
#include <projectexplorer/task.h>
|
#include <projectexplorer/task.h>
|
||||||
|
|
||||||
#include <qbs.h>
|
#include <qbs.h>
|
||||||
@@ -35,8 +36,6 @@
|
|||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QbsCleanStepConfigWidget;
|
|
||||||
|
|
||||||
class QbsCleanStep : public ProjectExplorer::BuildStep
|
class QbsCleanStep : public ProjectExplorer::BuildStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -52,27 +51,25 @@ public:
|
|||||||
|
|
||||||
void cancel() override;
|
void cancel() override;
|
||||||
|
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool dryRun() const { return m_dryRunAspect->value(); }
|
||||||
QVariantMap toMap() const override;
|
bool keepGoing() const { return m_keepGoingAspect->value(); }
|
||||||
|
|
||||||
bool dryRun() const;
|
|
||||||
bool keepGoing() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void stateChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cleaningDone(bool success);
|
void cleaningDone(bool success);
|
||||||
void handleTaskStarted(const QString &desciption, int max);
|
void handleTaskStarted(const QString &desciption, int max);
|
||||||
void handleProgress(int value);
|
void handleProgress(int value);
|
||||||
|
void updateState();
|
||||||
|
|
||||||
void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
|
void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
|
||||||
const QString &message, const QString &file, int line);
|
const QString &message, const QString &file, int line);
|
||||||
|
|
||||||
void setDryRun(bool dr);
|
ProjectExplorer::BaseBoolAspect *m_dryRunAspect = nullptr;
|
||||||
void setKeepGoing(bool kg);
|
ProjectExplorer::BaseBoolAspect *m_keepGoingAspect = nullptr;
|
||||||
|
ProjectExplorer::BaseStringAspect *m_effectiveCommandAspect = nullptr;
|
||||||
|
|
||||||
qbs::CleanOptions m_qbsCleanOptions;
|
|
||||||
QStringList m_products;
|
QStringList m_products;
|
||||||
|
|
||||||
QFutureInterface<bool> *m_fi = nullptr;
|
QFutureInterface<bool> *m_fi = nullptr;
|
||||||
@@ -80,28 +77,6 @@ private:
|
|||||||
int m_progressBase;
|
int m_progressBase;
|
||||||
bool m_showCompilerOutput = true;
|
bool m_showCompilerOutput = true;
|
||||||
ProjectExplorer::IOutputParser *m_parser = nullptr;
|
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
|
class QbsCleanStepFactory : public ProjectExplorer::BuildStepFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user