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"
|
|
|
|
|
#include "ui_toolitemsettings.h"
|
|
|
|
|
|
|
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
ToolItemSettings::ToolItemSettings(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, ui(new Ui::ToolItemSettings)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
ui->mesonPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
|
|
|
ui->mesonPathChooser->setHistoryCompleter(QLatin1String("Meson.Command.History"));
|
|
|
|
|
connect(ui->mesonPathChooser,
|
|
|
|
|
&Utils::PathChooser::rawPathChanged,
|
|
|
|
|
this,
|
|
|
|
|
&ToolItemSettings::store);
|
|
|
|
|
connect(ui->mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolItemSettings::~ToolItemSettings()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolItemSettings::load(ToolTreeItem *item)
|
|
|
|
|
{
|
|
|
|
|
if (item) {
|
2022-08-26 10:30:00 +02:00
|
|
|
m_currentId = std::nullopt;
|
2020-05-01 18:20:56 +02:00
|
|
|
ui->mesonNameLineEdit->setDisabled(item->isAutoDetected());
|
|
|
|
|
ui->mesonNameLineEdit->setText(item->name());
|
|
|
|
|
ui->mesonPathChooser->setDisabled(item->isAutoDetected());
|
2021-03-15 10:31:40 +01:00
|
|
|
ui->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,
|
|
|
|
|
ui->mesonNameLineEdit->text(),
|
2020-06-26 09:09:04 +02:00
|
|
|
ui->mesonPathChooser->filePath());
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|