QtSupport: Use setupXXX for some QtVersion factories

Change-Id: Ib3b0c3e92c826d86fc857b6451d5340126ce43e7
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-18 07:42:44 +01:00
parent c8bb7897f5
commit 0583fb81ca
3 changed files with 42 additions and 35 deletions

View File

@@ -48,9 +48,6 @@ namespace QtSupport::Internal {
class QtSupportPluginPrivate class QtSupportPluginPrivate
{ {
public: public:
DesktopQtVersionFactory desktopQtVersionFactory;
EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory;
QtOptionsPage qtOptionsPage; QtOptionsPage qtOptionsPage;
ExamplesWelcomePage examplesPage{true}; ExamplesWelcomePage examplesPage{true};
@@ -114,6 +111,9 @@ void QtSupportPlugin::initialize()
addTestCreator(createQtProjectImporterTest); addTestCreator(createQtProjectImporterTest);
#endif #endif
setupDesktopQtVersion();
setupEmbeddedLinuxQtVersion();
theProcessRunner() = processRunnerCallback; theProcessRunner() = processRunnerCallback;
thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional<QString> { thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional<QString> {

View File

@@ -6,6 +6,7 @@
#include "baseqtversion.h" #include "baseqtversion.h"
#include "qtsupportconstants.h" #include "qtsupportconstants.h"
#include "qtsupporttr.h" #include "qtsupporttr.h"
#include "qtversionfactory.h"
#include <projectexplorer/abi.h> #include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -20,17 +21,17 @@
namespace QtSupport::Internal { namespace QtSupport::Internal {
class DesktopQtVersion : public QtVersion class DesktopQtVersion final : public QtVersion
{ {
public: public:
DesktopQtVersion() = default; DesktopQtVersion() = default;
QStringList warningReason() const override; QStringList warningReason() const final;
QString description() const override; QString description() const final;
QSet<Utils::Id> availableFeatures() const override; QSet<Utils::Id> availableFeatures() const final;
QSet<Utils::Id> targetDeviceTypes() const override; QSet<Utils::Id> targetDeviceTypes() const final;
}; };
QStringList DesktopQtVersion::warningReason() const QStringList DesktopQtVersion::warningReason() const
@@ -66,42 +67,59 @@ QSet<Utils::Id> DesktopQtVersion::targetDeviceTypes() const
// Factory // Factory
DesktopQtVersionFactory::DesktopQtVersionFactory() class DesktopQtVersionFactory : public QtVersionFactory
{ {
public:
DesktopQtVersionFactory()
{
setQtVersionCreator([] { return new DesktopQtVersion; }); setQtVersionCreator([] { return new DesktopQtVersion; });
setSupportedType(QtSupport::Constants::DESKTOPQT); setSupportedType(QtSupport::Constants::DESKTOPQT);
setPriority(0); // Lowest of all, we want to be the fallback setPriority(0); // Lowest of all, we want to be the fallback
// No further restrictions. We are the fallback :) so we don't care what kind of qt it is. // No further restrictions. We are the fallback :) so we don't care what kind of qt it is.
} }
};
void setupDesktopQtVersion()
{
static DesktopQtVersion theDesktopQtVersion;
}
// EmbeddedLinuxQtVersion // EmbeddedLinuxQtVersion
const char EMBEDDED_LINUX_QT[] = "RemoteLinux.EmbeddedLinuxQt"; const char EMBEDDED_LINUX_QT[] = "RemoteLinux.EmbeddedLinuxQt";
class EmbeddedLinuxQtVersion : public QtVersion class EmbeddedLinuxQtVersion final : public QtVersion
{ {
public: public:
EmbeddedLinuxQtVersion() = default; EmbeddedLinuxQtVersion() = default;
QString description() const override QString description() const final
{ {
return Tr::tr("Embedded Linux", "Qt Version is used for embedded Linux development"); return Tr::tr("Embedded Linux", "Qt Version is used for embedded Linux development");
} }
QSet<Utils::Id> targetDeviceTypes() const override QSet<Utils::Id> targetDeviceTypes() const final
{ {
return {RemoteLinux::Constants::GenericLinuxOsType}; return {RemoteLinux::Constants::GenericLinuxOsType};
} }
}; };
EmbeddedLinuxQtVersionFactory::EmbeddedLinuxQtVersionFactory() class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory
{ {
public:
EmbeddedLinuxQtVersionFactory()
{
setQtVersionCreator([] { return new EmbeddedLinuxQtVersion; }); setQtVersionCreator([] { return new EmbeddedLinuxQtVersion; });
setSupportedType(EMBEDDED_LINUX_QT); setSupportedType(EMBEDDED_LINUX_QT);
setPriority(10); setPriority(10);
setRestrictionChecker([](const SetupData &) { return false; }); setRestrictionChecker([](const SetupData &) { return false; });
}
};
void setupEmbeddedLinuxQtVersion()
{
static EmbeddedLinuxQtVersionFactory theEmbeddedLinuxQtVersionFactory;
} }
} // QtSupport::Internal } // QtSupport::Internal

View File

@@ -3,20 +3,9 @@
#pragma once #pragma once
#include "qtversionfactory.h"
namespace QtSupport::Internal { namespace QtSupport::Internal {
class DesktopQtVersionFactory : public QtVersionFactory void setupDesktopQtVersion();
{ void setupEmbeddedLinuxQtVersion();
public:
DesktopQtVersionFactory();
};
class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory
{
public:
EmbeddedLinuxQtVersionFactory();
};
} // QtSupport::Internal } // QtSupport::Internal