forked from qt-creator/qt-creator
Meson: Merge toolitemsettings.* into toolssettingspage.cpp
Change-Id: I69cc4032c6b5c8fc9e5c86753994781a4f65a35f Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -47,8 +47,6 @@ add_qtc_plugin(MesonProjectManager
|
||||
settings.cpp
|
||||
settings.h
|
||||
target.h
|
||||
toolitemsettings.cpp
|
||||
toolitemsettings.h
|
||||
toolkitaspectwidget.cpp
|
||||
toolkitaspectwidget.h
|
||||
toolsmodel.cpp
|
||||
|
@@ -65,8 +65,6 @@ Project {
|
||||
"settings.h",
|
||||
"toolkitaspectwidget.cpp",
|
||||
"toolkitaspectwidget.h",
|
||||
"toolitemsettings.cpp",
|
||||
"toolitemsettings.h",
|
||||
"toolsmodel.cpp",
|
||||
"toolsmodel.h",
|
||||
"toolssettingsaccessor.cpp",
|
||||
|
@@ -1,61 +0,0 @@
|
||||
// Copyright (C) 2020 Alexis Jeandet.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "toolitemsettings.h"
|
||||
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "toolsmodel.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
ToolItemSettings::ToolItemSettings(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_mesonNameLineEdit = new QLineEdit;
|
||||
|
||||
m_mesonPathChooser = new PathChooser;
|
||||
m_mesonPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||
m_mesonPathChooser->setHistoryCompleter("Meson.Command.History");
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
Form {
|
||||
Tr::tr("Name:"), m_mesonNameLineEdit, br,
|
||||
Tr::tr("Path:"), m_mesonPathChooser, br,
|
||||
noMargin
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_mesonPathChooser, &PathChooser::rawPathChanged, this, &ToolItemSettings::store);
|
||||
connect(m_mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store);
|
||||
}
|
||||
|
||||
void ToolItemSettings::load(ToolTreeItem *item)
|
||||
{
|
||||
if (item) {
|
||||
m_currentId = std::nullopt;
|
||||
m_mesonNameLineEdit->setDisabled(item->isAutoDetected());
|
||||
m_mesonNameLineEdit->setText(item->name());
|
||||
m_mesonPathChooser->setDisabled(item->isAutoDetected());
|
||||
m_mesonPathChooser->setFilePath(item->executable());
|
||||
m_currentId = item->id();
|
||||
} else {
|
||||
m_currentId = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void ToolItemSettings::store()
|
||||
{
|
||||
if (m_currentId)
|
||||
emit applyChanges(*m_currentId,
|
||||
m_mesonNameLineEdit->text(),
|
||||
m_mesonPathChooser->filePath());
|
||||
}
|
||||
|
||||
} // MesonProjectManager::Internal
|
@@ -1,43 +0,0 @@
|
||||
// Copyright (C) 2020 Alexis Jeandet.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class FilePath;
|
||||
class PathChooser;
|
||||
}
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
class ToolTreeItem;
|
||||
|
||||
class ToolItemSettings : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ToolItemSettings(QWidget *parent = nullptr);
|
||||
void load(ToolTreeItem *item);
|
||||
void store();
|
||||
|
||||
signals:
|
||||
void applyChanges(Utils::Id itemId, const QString &name, const Utils::FilePath &exe);
|
||||
|
||||
private:
|
||||
std::optional<Utils::Id> m_currentId{std::nullopt};
|
||||
QLineEdit *m_mesonNameLineEdit;
|
||||
Utils::PathChooser *m_mesonPathChooser;
|
||||
};
|
||||
|
||||
} // MesonProjectManager::Internal
|
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "toolitemsettings.h"
|
||||
#include "toolsmodel.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
@@ -21,6 +20,65 @@ using namespace Utils;
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
class ToolTreeItem;
|
||||
|
||||
class ToolItemSettings final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToolItemSettings()
|
||||
{
|
||||
m_mesonNameLineEdit = new QLineEdit;
|
||||
|
||||
m_mesonPathChooser = new PathChooser;
|
||||
m_mesonPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||
m_mesonPathChooser->setHistoryCompleter("Meson.Command.History");
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
Form {
|
||||
Tr::tr("Name:"), m_mesonNameLineEdit, br,
|
||||
Tr::tr("Path:"), m_mesonPathChooser, br,
|
||||
noMargin
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_mesonPathChooser, &PathChooser::rawPathChanged, this, &ToolItemSettings::store);
|
||||
connect(m_mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store);
|
||||
}
|
||||
|
||||
void load(ToolTreeItem *item)
|
||||
{
|
||||
if (item) {
|
||||
m_currentId = std::nullopt;
|
||||
m_mesonNameLineEdit->setDisabled(item->isAutoDetected());
|
||||
m_mesonNameLineEdit->setText(item->name());
|
||||
m_mesonPathChooser->setDisabled(item->isAutoDetected());
|
||||
m_mesonPathChooser->setFilePath(item->executable());
|
||||
m_currentId = item->id();
|
||||
} else {
|
||||
m_currentId = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void store()
|
||||
{
|
||||
if (m_currentId) {
|
||||
emit applyChanges(*m_currentId,
|
||||
m_mesonNameLineEdit->text(),
|
||||
m_mesonPathChooser->filePath());
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void applyChanges(Id itemId, const QString &name, const FilePath &exe);
|
||||
|
||||
private:
|
||||
std::optional<Id> m_currentId{std::nullopt};
|
||||
QLineEdit *m_mesonNameLineEdit;
|
||||
PathChooser *m_mesonPathChooser;
|
||||
};
|
||||
|
||||
class ToolsSettingsWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
@@ -138,3 +196,5 @@ void setupToolsSettingsPage()
|
||||
}
|
||||
|
||||
} // namespace MesonProjectManager
|
||||
|
||||
#include "toolssettingspage.moc"
|
||||
|
Reference in New Issue
Block a user