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-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
#include "toolitemsettings.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include "tooltreeitem.h"
|
|
|
|
|
|
2022-10-04 17:49:00 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace MesonProjectManager::Internal {
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
ToolItemSettings::ToolItemSettings(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
2022-10-04 17:49:00 +02:00
|
|
|
m_mesonNameLineEdit = new QLineEdit;
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2022-10-04 17:49:00 +02:00
|
|
|
m_mesonPathChooser = new PathChooser;
|
|
|
|
|
m_mesonPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_mesonPathChooser->setHistoryCompleter(QLatin1String("Meson.Command.History"));
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
Form {
|
|
|
|
|
tr("Name:"), m_mesonNameLineEdit, br,
|
|
|
|
|
tr("Path:"), m_mesonPathChooser, br,
|
|
|
|
|
}.attachTo(this, WithoutMargins);
|
|
|
|
|
|
|
|
|
|
connect(m_mesonPathChooser, &PathChooser::rawPathChanged, this, &ToolItemSettings::store);
|
|
|
|
|
connect(m_mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store);
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolItemSettings::load(ToolTreeItem *item)
|
|
|
|
|
{
|
|
|
|
|
if (item) {
|
2022-08-26 10:30:00 +02:00
|
|
|
m_currentId = std::nullopt;
|
2022-10-04 17:49:00 +02:00
|
|
|
m_mesonNameLineEdit->setDisabled(item->isAutoDetected());
|
|
|
|
|
m_mesonNameLineEdit->setText(item->name());
|
|
|
|
|
m_mesonPathChooser->setDisabled(item->isAutoDetected());
|
|
|
|
|
m_mesonPathChooser->setFilePath(item->executable());
|
2020-05-01 18:20:56 +02:00
|
|
|
m_currentId = item->id();
|
|
|
|
|
} else {
|
2022-08-26 10:30:00 +02:00
|
|
|
m_currentId = std::nullopt;
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolItemSettings::store()
|
|
|
|
|
{
|
|
|
|
|
if (m_currentId)
|
|
|
|
|
emit applyChanges(*m_currentId,
|
2022-10-04 17:49:00 +02:00
|
|
|
m_mesonNameLineEdit->text(),
|
|
|
|
|
m_mesonPathChooser->filePath());
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-04 17:49:00 +02:00
|
|
|
} // MesonProjectManager::Internal
|