2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-10-29 10:20:14 +01:00
|
|
|
|
|
|
|
|
#include "mesonbuildsettingswidget.h"
|
|
|
|
|
|
2022-10-06 16:58:18 +02:00
|
|
|
#include "mesonbuildconfiguration.h"
|
|
|
|
|
#include "mesonbuildsystem.h"
|
2022-10-10 09:14:04 +02:00
|
|
|
#include "mesonprojectmanagertr.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <projectexplorer/buildaspects.h>
|
|
|
|
|
#include <projectexplorer/projectconfiguration.h>
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/headerviewstretcher.h>
|
2022-10-04 18:10:24 +02:00
|
|
|
#include <utils/itemviews.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2022-10-04 18:10:24 +02:00
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
#include <QLayout>
|
|
|
|
|
#include <QPushButton>
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
namespace MesonProjectManager::Internal {
|
2020-09-18 12:11:40 +02:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
MesonBuildSettingsWidget::MesonBuildSettingsWidget(MesonBuildConfiguration *buildCfg)
|
2022-10-10 09:14:04 +02:00
|
|
|
: ProjectExplorer::NamedWidget(Tr::tr("Meson"))
|
2022-10-04 18:10:24 +02:00
|
|
|
, m_progressIndicator(ProgressIndicatorSize::Large)
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
2022-10-10 09:14:04 +02:00
|
|
|
auto configureButton = new QPushButton(Tr::tr("Apply Configuration Changes"));
|
2022-10-04 18:10:24 +02:00
|
|
|
configureButton->setEnabled(false);
|
|
|
|
|
configureButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
|
|
|
|
|
2022-10-10 09:14:04 +02:00
|
|
|
auto wipeButton = new QPushButton(Tr::tr("Wipe Project"));
|
2022-10-04 18:10:24 +02:00
|
|
|
wipeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
|
|
|
|
wipeButton->setIcon(Utils::Icons::WARNING.icon());
|
2022-10-10 09:14:04 +02:00
|
|
|
wipeButton->setToolTip(Tr::tr("Wipes build directory and reconfigures using previous command "
|
|
|
|
|
"line options.\nUseful if build directory is corrupted or when "
|
|
|
|
|
"rebuilding with a newer version of Meson."));
|
2022-10-04 18:10:24 +02:00
|
|
|
|
|
|
|
|
auto container = new DetailsWidget;
|
|
|
|
|
|
|
|
|
|
auto details = new QWidget;
|
|
|
|
|
|
|
|
|
|
container->setState(DetailsWidget::NoSummary);
|
|
|
|
|
container->setWidget(details);
|
|
|
|
|
|
|
|
|
|
auto parametersLineEdit = new QLineEdit;
|
|
|
|
|
|
|
|
|
|
auto buildDirWidget = new QWidget;
|
|
|
|
|
|
|
|
|
|
auto optionsFilterLineEdit = new FancyLineEdit;
|
|
|
|
|
|
|
|
|
|
auto optionsTreeView = new TreeView;
|
|
|
|
|
optionsTreeView->setMinimumHeight(300);
|
|
|
|
|
optionsTreeView->setFrameShape(QFrame::NoFrame);
|
|
|
|
|
optionsTreeView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
|
|
|
|
optionsTreeView->setUniformRowHeights(true);
|
|
|
|
|
optionsTreeView->setSortingEnabled(true);
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
2021-03-11 19:02:42 +01:00
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
Column {
|
2022-10-10 09:14:04 +02:00
|
|
|
Form { Tr::tr("Parameters"), parametersLineEdit, br, },
|
2022-10-04 18:10:24 +02:00
|
|
|
buildDirWidget,
|
|
|
|
|
optionsFilterLineEdit,
|
|
|
|
|
optionsTreeView,
|
|
|
|
|
}.attachTo(details, WithoutMargins);
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
container,
|
|
|
|
|
Row { configureButton, wipeButton, }
|
|
|
|
|
}.attachTo(this, WithoutMargins);
|
|
|
|
|
|
|
|
|
|
Form buildDirWBuilder;
|
2021-03-11 19:02:42 +01:00
|
|
|
buildCfg->buildDirectoryAspect()->addToLayout(buildDirWBuilder);
|
2022-10-04 18:10:24 +02:00
|
|
|
buildDirWBuilder.attachTo(buildDirWidget, WithoutMargins);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
parametersLineEdit->setText(buildCfg->parameters());
|
|
|
|
|
optionsFilterLineEdit->setFiltering(true);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
optionsTreeView->sortByColumn(0, Qt::AscendingOrder);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
QFrame *findWrapper
|
2022-10-04 18:10:24 +02:00
|
|
|
= Core::ItemViewFind::createSearchableWrapper(optionsTreeView,
|
2020-05-01 18:20:56 +02:00
|
|
|
Core::ItemViewFind::LightColored);
|
|
|
|
|
findWrapper->setFrameStyle(QFrame::StyledPanel);
|
|
|
|
|
m_progressIndicator.attachToWidget(findWrapper);
|
|
|
|
|
m_progressIndicator.raise();
|
|
|
|
|
m_progressIndicator.hide();
|
2022-10-04 18:10:24 +02:00
|
|
|
details->layout()->addWidget(findWrapper);
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
m_showProgressTimer.setSingleShot(true);
|
|
|
|
|
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
|
|
|
|
|
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator.show(); });
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(&m_optionsModel, &BuidOptionsModel::configurationChanged, this, [configureButton] {
|
|
|
|
|
configureButton->setEnabled(true);
|
2020-05-01 18:20:56 +02:00
|
|
|
});
|
|
|
|
|
m_optionsFilter.setSourceModel(&m_optionsModel);
|
|
|
|
|
m_optionsFilter.setSortRole(Qt::DisplayRole);
|
|
|
|
|
m_optionsFilter.setFilterKeyColumn(-1);
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
optionsTreeView->setModel(&m_optionsFilter);
|
|
|
|
|
optionsTreeView->setItemDelegate(new BuildOptionDelegate{optionsTreeView});
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
MesonBuildSystem *bs = static_cast<MesonBuildSystem *>(buildCfg->buildSystem());
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(buildCfg->target(), &ProjectExplorer::Target::parsingFinished,
|
|
|
|
|
this, [this, bs, optionsTreeView](bool success) {
|
2020-05-01 18:20:56 +02:00
|
|
|
if (success) {
|
|
|
|
|
m_optionsModel.setConfiguration(bs->buildOptions());
|
|
|
|
|
} else {
|
|
|
|
|
m_optionsModel.clear();
|
|
|
|
|
}
|
2022-10-04 18:10:24 +02:00
|
|
|
optionsTreeView->expandAll();
|
|
|
|
|
optionsTreeView->resizeColumnToContents(0);
|
|
|
|
|
optionsTreeView->setEnabled(true);
|
2020-05-01 18:20:56 +02:00
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator.hide();
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(bs, &MesonBuildSystem::parsingStarted, this, [this, optionsTreeView] {
|
2020-05-01 18:20:56 +02:00
|
|
|
if (!m_showProgressTimer.isActive()) {
|
2022-10-04 18:10:24 +02:00
|
|
|
optionsTreeView->setEnabled(false);
|
2020-05-01 18:20:56 +02:00
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(&m_optionsModel, &BuidOptionsModel::dataChanged, this, [bs, this] {
|
2020-05-01 18:20:56 +02:00
|
|
|
bs->setMesonConfigArgs(this->m_optionsModel.changesAsMesonArgs());
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(&m_optionsFilter, &QAbstractItemModel::modelReset, this, [optionsTreeView] {
|
|
|
|
|
optionsTreeView->expandAll();
|
|
|
|
|
optionsTreeView->resizeColumnToContents(0);
|
2020-05-01 18:20:56 +02:00
|
|
|
});
|
2022-10-04 18:10:24 +02:00
|
|
|
|
|
|
|
|
connect(optionsFilterLineEdit, &QLineEdit::textChanged, &m_optionsFilter, [this](const QString &txt) {
|
|
|
|
|
m_optionsFilter.setFilterRegularExpression(
|
|
|
|
|
QRegularExpression(QRegularExpression::escape(txt),
|
|
|
|
|
QRegularExpression::CaseInsensitiveOption));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(optionsTreeView,
|
2020-05-01 18:20:56 +02:00
|
|
|
&Utils::TreeView::activated,
|
2022-10-04 18:10:24 +02:00
|
|
|
optionsTreeView,
|
|
|
|
|
[tree = optionsTreeView](const QModelIndex &idx) { tree->edit(idx); });
|
|
|
|
|
|
|
|
|
|
connect(configureButton, &QPushButton::clicked, [this, bs, configureButton, optionsTreeView] {
|
|
|
|
|
optionsTreeView->setEnabled(false);
|
|
|
|
|
configureButton->setEnabled(false);
|
2020-05-01 18:20:56 +02:00
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
bs->configure();
|
|
|
|
|
});
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(wipeButton, &QPushButton::clicked, [this, bs, configureButton, optionsTreeView] {
|
|
|
|
|
optionsTreeView->setEnabled(false);
|
|
|
|
|
configureButton->setEnabled(false);
|
2020-05-01 18:20:56 +02:00
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
bs->wipe();
|
|
|
|
|
});
|
2022-10-04 18:10:24 +02:00
|
|
|
connect(parametersLineEdit, &QLineEdit::editingFinished, this, [ buildCfg, parametersLineEdit] {
|
|
|
|
|
buildCfg->setParameters(parametersLineEdit->text());
|
2021-01-02 20:14:56 +02:00
|
|
|
});
|
2020-05-01 18:20:56 +02:00
|
|
|
bs->triggerParsing();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
MesonBuildSettingsWidget::~MesonBuildSettingsWidget() = default;
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-10-04 18:10:24 +02:00
|
|
|
} // MesonProjectManager::Internal
|