From 0583fb81ca11a685d3401f5a082f6082680fbdbf Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jan 2024 07:42:44 +0100 Subject: [PATCH] QtSupport: Use setupXXX for some QtVersion factories Change-Id: Ib3b0c3e92c826d86fc857b6451d5340126ce43e7 Reviewed-by: Jarek Kobus --- src/plugins/qtsupport/qtsupportplugin.cpp | 6 +-- src/plugins/qtsupport/qtversions.cpp | 56 +++++++++++++++-------- src/plugins/qtsupport/qtversions.h | 15 +----- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 5a8a848a399..4ff5e4659f1 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -48,9 +48,6 @@ namespace QtSupport::Internal { class QtSupportPluginPrivate { public: - DesktopQtVersionFactory desktopQtVersionFactory; - EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory; - QtOptionsPage qtOptionsPage; ExamplesWelcomePage examplesPage{true}; @@ -114,6 +111,9 @@ void QtSupportPlugin::initialize() addTestCreator(createQtProjectImporterTest); #endif + setupDesktopQtVersion(); + setupEmbeddedLinuxQtVersion(); + theProcessRunner() = processRunnerCallback; thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional { diff --git a/src/plugins/qtsupport/qtversions.cpp b/src/plugins/qtsupport/qtversions.cpp index 71304ed5896..b1149bb92a6 100644 --- a/src/plugins/qtsupport/qtversions.cpp +++ b/src/plugins/qtsupport/qtversions.cpp @@ -6,6 +6,7 @@ #include "baseqtversion.h" #include "qtsupportconstants.h" #include "qtsupporttr.h" +#include "qtversionfactory.h" #include #include @@ -20,17 +21,17 @@ namespace QtSupport::Internal { -class DesktopQtVersion : public QtVersion +class DesktopQtVersion final : public QtVersion { public: DesktopQtVersion() = default; - QStringList warningReason() const override; + QStringList warningReason() const final; - QString description() const override; + QString description() const final; - QSet availableFeatures() const override; - QSet targetDeviceTypes() const override; + QSet availableFeatures() const final; + QSet targetDeviceTypes() const final; }; QStringList DesktopQtVersion::warningReason() const @@ -66,42 +67,59 @@ QSet DesktopQtVersion::targetDeviceTypes() const // Factory -DesktopQtVersionFactory::DesktopQtVersionFactory() +class DesktopQtVersionFactory : public QtVersionFactory { - setQtVersionCreator([] { return new DesktopQtVersion; }); - setSupportedType(QtSupport::Constants::DESKTOPQT); - 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. -} +public: + DesktopQtVersionFactory() + { + setQtVersionCreator([] { return new DesktopQtVersion; }); + setSupportedType(QtSupport::Constants::DESKTOPQT); + 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. + } +}; +void setupDesktopQtVersion() +{ + static DesktopQtVersion theDesktopQtVersion; +} // EmbeddedLinuxQtVersion const char EMBEDDED_LINUX_QT[] = "RemoteLinux.EmbeddedLinuxQt"; -class EmbeddedLinuxQtVersion : public QtVersion +class EmbeddedLinuxQtVersion final : public QtVersion { public: EmbeddedLinuxQtVersion() = default; - QString description() const override + QString description() const final { return Tr::tr("Embedded Linux", "Qt Version is used for embedded Linux development"); } - QSet targetDeviceTypes() const override + QSet targetDeviceTypes() const final { return {RemoteLinux::Constants::GenericLinuxOsType}; } }; -EmbeddedLinuxQtVersionFactory::EmbeddedLinuxQtVersionFactory() +class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory { - setQtVersionCreator([] { return new EmbeddedLinuxQtVersion; }); - setSupportedType(EMBEDDED_LINUX_QT); - setPriority(10); +public: + EmbeddedLinuxQtVersionFactory() + { + setQtVersionCreator([] { return new EmbeddedLinuxQtVersion; }); + setSupportedType(EMBEDDED_LINUX_QT); + setPriority(10); - setRestrictionChecker([](const SetupData &) { return false; }); + setRestrictionChecker([](const SetupData &) { return false; }); + } +}; + +void setupEmbeddedLinuxQtVersion() +{ + static EmbeddedLinuxQtVersionFactory theEmbeddedLinuxQtVersionFactory; } } // QtSupport::Internal diff --git a/src/plugins/qtsupport/qtversions.h b/src/plugins/qtsupport/qtversions.h index e46f3d92c6b..a8e936b7337 100644 --- a/src/plugins/qtsupport/qtversions.h +++ b/src/plugins/qtsupport/qtversions.h @@ -3,20 +3,9 @@ #pragma once -#include "qtversionfactory.h" - namespace QtSupport::Internal { -class DesktopQtVersionFactory : public QtVersionFactory -{ -public: - DesktopQtVersionFactory(); -}; - -class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory -{ -public: - EmbeddedLinuxQtVersionFactory(); -}; +void setupDesktopQtVersion(); +void setupEmbeddedLinuxQtVersion(); } // QtSupport::Internal