2020-05-01 18:20:56 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
2020-10-29 10:20:14 +01:00
|
|
|
|
|
|
|
|
#include "mesonbuildsettingswidget.h"
|
|
|
|
|
|
|
|
|
|
#include "../mesonbuildconfiguration.h"
|
|
|
|
|
#include "../mesonbuildsystem.h"
|
|
|
|
|
#include "ui_mesonbuildsettingswidget.h"
|
|
|
|
|
|
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>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
2020-09-18 12:11:40 +02:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
MesonBuildSettingsWidget::MesonBuildSettingsWidget(MesonBuildConfiguration *buildCfg)
|
|
|
|
|
: ProjectExplorer::NamedWidget{tr("Meson")}
|
|
|
|
|
, ui{new Ui::MesonBuildSettingsWidget}
|
|
|
|
|
, m_progressIndicator(Utils::ProgressIndicatorSize::Large)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
ui->container->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
ui->container->setWidget(ui->details);
|
2020-09-18 12:11:40 +02:00
|
|
|
LayoutBuilder buildDirWBuilder{ui->buildDirWidget};
|
2020-05-01 18:20:56 +02:00
|
|
|
auto buildDirAspect = buildCfg->buildDirectoryAspect();
|
|
|
|
|
buildDirAspect->addToLayout(buildDirWBuilder);
|
|
|
|
|
|
2021-01-02 20:14:56 +02:00
|
|
|
ui->parametersLineEdit->setText(buildCfg->parameters());
|
2020-05-01 18:20:56 +02:00
|
|
|
ui->optionsFilterLineEdit->setFiltering(true);
|
|
|
|
|
|
|
|
|
|
ui->optionsTreeView->sortByColumn(0, Qt::AscendingOrder);
|
|
|
|
|
|
|
|
|
|
QFrame *findWrapper
|
|
|
|
|
= Core::ItemViewFind::createSearchableWrapper(ui->optionsTreeView,
|
|
|
|
|
Core::ItemViewFind::LightColored);
|
|
|
|
|
findWrapper->setFrameStyle(QFrame::StyledPanel);
|
|
|
|
|
m_progressIndicator.attachToWidget(findWrapper);
|
|
|
|
|
m_progressIndicator.raise();
|
|
|
|
|
m_progressIndicator.hide();
|
|
|
|
|
ui->details->layout()->addWidget(findWrapper);
|
|
|
|
|
|
|
|
|
|
m_showProgressTimer.setSingleShot(true);
|
|
|
|
|
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
|
|
|
|
|
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator.show(); });
|
|
|
|
|
connect(&m_optionsModel, &BuidOptionsModel::configurationChanged, this, [this]() {
|
|
|
|
|
ui->configureButton->setEnabled(true);
|
|
|
|
|
});
|
|
|
|
|
m_optionsFilter.setSourceModel(&m_optionsModel);
|
|
|
|
|
m_optionsFilter.setSortRole(Qt::DisplayRole);
|
|
|
|
|
m_optionsFilter.setFilterKeyColumn(-1);
|
|
|
|
|
|
|
|
|
|
ui->optionsTreeView->setModel(&m_optionsFilter);
|
|
|
|
|
|
|
|
|
|
ui->optionsTreeView->setItemDelegate(new BuildOptionDelegate{ui->optionsTreeView});
|
|
|
|
|
MesonBuildSystem *bs = static_cast<MesonBuildSystem *>(buildCfg->buildSystem());
|
|
|
|
|
connect(buildCfg->target(),
|
|
|
|
|
&ProjectExplorer::Target::parsingFinished,
|
|
|
|
|
this,
|
|
|
|
|
[this, bs](bool success) {
|
|
|
|
|
if (success) {
|
|
|
|
|
m_optionsModel.setConfiguration(bs->buildOptions());
|
|
|
|
|
} else {
|
|
|
|
|
m_optionsModel.clear();
|
|
|
|
|
}
|
|
|
|
|
ui->optionsTreeView->expandAll();
|
|
|
|
|
ui->optionsTreeView->resizeColumnToContents(0);
|
|
|
|
|
ui->optionsTreeView->setEnabled(true);
|
|
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator.hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(bs, &MesonBuildSystem::parsingStarted, this, [this]() {
|
|
|
|
|
if (!m_showProgressTimer.isActive()) {
|
|
|
|
|
ui->optionsTreeView->setEnabled(false);
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(&m_optionsModel, &BuidOptionsModel::dataChanged, this, [bs, this]() {
|
|
|
|
|
bs->setMesonConfigArgs(this->m_optionsModel.changesAsMesonArgs());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(&m_optionsFilter, &QAbstractItemModel::modelReset, this, [this]() {
|
|
|
|
|
ui->optionsTreeView->expandAll();
|
|
|
|
|
ui->optionsTreeView->resizeColumnToContents(0);
|
|
|
|
|
});
|
|
|
|
|
connect(ui->optionsFilterLineEdit,
|
|
|
|
|
&QLineEdit::textChanged,
|
|
|
|
|
&m_optionsFilter,
|
2020-06-22 12:22:11 +02:00
|
|
|
[this](const QString &txt) {
|
|
|
|
|
m_optionsFilter.setFilterRegularExpression(
|
|
|
|
|
QRegularExpression(QRegularExpression::escape(txt),
|
|
|
|
|
QRegularExpression::CaseInsensitiveOption));
|
|
|
|
|
});
|
2020-05-01 18:20:56 +02:00
|
|
|
connect(ui->optionsTreeView,
|
|
|
|
|
&Utils::TreeView::activated,
|
|
|
|
|
ui->optionsTreeView,
|
|
|
|
|
[tree = ui->optionsTreeView](const QModelIndex &idx) { tree->edit(idx); });
|
|
|
|
|
connect(ui->configureButton, &QPushButton::clicked, [bs, this]() {
|
|
|
|
|
ui->optionsTreeView->setEnabled(false);
|
|
|
|
|
ui->configureButton->setEnabled(false);
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
bs->configure();
|
|
|
|
|
});
|
|
|
|
|
connect(ui->wipeButton, &QPushButton::clicked, [bs, this]() {
|
|
|
|
|
ui->optionsTreeView->setEnabled(false);
|
|
|
|
|
ui->configureButton->setEnabled(false);
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
bs->wipe();
|
|
|
|
|
});
|
2021-01-02 20:14:56 +02:00
|
|
|
connect(ui->parametersLineEdit, &QLineEdit::editingFinished, this, [this, buildCfg] {
|
|
|
|
|
buildCfg->setParameters(ui->parametersLineEdit->text());
|
|
|
|
|
});
|
2020-05-01 18:20:56 +02:00
|
|
|
bs->triggerParsing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesonBuildSettingsWidget::~MesonBuildSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|