forked from qt-creator/qt-creator
Meson: Hide the tool aspect implementation
Change-Id: Ib8cf56385d7e369a2c185d6cbd62613b4b28bc79 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -35,8 +35,6 @@ add_qtc_plugin(MesonProjectManager
|
||||
mesonprojectplugin.cpp
|
||||
mesonrunconfiguration.cpp
|
||||
mesonrunconfiguration.h
|
||||
mesontoolkitaspect.cpp
|
||||
mesontoolkitaspect.h
|
||||
mesontools.cpp
|
||||
mesontools.h
|
||||
mesonwrapper.cpp
|
||||
@@ -45,8 +43,6 @@ add_qtc_plugin(MesonProjectManager
|
||||
ninjabuildstep.h
|
||||
ninjaparser.cpp
|
||||
ninjaparser.h
|
||||
ninjatoolkitaspect.cpp
|
||||
ninjatoolkitaspect.h
|
||||
ninjawrapper.h
|
||||
projecttree.cpp
|
||||
projecttree.h
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "kitdata.h"
|
||||
#include "mesonbuildconfiguration.h"
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "mesontoolkitaspect.h"
|
||||
#include "settings.h"
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#define LEAVE_IF_BUSY() \
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "mesontoolkitaspect.h"
|
||||
#include "ninjatoolkitaspect.h"
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
|
||||
@@ -68,10 +68,6 @@ Project {
|
||||
"resources_meson.qrc",
|
||||
"settings.cpp",
|
||||
"settings.h",
|
||||
"mesontoolkitaspect.cpp",
|
||||
"mesontoolkitaspect.h",
|
||||
"ninjatoolkitaspect.cpp",
|
||||
"ninjatoolkitaspect.h",
|
||||
"toolkitaspectwidget.cpp",
|
||||
"toolkitaspectwidget.h",
|
||||
"toolitemsettings.cpp",
|
||||
|
||||
@@ -1,82 +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 "mesontoolkitaspect.h"
|
||||
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
const char TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Meson";
|
||||
|
||||
void MesonToolKitAspect::setMesonTool(Kit *kit, Utils::Id id)
|
||||
{
|
||||
QTC_ASSERT(kit && id.isValid(), return );
|
||||
kit->setValue(TOOL_ID, id.toSetting());
|
||||
}
|
||||
|
||||
Utils::Id MesonToolKitAspect::mesonToolId(const Kit *kit)
|
||||
{
|
||||
QTC_ASSERT(kit, return {});
|
||||
return Utils::Id::fromSetting(kit->value(TOOL_ID));
|
||||
}
|
||||
|
||||
// MesonToolKitAspectFactory
|
||||
|
||||
class MesonToolKitAspectFactory final : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
MesonToolKitAspectFactory()
|
||||
{
|
||||
setId(TOOL_ID);
|
||||
setDisplayName(Tr::tr("Meson Tool"));
|
||||
setDescription(Tr::tr("The Meson tool to use when building a project with Meson.<br>"
|
||||
"This setting is ignored when using other build systems."));
|
||||
setPriority(9000);
|
||||
}
|
||||
|
||||
Tasks validate(const Kit *k) const final
|
||||
{
|
||||
Tasks tasks;
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (tool && !tool->isValid())
|
||||
tasks << BuildSystemTask{Task::Warning, Tr::tr("Cannot validate this meson executable.")};
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void setup(Kit *k) final
|
||||
{
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (!tool) {
|
||||
const auto autoDetected = MesonTools::mesonWrapper();
|
||||
if (autoDetected)
|
||||
MesonToolKitAspect::setMesonTool(k, autoDetected->id());
|
||||
}
|
||||
}
|
||||
void fix(Kit *k) final
|
||||
{
|
||||
setup(k);
|
||||
}
|
||||
|
||||
KitAspect *createKitAspect(Kit *k) const override
|
||||
{
|
||||
return new MesonToolKitAspectImpl{k, this, MesonToolKitAspectImpl::ToolType::Meson};
|
||||
}
|
||||
|
||||
ItemList toUserOutput(const Kit *k) const override
|
||||
{
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (tool)
|
||||
return {{Tr::tr("Meson"), tool->name()}};
|
||||
return {{Tr::tr("Meson"), Tr::tr("Unconfigured")}};
|
||||
}
|
||||
};
|
||||
|
||||
const MesonToolKitAspectFactory theMesonKitAspectFactory;
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
@@ -1,31 +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 "mesontools.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
class MesonToolKitAspect final
|
||||
{
|
||||
public:
|
||||
static void setMesonTool(ProjectExplorer::Kit *kit, Utils::Id id);
|
||||
static Utils::Id mesonToolId(const ProjectExplorer::Kit *kit);
|
||||
|
||||
static inline decltype(auto) mesonTool(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
return MesonTools::mesonWrapper(MesonToolKitAspect::mesonToolId(kit));
|
||||
}
|
||||
|
||||
static inline bool isValid(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
auto tool = mesonTool(kit);
|
||||
return (tool && tool->isValid());
|
||||
}
|
||||
};
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
#include "mesonwrapper.h"
|
||||
#include "ninjawrapper.h"
|
||||
#include "toolwrapper.h"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "mesonpluginconstants.h"
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "mesonoutputparser.h"
|
||||
#include "ninjatoolkitaspect.h"
|
||||
#include "settings.h"
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
|
||||
|
||||
@@ -1,83 +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 "ninjatoolkitaspect.h"
|
||||
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
const char TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Ninja";
|
||||
|
||||
void NinjaToolKitAspect::setNinjaTool(ProjectExplorer::Kit *kit, Utils::Id id)
|
||||
{
|
||||
QTC_ASSERT(kit && id.isValid(), return );
|
||||
kit->setValue(TOOL_ID, id.toSetting());
|
||||
}
|
||||
|
||||
Utils::Id NinjaToolKitAspect::ninjaToolId(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
QTC_ASSERT(kit, return {});
|
||||
return Utils::Id::fromSetting(kit->value(TOOL_ID));
|
||||
}
|
||||
|
||||
// NinjaToolKitAspectFactory
|
||||
|
||||
class NinjaToolKitAspectFactory final : public ProjectExplorer::KitAspectFactory
|
||||
{
|
||||
public:
|
||||
NinjaToolKitAspectFactory()
|
||||
{
|
||||
setId(TOOL_ID);
|
||||
setDisplayName(Tr::tr("Ninja Tool"));
|
||||
setDescription(Tr::tr("The Ninja tool to use when building a project with Meson.<br>"
|
||||
"This setting is ignored when using other build systems."));
|
||||
setPriority(9000);
|
||||
}
|
||||
|
||||
Tasks validate(const Kit *k) const final
|
||||
{
|
||||
Tasks tasks;
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (tool && !tool->isValid())
|
||||
tasks << BuildSystemTask{Task::Warning,
|
||||
Tr::tr("Cannot validate this Ninja executable.")};
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void setup(Kit *k) final
|
||||
{
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (!tool) {
|
||||
const auto autoDetected = MesonTools::ninjaWrapper();
|
||||
if (autoDetected)
|
||||
NinjaToolKitAspect::setNinjaTool(k, autoDetected->id());
|
||||
}
|
||||
}
|
||||
void fix(Kit *k) final
|
||||
{
|
||||
setup(k);
|
||||
}
|
||||
|
||||
ItemList toUserOutput(const Kit *k) const override
|
||||
{
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (tool)
|
||||
return {{Tr::tr("Ninja"), tool->name()}};
|
||||
return {{Tr::tr("Ninja"), Tr::tr("Unconfigured")}};
|
||||
}
|
||||
|
||||
KitAspect *createKitAspect(Kit *k) const final
|
||||
{
|
||||
return new MesonToolKitAspectImpl(k, this, MesonToolKitAspectImpl::ToolType::Ninja);
|
||||
}
|
||||
};
|
||||
|
||||
const NinjaToolKitAspectFactory theNinjaToolKitAspectFactory;
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
@@ -1,30 +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 "mesontools.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
class NinjaToolKitAspect final
|
||||
{
|
||||
public:
|
||||
static void setNinjaTool(ProjectExplorer::Kit *kit, Utils::Id id);
|
||||
static Utils::Id ninjaToolId(const ProjectExplorer::Kit *kit);
|
||||
|
||||
static inline decltype(auto) ninjaTool(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
return MesonTools::ninjaWrapper(NinjaToolKitAspect::ninjaToolId(kit));
|
||||
}
|
||||
static inline bool isValid(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
auto tool = ninjaTool(kit);
|
||||
return (tool && tool->isValid());
|
||||
}
|
||||
};
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
@@ -4,15 +4,63 @@
|
||||
#include "toolkitaspectwidget.h"
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
#include "mesontoolkitaspect.h"
|
||||
#include "ninjatoolkitaspect.h"
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "mesontools.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
enum class ToolType { Meson, Ninja };
|
||||
|
||||
// Meson/Ninja KitAspect base
|
||||
|
||||
class MesonToolKitAspectImpl final : public KitAspect
|
||||
{
|
||||
public:
|
||||
MesonToolKitAspectImpl(Kit *kit,
|
||||
const KitAspectFactory *factory,
|
||||
ToolType type);
|
||||
~MesonToolKitAspectImpl() { delete m_toolsComboBox; }
|
||||
|
||||
private:
|
||||
void addTool(const MesonTools::Tool_t &tool);
|
||||
void removeTool(const MesonTools::Tool_t &tool);
|
||||
void setCurrentToolIndex(int index);
|
||||
int indexOf(const Id &id);
|
||||
bool isCompatible(const MesonTools::Tool_t &tool);
|
||||
void loadTools();
|
||||
void setToDefault();
|
||||
|
||||
void makeReadOnly() final { m_toolsComboBox->setEnabled(false); }
|
||||
|
||||
void addToInnerLayout(Layouting::Layout &parent) final
|
||||
{
|
||||
addMutableAction(m_toolsComboBox);
|
||||
parent.addItem(m_toolsComboBox);
|
||||
}
|
||||
|
||||
void refresh() final
|
||||
{
|
||||
const auto id = [this] {
|
||||
if (m_type == ToolType::Meson)
|
||||
return MesonToolKitAspect::mesonToolId(m_kit);
|
||||
return NinjaToolKitAspect::ninjaToolId(m_kit);
|
||||
}();
|
||||
m_toolsComboBox->setCurrentIndex(indexOf(id));
|
||||
}
|
||||
|
||||
QComboBox *m_toolsComboBox;
|
||||
ToolType m_type;
|
||||
};
|
||||
|
||||
MesonToolKitAspectImpl::MesonToolKitAspectImpl(Kit *kit,
|
||||
const KitAspectFactory *factory,
|
||||
ToolType type)
|
||||
@@ -36,10 +84,7 @@ MesonToolKitAspectImpl::MesonToolKitAspectImpl(Kit *kit,
|
||||
this, &MesonToolKitAspectImpl::setCurrentToolIndex);
|
||||
}
|
||||
|
||||
MesonToolKitAspectImpl::~MesonToolKitAspectImpl()
|
||||
{
|
||||
delete m_toolsComboBox;
|
||||
}
|
||||
|
||||
|
||||
void MesonToolKitAspectImpl::addTool(const MesonTools::Tool_t &tool)
|
||||
{
|
||||
@@ -64,17 +109,17 @@ void MesonToolKitAspectImpl::setCurrentToolIndex(int index)
|
||||
{
|
||||
if (m_toolsComboBox->count() == 0)
|
||||
return;
|
||||
const Utils::Id id = Utils::Id::fromSetting(m_toolsComboBox->itemData(index));
|
||||
const Id id = Id::fromSetting(m_toolsComboBox->itemData(index));
|
||||
if (m_type == ToolType::Meson)
|
||||
MesonToolKitAspect::setMesonTool(m_kit, id);
|
||||
else
|
||||
NinjaToolKitAspect::setNinjaTool(m_kit, id);
|
||||
}
|
||||
|
||||
int MesonToolKitAspectImpl::indexOf(const Utils::Id &id)
|
||||
int MesonToolKitAspectImpl::indexOf(const Id &id)
|
||||
{
|
||||
for (int i = 0; i < m_toolsComboBox->count(); ++i) {
|
||||
if (id == Utils::Id::fromSetting(m_toolsComboBox->itemData(i)))
|
||||
if (id == Id::fromSetting(m_toolsComboBox->itemData(i)))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@@ -113,4 +158,165 @@ void MesonToolKitAspectImpl::setToDefault()
|
||||
}
|
||||
}
|
||||
|
||||
// MesonToolKitAspect
|
||||
|
||||
const char MESON_TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Meson";
|
||||
|
||||
void MesonToolKitAspect::setMesonTool(Kit *kit, Id id)
|
||||
{
|
||||
QTC_ASSERT(kit && id.isValid(), return );
|
||||
kit->setValue(MESON_TOOL_ID, id.toSetting());
|
||||
}
|
||||
|
||||
Id MesonToolKitAspect::mesonToolId(const Kit *kit)
|
||||
{
|
||||
QTC_ASSERT(kit, return {});
|
||||
return Id::fromSetting(kit->value(MESON_TOOL_ID));
|
||||
}
|
||||
|
||||
std::shared_ptr<MesonWrapper> MesonToolKitAspect::mesonTool(const Kit *kit)
|
||||
{
|
||||
return MesonTools::mesonWrapper(MesonToolKitAspect::mesonToolId(kit));
|
||||
}
|
||||
|
||||
bool MesonToolKitAspect::isValid(const Kit *kit)
|
||||
{
|
||||
auto tool = mesonTool(kit);
|
||||
return tool && tool->isValid();
|
||||
}
|
||||
|
||||
// MesonToolKitAspectFactory
|
||||
|
||||
class MesonToolKitAspectFactory final : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
MesonToolKitAspectFactory()
|
||||
{
|
||||
setId(MESON_TOOL_ID);
|
||||
setDisplayName(Tr::tr("Meson Tool"));
|
||||
setDescription(Tr::tr("The Meson tool to use when building a project with Meson.<br>"
|
||||
"This setting is ignored when using other build systems."));
|
||||
setPriority(9000);
|
||||
}
|
||||
|
||||
Tasks validate(const Kit *k) const final
|
||||
{
|
||||
Tasks tasks;
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (tool && !tool->isValid())
|
||||
tasks << BuildSystemTask{Task::Warning, Tr::tr("Cannot validate this meson executable.")};
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void setup(Kit *k) final
|
||||
{
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (!tool) {
|
||||
const auto autoDetected = MesonTools::mesonWrapper();
|
||||
if (autoDetected)
|
||||
MesonToolKitAspect::setMesonTool(k, autoDetected->id());
|
||||
}
|
||||
}
|
||||
void fix(Kit *k) final
|
||||
{
|
||||
setup(k);
|
||||
}
|
||||
|
||||
KitAspect *createKitAspect(Kit *k) const final
|
||||
{
|
||||
return new MesonToolKitAspectImpl(k, this, ToolType::Meson);
|
||||
}
|
||||
|
||||
ItemList toUserOutput(const Kit *k) const final
|
||||
{
|
||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||
if (tool)
|
||||
return {{Tr::tr("Meson"), tool->name()}};
|
||||
return {{Tr::tr("Meson"), Tr::tr("Unconfigured")}};
|
||||
}
|
||||
};
|
||||
|
||||
const MesonToolKitAspectFactory theMesonKitAspectFactory;
|
||||
|
||||
|
||||
// NinjaToolKitAspect
|
||||
|
||||
const char NINJA_TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Ninja";
|
||||
|
||||
void NinjaToolKitAspect::setNinjaTool(Kit *kit, Id id)
|
||||
{
|
||||
QTC_ASSERT(kit && id.isValid(), return );
|
||||
kit->setValue(NINJA_TOOL_ID, id.toSetting());
|
||||
}
|
||||
|
||||
Id NinjaToolKitAspect::ninjaToolId(const Kit *kit)
|
||||
{
|
||||
QTC_ASSERT(kit, return {});
|
||||
return Id::fromSetting(kit->value(NINJA_TOOL_ID));
|
||||
}
|
||||
|
||||
std::shared_ptr<NinjaWrapper> NinjaToolKitAspect::ninjaTool(const Kit *kit)
|
||||
{
|
||||
return MesonTools::ninjaWrapper(NinjaToolKitAspect::ninjaToolId(kit));
|
||||
}
|
||||
|
||||
bool NinjaToolKitAspect::isValid(const Kit *kit)
|
||||
{
|
||||
auto tool = ninjaTool(kit);
|
||||
return tool && tool->isValid();
|
||||
}
|
||||
|
||||
// NinjaToolKitAspectFactory
|
||||
|
||||
class NinjaToolKitAspectFactory final : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
NinjaToolKitAspectFactory()
|
||||
{
|
||||
setId(NINJA_TOOL_ID);
|
||||
setDisplayName(Tr::tr("Ninja Tool"));
|
||||
setDescription(Tr::tr("The Ninja tool to use when building a project with Meson.<br>"
|
||||
"This setting is ignored when using other build systems."));
|
||||
setPriority(9000);
|
||||
}
|
||||
|
||||
Tasks validate(const Kit *k) const final
|
||||
{
|
||||
Tasks tasks;
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (tool && !tool->isValid())
|
||||
tasks << BuildSystemTask{Task::Warning, Tr::tr("Cannot validate this Ninja executable.")};
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void setup(Kit *k) final
|
||||
{
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (!tool) {
|
||||
const auto autoDetected = MesonTools::ninjaWrapper();
|
||||
if (autoDetected)
|
||||
NinjaToolKitAspect::setNinjaTool(k, autoDetected->id());
|
||||
}
|
||||
}
|
||||
void fix(Kit *k) final
|
||||
{
|
||||
setup(k);
|
||||
}
|
||||
|
||||
ItemList toUserOutput(const Kit *k) const final
|
||||
{
|
||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||
if (tool)
|
||||
return {{Tr::tr("Ninja"), tool->name()}};
|
||||
return {{Tr::tr("Ninja"), Tr::tr("Unconfigured")}};
|
||||
}
|
||||
|
||||
KitAspect *createKitAspect(Kit *k) const final
|
||||
{
|
||||
return new MesonToolKitAspectImpl(k, this, ToolType::Ninja);
|
||||
}
|
||||
};
|
||||
|
||||
const NinjaToolKitAspectFactory theNinjaToolKitAspectFactory;
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
|
||||
@@ -1,58 +1,34 @@
|
||||
// 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 "mesontoolkitaspect.h"
|
||||
#include "ninjatoolkitaspect.h"
|
||||
#include "mesonwrapper.h"
|
||||
#include "ninjawrapper.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
class MesonToolKitAspectImpl final : public ProjectExplorer::KitAspect
|
||||
class MesonToolKitAspect final
|
||||
{
|
||||
public:
|
||||
enum class ToolType { Meson, Ninja };
|
||||
static void setMesonTool(ProjectExplorer::Kit *kit, Utils::Id id);
|
||||
static Utils::Id mesonToolId(const ProjectExplorer::Kit *kit);
|
||||
|
||||
MesonToolKitAspectImpl(ProjectExplorer::Kit *kit,
|
||||
const ProjectExplorer::KitAspectFactory *factory,
|
||||
ToolType type);
|
||||
~MesonToolKitAspectImpl();
|
||||
static bool isValid(const ProjectExplorer::Kit *kit);
|
||||
static std::shared_ptr<MesonWrapper> mesonTool(const ProjectExplorer::Kit *kit);
|
||||
};
|
||||
|
||||
private:
|
||||
void addTool(const MesonTools::Tool_t &tool);
|
||||
void removeTool(const MesonTools::Tool_t &tool);
|
||||
void setCurrentToolIndex(int index);
|
||||
int indexOf(const Utils::Id &id);
|
||||
bool isCompatible(const MesonTools::Tool_t &tool);
|
||||
void loadTools();
|
||||
void setToDefault();
|
||||
class NinjaToolKitAspect final
|
||||
{
|
||||
public:
|
||||
static void setNinjaTool(ProjectExplorer::Kit *kit, Utils::Id id);
|
||||
static Utils::Id ninjaToolId(const ProjectExplorer::Kit *kit);
|
||||
|
||||
void makeReadOnly() override { m_toolsComboBox->setEnabled(false); }
|
||||
|
||||
void addToInnerLayout(Layouting::Layout &parent) override
|
||||
{
|
||||
addMutableAction(m_toolsComboBox);
|
||||
parent.addItem(m_toolsComboBox);
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
const auto id = [this] {
|
||||
if (m_type == ToolType::Meson)
|
||||
return MesonToolKitAspect::mesonToolId(m_kit);
|
||||
return NinjaToolKitAspect::ninjaToolId(m_kit);
|
||||
}();
|
||||
m_toolsComboBox->setCurrentIndex(indexOf(id));
|
||||
}
|
||||
|
||||
QComboBox *m_toolsComboBox;
|
||||
ToolType m_type;
|
||||
static bool isValid(const ProjectExplorer::Kit *kit);
|
||||
static std::shared_ptr<NinjaWrapper> ninjaTool(const ProjectExplorer::Kit *kit);
|
||||
};
|
||||
|
||||
} // MesonProjectManager::Internal
|
||||
|
||||
Reference in New Issue
Block a user