Meson: Fully inline MesonBuildStepWidget

Next step in aspectification.

Change-Id: I9718d7ca763008fa040371d5b863b8604901adb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-08-26 12:15:31 +02:00
parent 472cae1823
commit cef1297504
6 changed files with 74 additions and 164 deletions

View File

@@ -65,8 +65,6 @@ add_qtc_plugin(MesonProjectManager
project/mesonbuildconfiguration.cpp
project/ninjabuildstep.h
project/ninjabuildstep.cpp
project/buildoptions/mesonbuildstepconfigwidget.h
project/buildoptions/mesonbuildstepconfigwidget.cpp
project/buildoptions/mesonbuildsettingswidget.ui
project/buildoptions/mesonbuildsettingswidget.h
project/buildoptions/mesonbuildsettingswidget.cpp

View File

@@ -24,7 +24,6 @@ HEADERS = \
project/buildoptions/optionsmodel/arrayoptionlineedit.h \
project/buildoptions/optionsmodel/buildoptionsmodel.h \
project/buildoptions/mesonbuildsettingswidget.h \
project/buildoptions/mesonbuildstepconfigwidget.h \
project/outputparsers/mesonoutputparser.h \
project/outputparsers/ninjaparser.h \
project/projecttree/mesonprojectnodes.h \
@@ -64,7 +63,6 @@ SOURCES = \
project/buildoptions/optionsmodel/arrayoptionlineedit.cpp \
project/buildoptions/optionsmodel/buildoptionsmodel.cpp \
project/buildoptions/mesonbuildsettingswidget.cpp \
project/buildoptions/mesonbuildstepconfigwidget.cpp \
project/outputparsers/mesonoutputparser.cpp \
project/outputparsers/ninjaparser.cpp \
project/projecttree/mesonprojectnodes.cpp \

View File

@@ -54,8 +54,6 @@ Project {
"project/buildoptions/mesonbuildsettingswidget.cpp",
"project/buildoptions/mesonbuildsettingswidget.h",
"project/buildoptions/mesonbuildsettingswidget.ui",
"project/buildoptions/mesonbuildstepconfigwidget.cpp",
"project/buildoptions/mesonbuildstepconfigwidget.h",
"project/buildoptions/optionsmodel/arrayoptionlineedit.cpp",
"project/buildoptions/optionsmodel/arrayoptionlineedit.h",
"project/buildoptions/optionsmodel/buildoptionsmodel.cpp",

View File

@@ -1,104 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 Alexis Jeandet.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "mesonbuildstepconfigwidget.h"
#include <mesonpluginconstants.h>
#include <coreplugin/find/itemviewfind.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/processparameters.h>
#include <QFormLayout>
#include <QRadioButton>
namespace MesonProjectManager {
namespace Internal {
MesonBuildStepConfigWidget::MesonBuildStepConfigWidget(NinjaBuildStep *step)
: ProjectExplorer::BuildStepConfigWidget{step}
, m_buildTargetsList{new QListWidget}
{
setDisplayName(tr("Build", "MesonProjectManager::MesonBuildStepConfigWidget display name."));
m_toolArguments = new QLineEdit(this);
m_buildTargetsList->setMinimumHeight(200);
m_buildTargetsList->setFrameShape(QFrame::StyledPanel);
m_buildTargetsList->setFrameShadow(QFrame::Raised);
auto wrapper = Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList,
Core::ItemViewFind::LightColored);
auto formLayout = new QFormLayout(this);
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
formLayout->setContentsMargins(0, 0, 0, 0);
formLayout->addRow(tr("Tool arguments:"), m_toolArguments);
formLayout->addRow(tr("Targets:"), wrapper);
updateDetails();
updateTargetList();
connect(step, &NinjaBuildStep::commandChanged, this, &MesonBuildStepConfigWidget::updateDetails);
connect(step,
&NinjaBuildStep::targetListChanged,
this,
&MesonBuildStepConfigWidget::updateTargetList);
connect(m_toolArguments, &QLineEdit::textEdited, this, [this](const QString &text) {
auto mesonBuildStep = static_cast<NinjaBuildStep *>(this->step());
mesonBuildStep->setCommandArgs(text);
updateDetails();
});
connect(m_buildTargetsList, &QListWidget::itemChanged, this, [this](QListWidgetItem *item) {
if (item->checkState() == Qt::Checked) {
mesonBuildStep()->setBuildTarget(item->data(Qt::UserRole).toString());
updateDetails();
}
});
}
void MesonBuildStepConfigWidget::updateDetails()
{
auto mesonBuildStep = static_cast<NinjaBuildStep *>(step());
ProjectExplorer::ProcessParameters param;
mesonBuildStep->setupProcessParameters(&param);
setSummaryText(param.summary(displayName()));
}
void MesonBuildStepConfigWidget::updateTargetList()
{
m_buildTargetsList->clear();
for (const auto &target : mesonBuildStep()->projectTargets()) {
auto item = new QListWidgetItem(m_buildTargetsList);
auto button = new QRadioButton(target);
connect(button, &QRadioButton::toggled, this, [this, target](bool toggled) {
if (toggled) {
mesonBuildStep()->setBuildTarget(target);
updateDetails();
}
});
button->setChecked(mesonBuildStep()->targetName() == target);
m_buildTargetsList->setItemWidget(item, button);
item->setData(Qt::UserRole, target);
}
}
} // namespace Internal
} // namespace MesonProjectManager

View File

@@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 Alexis Jeandet.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "../ninjabuildstep.h"
#include "projectexplorer/buildstep.h"
#include <QLineEdit>
#include <QListWidget>
#include <QWidget>
namespace MesonProjectManager {
namespace Internal {
class MesonBuildStepConfigWidget final : public ProjectExplorer::BuildStepConfigWidget
{
Q_DECLARE_TR_FUNCTIONS(MesonProjectManager::Internal::MesonBuildStepConfigWidget)
public:
explicit MesonBuildStepConfigWidget(NinjaBuildStep *step);
private:
void updateDetails();
void updateTargetList();
inline NinjaBuildStep *mesonBuildStep() { return static_cast<NinjaBuildStep *>(step()); }
QListWidget *m_buildTargetsList;
QLineEdit *m_toolArguments;
};
} // namespace Internal
} // namespace MesonProjectManager

View File

@@ -24,7 +24,7 @@
****************************************************************************/
#include "ninjabuildstep.h"
#include "buildoptions/mesonbuildstepconfigwidget.h"
#include "outputparsers/mesonoutputparser.h"
#include "mesonbuildconfiguration.h"
#include "mesonbuildsystem.h"
@@ -32,12 +32,20 @@
#include <settings/general/settings.h>
#include <settings/tools/kitaspect/ninjatoolkitaspect.h>
#include <coreplugin/find/itemviewfind.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <QFormLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QRadioButton>
using namespace ProjectExplorer;
using namespace Utils;
namespace MesonProjectManager {
@@ -63,9 +71,72 @@ NinjaBuildStep::NinjaBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id
&NinjaBuildStep::commandChanged);
}
ProjectExplorer::BuildStepConfigWidget *NinjaBuildStep::createConfigWidget()
BuildStepConfigWidget *NinjaBuildStep::createConfigWidget()
{
return new MesonBuildStepConfigWidget{this};
auto widget = new BuildStepConfigWidget{this};
widget->setDisplayName(tr("Build", "MesonProjectManager::MesonBuildStepConfigWidget display name."));
auto buildTargetsList = new QListWidget(widget);
buildTargetsList->setMinimumHeight(200);
buildTargetsList->setFrameShape(QFrame::StyledPanel);
buildTargetsList->setFrameShadow(QFrame::Raised);
auto toolArguments = new QLineEdit(widget);
auto wrapper = Core::ItemViewFind::createSearchableWrapper(buildTargetsList,
Core::ItemViewFind::LightColored);
auto formLayout = new QFormLayout(widget);
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
formLayout->setContentsMargins(0, 0, 0, 0);
formLayout->addRow(tr("Tool arguments:"), toolArguments);
formLayout->addRow(tr("Targets:"), wrapper);
auto updateDetails = [this, widget] {
ProcessParameters param;
setupProcessParameters(&param);
widget->setSummaryText(param.summary(displayName()));
};
auto updateTargetList = [this, buildTargetsList, updateDetails] {
buildTargetsList->clear();
for (const QString &target : projectTargets()) {
auto item = new QListWidgetItem(buildTargetsList);
auto button = new QRadioButton(target);
connect(button, &QRadioButton::toggled,
this, [this, target, updateDetails](bool toggled) {
if (toggled) {
setBuildTarget(target);
updateDetails();
}
});
button->setChecked(targetName() == target);
buildTargetsList->setItemWidget(item, button);
item->setData(Qt::UserRole, target);
}
};
updateDetails();
updateTargetList();
connect(this, &NinjaBuildStep::commandChanged, this, updateDetails);
connect(this, &NinjaBuildStep::targetListChanged, this, updateTargetList);
connect(toolArguments, &QLineEdit::textEdited, this, [this, updateDetails](const QString &text) {
setCommandArgs(text);
updateDetails();
});
connect(buildTargetsList, &QListWidget::itemChanged,
this, [this, updateDetails](QListWidgetItem *item) {
if (item->checkState() == Qt::Checked) {
setBuildTarget(item->data(Qt::UserRole).toString());
updateDetails();
}
});
return widget;
}
// --verbose is only supported since