QmakeProjectManager: Hide QmakeKitAspectFactory implementation

Change-Id: I9847c82f023d6b1620fdbf66f34b0fd845cfe721
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-08-18 14:45:06 +02:00
parent 30a7228c5f
commit 8d5641847f
3 changed files with 54 additions and 68 deletions

View File

@@ -23,8 +23,7 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace QmakeProjectManager { namespace QmakeProjectManager::Internal {
namespace Internal {
class QmakeKitAspectImpl final : public KitAspect class QmakeKitAspectImpl final : public KitAspect
{ {
@@ -64,49 +63,6 @@ private:
Guard m_ignoreChanges; Guard m_ignoreChanges;
}; };
QmakeKitAspectFactory::QmakeKitAspectFactory()
{
setObjectName(QLatin1String("QmakeKitAspect"));
setId(QmakeKitAspect::id());
setDisplayName(Tr::tr("Qt mkspec"));
setDescription(Tr::tr("The mkspec to use when building the project with qmake.<br>"
"This setting is ignored when using other build systems."));
setPriority(24000);
}
Tasks QmakeKitAspectFactory::validate(const Kit *k) const
{
Tasks result;
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(k);
const QString mkspec = QmakeKitAspect::mkspec(k);
if (!version && !mkspec.isEmpty())
result << BuildSystemTask(Task::Warning, Tr::tr("No Qt version set, so mkspec is ignored."));
if (version && !version->hasMkspec(mkspec))
result << BuildSystemTask(Task::Error, Tr::tr("Mkspec not found for Qt version."));
return result;
}
KitAspect *QmakeKitAspectFactory::createKitAspect(Kit *k) const
{
return new Internal::QmakeKitAspectImpl(k, this);
}
KitAspectFactory::ItemList QmakeKitAspectFactory::toUserOutput(const Kit *k) const
{
return {{Tr::tr("mkspec"), QDir::toNativeSeparators(QmakeKitAspect::mkspec(k))}};
}
void QmakeKitAspectFactory::addToMacroExpander(Kit *kit, MacroExpander *expander) const
{
expander->registerVariable("Qmake:mkspec", Tr::tr("Mkspec configured for qmake by the kit."),
[kit]() -> QString {
return QDir::toNativeSeparators(QmakeKitAspect::mkspec(kit));
});
}
Id QmakeKitAspect::id() Id QmakeKitAspect::id()
{ {
return Constants::KIT_INFORMATION_ID; return Constants::KIT_INFORMATION_ID;
@@ -145,5 +101,54 @@ QString QmakeKitAspect::defaultMkspec(const Kit *k)
return version->mkspecFor(ToolChainKitAspect::cxxToolChain(k)); return version->mkspecFor(ToolChainKitAspect::cxxToolChain(k));
} }
} // namespace Internal // QmakeKitAspectFactory
} // namespace QmakeProjectManager
class QmakeKitAspectFactory : public KitAspectFactory
{
public:
QmakeKitAspectFactory()
{
setObjectName(QLatin1String("QmakeKitAspect"));
setId(QmakeKitAspect::id());
setDisplayName(Tr::tr("Qt mkspec"));
setDescription(Tr::tr("The mkspec to use when building the project with qmake.<br>"
"This setting is ignored when using other build systems."));
setPriority(24000);
}
Tasks validate(const Kit *k) const override
{
Tasks result;
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(k);
const QString mkspec = QmakeKitAspect::mkspec(k);
if (!version && !mkspec.isEmpty())
result << BuildSystemTask(Task::Warning, Tr::tr("No Qt version set, so mkspec is ignored."));
if (version && !version->hasMkspec(mkspec))
result << BuildSystemTask(Task::Error, Tr::tr("Mkspec not found for Qt version."));
return result;
}
KitAspect *createKitAspect(Kit *k) const override
{
return new QmakeKitAspectImpl(k, this);
}
ItemList toUserOutput(const Kit *k) const override
{
return {{Tr::tr("mkspec"), QDir::toNativeSeparators(QmakeKitAspect::mkspec(k))}};
}
void addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const override
{
expander->registerVariable("Qmake:mkspec", Tr::tr("Mkspec configured for qmake by the kit."),
[kit]() -> QString {
return QDir::toNativeSeparators(QmakeKitAspect::mkspec(kit));
});
}
};
const QmakeKitAspectFactory theQmakeKitAspectFactory;
} // QmakeProjectManager::Internal

View File

@@ -5,8 +5,7 @@
#include <projectexplorer/kitmanager.h> #include <projectexplorer/kitmanager.h>
namespace QmakeProjectManager { namespace QmakeProjectManager::Internal {
namespace Internal {
class QmakeKitAspect class QmakeKitAspect
{ {
@@ -19,19 +18,4 @@ public:
static QString defaultMkspec(const ProjectExplorer::Kit *k); static QString defaultMkspec(const ProjectExplorer::Kit *k);
}; };
class QmakeKitAspectFactory : public ProjectExplorer::KitAspectFactory } // QmakeProjectManager::Internal
{
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 QmakeProjectManager

View File

@@ -7,7 +7,6 @@
#include "customwidgetwizard/customwidgetwizard.h" #include "customwidgetwizard/customwidgetwizard.h"
#include "profileeditor.h" #include "profileeditor.h"
#include "qmakebuildconfiguration.h" #include "qmakebuildconfiguration.h"
#include "qmakekitinformation.h"
#include "qmakemakestep.h" #include "qmakemakestep.h"
#include "qmakenodes.h" #include "qmakenodes.h"
#include "qmakeproject.h" #include "qmakeproject.h"
@@ -96,8 +95,6 @@ public:
QAction *m_addLibraryAction = nullptr; QAction *m_addLibraryAction = nullptr;
QAction *m_addLibraryActionContextMenu = nullptr; QAction *m_addLibraryActionContextMenu = nullptr;
QmakeKitAspectFactory qmakeKitAspectFactory;
void addLibrary(); void addLibrary();
void addLibraryContextMenu(); void addLibraryContextMenu();
void runQMake(); void runQMake();