Qbs: Inline qbsinstallstepconfigwidget.ui

Prelimimary step towards aspectification.

Change-Id: I3ce6e3ca3ecd3fbb858525a533202af2fd0e6ff5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-25 18:37:49 +02:00
parent 32bbf2a3b3
commit 7ebfa87dc2
6 changed files with 90 additions and 180 deletions

View File

@@ -17,7 +17,6 @@ add_qtc_plugin(QbsProjectManager
qbscleanstep.cpp qbscleanstep.h
qbscleanstepconfigwidget.ui
qbsinstallstep.cpp qbsinstallstep.h
qbsinstallstepconfigwidget.ui
qbskitinformation.cpp qbskitinformation.h
qbslogsink.cpp qbslogsink.h
qbsnodes.cpp qbsnodes.h

View File

@@ -30,8 +30,6 @@
#include "qbsproject.h"
#include "qbsprojectmanagerconstants.h"
#include "ui_qbsinstallstepconfigwidget.h"
#include <coreplugin/icore.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h>
@@ -40,7 +38,14 @@
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <QCheckBox>
#include <QFileInfo>
#include <QFormLayout>
#include <QLabel>
#include <QPlainTextEdit>
#include <QSpacerItem>
using namespace ProjectExplorer;
// --------------------------------------------------------------------
// Constants:
@@ -53,6 +58,29 @@ static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
namespace QbsProjectManager {
namespace Internal {
class QbsInstallStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
public:
QbsInstallStepConfigWidget(QbsInstallStep *step);
private:
void updateState();
void changeRemoveFirst(bool rf) { m_step->setRemoveFirst(rf); }
void changeDryRun(bool dr) { m_step->setDryRun(dr); }
void changeKeepGoing(bool kg) { m_step->setKeepGoing(kg); }
private:
QbsInstallStep *m_step;
bool m_ignoreChange;
QCheckBox *m_dryRunCheckBox;
QCheckBox *m_keepGoingCheckBox;
QCheckBox *m_removeFirstCheckBox;
QPlainTextEdit *m_commandLineTextEdit;
QLabel *m_installRootValueLabel;
};
// --------------------------------------------------------------------
// QbsInstallStep:
// --------------------------------------------------------------------
@@ -248,60 +276,88 @@ QbsInstallStepConfigWidget::QbsInstallStepConfigWidget(QbsInstallStep *step) :
setContentsMargins(0, 0, 0, 0);
auto project = static_cast<QbsProject *>(m_step->project());
auto installRootLabel = new QLabel(this);
m_ui = new Ui::QbsInstallStepConfigWidget;
m_ui->setupUi(this);
auto flagsLabel = new QLabel(this);
connect(m_ui->removeFirstCheckBox, &QAbstractButton::toggled,
m_dryRunCheckBox = new QCheckBox(this);
m_keepGoingCheckBox = new QCheckBox(this);
m_removeFirstCheckBox = new QCheckBox(this);
auto horizontalLayout = new QHBoxLayout();
horizontalLayout->addWidget(m_dryRunCheckBox);
horizontalLayout->addWidget(m_keepGoingCheckBox);
horizontalLayout->addWidget(m_removeFirstCheckBox);
horizontalLayout->addStretch(1);
auto commandLineKeyLabel = new QLabel(this);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(commandLineKeyLabel->sizePolicy().hasHeightForWidth());
commandLineKeyLabel->setSizePolicy(sizePolicy);
commandLineKeyLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
m_commandLineTextEdit = new QPlainTextEdit(this);
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(m_commandLineTextEdit->sizePolicy().hasHeightForWidth());
m_commandLineTextEdit->setSizePolicy(sizePolicy1);
m_commandLineTextEdit->setReadOnly(true);
m_commandLineTextEdit->setTextInteractionFlags(Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);
m_installRootValueLabel = new QLabel(this);
auto formLayout = new QFormLayout(this);
formLayout->setWidget(0, QFormLayout::LabelRole, installRootLabel);
formLayout->setWidget(0, QFormLayout::FieldRole, m_installRootValueLabel);
formLayout->setWidget(1, QFormLayout::LabelRole, flagsLabel);
formLayout->setLayout(1, QFormLayout::FieldRole, horizontalLayout);
formLayout->setWidget(2, QFormLayout::LabelRole, commandLineKeyLabel);
formLayout->setWidget(2, QFormLayout::FieldRole, m_commandLineTextEdit);
QWidget::setTabOrder(m_dryRunCheckBox, m_keepGoingCheckBox);
QWidget::setTabOrder(m_keepGoingCheckBox, m_removeFirstCheckBox);
QWidget::setTabOrder(m_removeFirstCheckBox, m_commandLineTextEdit);
installRootLabel->setText(QbsInstallStep::tr("Install root:"));
flagsLabel->setText(QbsInstallStep::tr("Flags:"));
m_dryRunCheckBox->setText(QbsInstallStep::tr("Dry run"));
m_keepGoingCheckBox->setText(QbsInstallStep::tr("Keep going"));
m_removeFirstCheckBox->setText(QbsInstallStep::tr("Remove first"));
commandLineKeyLabel->setText(QbsInstallStep::tr("Equivalent command line:"));
m_installRootValueLabel->setText(QString());
connect(m_removeFirstCheckBox, &QAbstractButton::toggled,
this, &QbsInstallStepConfigWidget::changeRemoveFirst);
connect(m_ui->dryRunCheckBox, &QAbstractButton::toggled,
connect(m_dryRunCheckBox, &QAbstractButton::toggled,
this, &QbsInstallStepConfigWidget::changeDryRun);
connect(m_ui->keepGoingCheckBox, &QAbstractButton::toggled,
connect(m_keepGoingCheckBox, &QAbstractButton::toggled,
this, &QbsInstallStepConfigWidget::changeKeepGoing);
connect(project, &ProjectExplorer::Project::parsingFinished,
connect(m_step->project(), &Project::parsingFinished,
this, &QbsInstallStepConfigWidget::updateState);
updateState();
}
QbsInstallStepConfigWidget::~QbsInstallStepConfigWidget()
{
delete m_ui;
}
void QbsInstallStepConfigWidget::updateState()
{
if (!m_ignoreChange) {
m_ui->installRootValueLabel->setText(m_step->installRoot());
m_ui->removeFirstCheckBox->setChecked(m_step->removeFirst());
m_ui->dryRunCheckBox->setChecked(m_step->dryRun());
m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing());
m_installRootValueLabel->setText(m_step->installRoot());
m_removeFirstCheckBox->setChecked(m_step->removeFirst());
m_dryRunCheckBox->setChecked(m_step->dryRun());
m_keepGoingCheckBox->setChecked(m_step->keepGoing());
}
QString command = m_step->buildConfig()->equivalentCommandLine(m_step);
m_ui->commandLineTextEdit->setPlainText(command);
m_commandLineTextEdit->setPlainText(command);
setSummaryText(tr("<b>Qbs:</b> %1").arg(command));
}
void QbsInstallStepConfigWidget::changeRemoveFirst(bool rf)
{
m_step->setRemoveFirst(rf);
}
void QbsInstallStepConfigWidget::changeDryRun(bool dr)
{
m_step->setDryRun(dr);
}
void QbsInstallStepConfigWidget::changeKeepGoing(bool kg)
{
m_step->setKeepGoing(kg);
}
// --------------------------------------------------------------------
// QbsInstallStepFactory:
// --------------------------------------------------------------------

View File

@@ -35,8 +35,6 @@
namespace QbsProjectManager {
namespace Internal {
class QbsInstallStepConfigWidget;
class QbsInstallStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
@@ -86,29 +84,6 @@ private:
friend class QbsInstallStepConfigWidget;
};
namespace Ui { class QbsInstallStepConfigWidget; }
class QbsInstallStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
QbsInstallStepConfigWidget(QbsInstallStep *step);
~QbsInstallStepConfigWidget() override;
private:
void updateState();
void changeRemoveFirst(bool rf);
void changeDryRun(bool dr);
void changeKeepGoing(bool kg);
private:
Ui::QbsInstallStepConfigWidget *m_ui;
QbsInstallStep *m_step;
bool m_ignoreChange;
};
class QbsInstallStepFactory : public ProjectExplorer::BuildStepFactory
{
public:

View File

@@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QbsProjectManager::Internal::QbsInstallStepConfigWidget</class>
<widget class="QWidget" name="QbsProjectManager::Internal::QbsInstallStepConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>146</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="installRootLabel">
<property name="text">
<string>Install root:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="flagsLabel">
<property name="text">
<string>Flags:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="dryRunCheckBox">
<property name="text">
<string>Dry run</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="keepGoingCheckBox">
<property name="text">
<string>Keep going</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="removeFirstCheckBox">
<property name="text">
<string>Remove first</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="commandLineKeyLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Equivalent command line:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPlainTextEdit" name="commandLineTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string notr="true"/>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="installRootValueLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>dryRunCheckBox</tabstop>
<tabstop>keepGoingCheckBox</tabstop>
<tabstop>removeFirstCheckBox</tabstop>
<tabstop>commandLineTextEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -66,7 +66,6 @@ FORMS = \
customqbspropertiesdialog.ui \
qbsbuildstepconfigwidget.ui \
qbscleanstepconfigwidget.ui \
qbsinstallstepconfigwidget.ui \
qbsprofilessettingswidget.ui
RESOURCES += \

View File

@@ -74,7 +74,6 @@ QtcPlugin {
"qbscleanstepconfigwidget.ui",
"qbsinstallstep.cpp",
"qbsinstallstep.h",
"qbsinstallstepconfigwidget.ui",
"qbskitinformation.cpp",
"qbskitinformation.h",
"qbslogsink.cpp",