Qmake: Rename some of the KitAspect related classes

... and split out the static interface.

Change-Id: I9767c858a850b1fe16c97acc4848e8f69ae3342e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2023-08-10 17:01:28 +02:00
parent 74a0313fcf
commit cde3156050
3 changed files with 30 additions and 26 deletions

View File

@@ -26,18 +26,18 @@ using namespace Utils;
namespace QmakeProjectManager { namespace QmakeProjectManager {
namespace Internal { namespace Internal {
class QmakeKitAspectWidget final : public KitAspect class QmakeKitAspectImpl final : public KitAspect
{ {
public: public:
QmakeKitAspectWidget(Kit *k, const KitAspectFactory *ki) QmakeKitAspectImpl(Kit *k, const KitAspectFactory *ki)
: KitAspect(k, ki), m_lineEdit(createSubWidget<QLineEdit>()) : KitAspect(k, ki), m_lineEdit(createSubWidget<QLineEdit>())
{ {
refresh(); // set up everything according to kit refresh(); // set up everything according to kit
m_lineEdit->setToolTip(ki->description()); m_lineEdit->setToolTip(ki->description());
connect(m_lineEdit, &QLineEdit::textEdited, this, &QmakeKitAspectWidget::mkspecWasChanged); connect(m_lineEdit, &QLineEdit::textEdited, this, &QmakeKitAspectImpl::mkspecWasChanged);
} }
~QmakeKitAspectWidget() override { delete m_lineEdit; } ~QmakeKitAspectImpl() override { delete m_lineEdit; }
private: private:
void addToLayout(Layouting::LayoutItem &parent) override void addToLayout(Layouting::LayoutItem &parent) override
@@ -65,7 +65,7 @@ private:
}; };
QmakeKitAspect::QmakeKitAspect() QmakeKitAspectFactory::QmakeKitAspectFactory()
{ {
setObjectName(QLatin1String("QmakeKitAspect")); setObjectName(QLatin1String("QmakeKitAspect"));
setId(QmakeKitAspect::id()); setId(QmakeKitAspect::id());
@@ -75,7 +75,7 @@ QmakeKitAspect::QmakeKitAspect()
setPriority(24000); setPriority(24000);
} }
Tasks QmakeKitAspect::validate(const Kit *k) const Tasks QmakeKitAspectFactory::validate(const Kit *k) const
{ {
Tasks result; Tasks result;
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(k); QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(k);
@@ -89,21 +89,21 @@ Tasks QmakeKitAspect::validate(const Kit *k) const
return result; return result;
} }
KitAspect *QmakeKitAspect::createKitAspect(Kit *k) const KitAspect *QmakeKitAspectFactory::createKitAspect(Kit *k) const
{ {
return new Internal::QmakeKitAspectWidget(k, this); return new Internal::QmakeKitAspectImpl(k, this);
} }
KitAspectFactory::ItemList QmakeKitAspect::toUserOutput(const Kit *k) const KitAspectFactory::ItemList QmakeKitAspectFactory::toUserOutput(const Kit *k) const
{ {
return {{Tr::tr("mkspec"), QDir::toNativeSeparators(mkspec(k))}}; return {{Tr::tr("mkspec"), QDir::toNativeSeparators(QmakeKitAspect::mkspec(k))}};
} }
void QmakeKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const void QmakeKitAspectFactory::addToMacroExpander(Kit *kit, MacroExpander *expander) const
{ {
expander->registerVariable("Qmake:mkspec", Tr::tr("Mkspec configured for qmake by the kit."), expander->registerVariable("Qmake:mkspec", Tr::tr("Mkspec configured for qmake by the kit."),
[kit]() -> QString { [kit]() -> QString {
return QDir::toNativeSeparators(mkspec(kit)); return QDir::toNativeSeparators(QmakeKitAspect::mkspec(kit));
}); });
} }

View File

@@ -8,21 +8,9 @@
namespace QmakeProjectManager { namespace QmakeProjectManager {
namespace Internal { namespace Internal {
class QmakeKitAspect : public ProjectExplorer::KitAspectFactory class QmakeKitAspect
{ {
Q_OBJECT
public: public:
QmakeKitAspect();
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const override;
ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k) const override;
ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override;
static Utils::Id id(); static Utils::Id id();
enum class MkspecSource { User, Code }; enum class MkspecSource { User, Code };
static void setMkspec(ProjectExplorer::Kit *k, const QString &mkspec, MkspecSource source); static void setMkspec(ProjectExplorer::Kit *k, const QString &mkspec, MkspecSource source);
@@ -31,5 +19,21 @@ public:
static QString defaultMkspec(const ProjectExplorer::Kit *k); static QString defaultMkspec(const ProjectExplorer::Kit *k);
}; };
class QmakeKitAspectFactory : public ProjectExplorer::KitAspectFactory
{
Q_OBJECT
public:
QmakeKitAspectFactory();
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const override;
ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k) const override;
ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override;
};
} // namespace Internal } // namespace Internal
} // namespace QmakeProjectManager } // namespace QmakeProjectManager

View File

@@ -96,7 +96,7 @@ public:
QAction *m_addLibraryAction = nullptr; QAction *m_addLibraryAction = nullptr;
QAction *m_addLibraryActionContextMenu = nullptr; QAction *m_addLibraryActionContextMenu = nullptr;
QmakeKitAspect qmakeKitAspect; QmakeKitAspectFactory qmakeKitAspectFactory;
void addLibrary(); void addLibrary();
void addLibraryContextMenu(); void addLibraryContextMenu();