Meson: Inline toolitemsettings.ui

Change-Id: Ib305c45354e63142587593401fda45d03d42d207
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-10-04 17:49:00 +02:00
parent bad664163f
commit a5803ae555
5 changed files with 44 additions and 81 deletions

View File

@@ -14,7 +14,6 @@ add_qtc_plugin(MesonProjectManager
settings/tools/toolssettingswidget.cpp settings/tools/toolssettingswidget.cpp
settings/tools/toolssettingspage.cpp settings/tools/toolssettingspage.cpp
settings/tools/toolssettingspage.h settings/tools/toolssettingspage.h
settings/tools/toolitemsettings.ui
settings/tools/toolitemsettings.cpp settings/tools/toolitemsettings.cpp
settings/tools/toolitemsettings.h settings/tools/toolitemsettings.h
settings/tools/tooltreeitem.cpp settings/tools/tooltreeitem.cpp

View File

@@ -88,7 +88,6 @@ Project {
"settings/tools/kitaspect/toolkitaspectwidget.h", "settings/tools/kitaspect/toolkitaspectwidget.h",
"settings/tools/toolitemsettings.cpp", "settings/tools/toolitemsettings.cpp",
"settings/tools/toolitemsettings.h", "settings/tools/toolitemsettings.h",
"settings/tools/toolitemsettings.ui",
"settings/tools/toolsmodel.cpp", "settings/tools/toolsmodel.cpp",
"settings/tools/toolsmodel.h", "settings/tools/toolsmodel.h",
"settings/tools/toolssettingsaccessor.cpp", "settings/tools/toolssettingsaccessor.cpp",

View File

@@ -4,38 +4,44 @@
#include "toolitemsettings.h" #include "toolitemsettings.h"
#include "tooltreeitem.h" #include "tooltreeitem.h"
#include "ui_toolitemsettings.h"
namespace MesonProjectManager { #include <utils/layoutbuilder.h>
namespace Internal { #include <utils/pathchooser.h>
#include <QLineEdit>
using namespace Utils;
namespace MesonProjectManager::Internal {
ToolItemSettings::ToolItemSettings(QWidget *parent) ToolItemSettings::ToolItemSettings(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::ToolItemSettings)
{ {
ui->setupUi(this); m_mesonNameLineEdit = new QLineEdit;
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() m_mesonPathChooser = new PathChooser;
{ m_mesonPathChooser->setExpectedKind(PathChooser::ExistingCommand);
delete ui; 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);
} }
void ToolItemSettings::load(ToolTreeItem *item) void ToolItemSettings::load(ToolTreeItem *item)
{ {
if (item) { if (item) {
m_currentId = std::nullopt; m_currentId = std::nullopt;
ui->mesonNameLineEdit->setDisabled(item->isAutoDetected()); m_mesonNameLineEdit->setDisabled(item->isAutoDetected());
ui->mesonNameLineEdit->setText(item->name()); m_mesonNameLineEdit->setText(item->name());
ui->mesonPathChooser->setDisabled(item->isAutoDetected()); m_mesonPathChooser->setDisabled(item->isAutoDetected());
ui->mesonPathChooser->setFilePath(item->executable()); m_mesonPathChooser->setFilePath(item->executable());
m_currentId = item->id(); m_currentId = item->id();
} else { } else {
m_currentId = std::nullopt; m_currentId = std::nullopt;
@@ -46,9 +52,8 @@ void ToolItemSettings::store()
{ {
if (m_currentId) if (m_currentId)
emit applyChanges(*m_currentId, emit applyChanges(*m_currentId,
ui->mesonNameLineEdit->text(), m_mesonNameLineEdit->text(),
ui->mesonPathChooser->filePath()); m_mesonPathChooser->filePath());
} }
} // namespace Internal } // MesonProjectManager::Internal
} // namespace MesonProjectManager

View File

@@ -4,16 +4,21 @@
#pragma once #pragma once
#include <utils/id.h> #include <utils/id.h>
#include <utils/fileutils.h>
#include <QWidget> #include <QWidget>
#include <optional> #include <optional>
namespace MesonProjectManager { QT_BEGIN_NAMESPACE
namespace Internal { class QLineEdit;
QT_END_NAMESPACE
namespace Ui { class ToolItemSettings; } namespace Utils {
class FilePath;
class PathChooser;
}
namespace MesonProjectManager::Internal {
class ToolTreeItem; class ToolTreeItem;
@@ -23,15 +28,16 @@ class ToolItemSettings : public QWidget
public: public:
explicit ToolItemSettings(QWidget *parent = nullptr); explicit ToolItemSettings(QWidget *parent = nullptr);
~ToolItemSettings();
void load(ToolTreeItem *item); void load(ToolTreeItem *item);
void store(); void store();
Q_SIGNAL void applyChanges(Utils::Id itemId, const QString &name, const Utils::FilePath &exe);
signals:
void applyChanges(Utils::Id itemId, const QString &name, const Utils::FilePath &exe);
private: private:
Ui::ToolItemSettings *ui;
std::optional<Utils::Id> m_currentId{std::nullopt}; std::optional<Utils::Id> m_currentId{std::nullopt};
QLineEdit *m_mesonNameLineEdit;
Utils::PathChooser *m_mesonPathChooser;
}; };
} // namespace Internal } // MesonProjectManager::Internal
} // namespace MesonProjectManager

View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MesonProjectManager::Internal::ToolItemSettings</class>
<widget class="QWidget" name="MesonProjectManager::Internal::ToolItemSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>70</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="_nameLbl">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mesonNameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="_pathLbl">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathChooser" name="mesonPathChooser" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>