From 9f83bafe33f83859df6447509bd5405a8b0d5163 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 13 Feb 2019 18:58:54 +0100 Subject: [PATCH] WinRt: Split WinRtQtVersionFactory ... to get a 1:1 relation with produced Qt versions. This looks wasteful right now, but will be simplified in follow-up patches. Change-Id: I6bb1c087751cc6acdd0293410c02e1656da36050 Reviewed-by: Oliver Wolff --- src/plugins/winrt/winrtplugin.cpp | 1 + src/plugins/winrt/winrtqtversionfactory.cpp | 64 +++++++++++++++------ src/plugins/winrt/winrtqtversionfactory.h | 13 +++++ 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/plugins/winrt/winrtplugin.cpp b/src/plugins/winrt/winrtplugin.cpp index f2325a59ffb..b98d7c0080f 100644 --- a/src/plugins/winrt/winrtplugin.cpp +++ b/src/plugins/winrt/winrtplugin.cpp @@ -48,6 +48,7 @@ class WinRtPluginRunData public: WinRtRunConfigurationFactory runConfigFactory; WinRtQtVersionFactory qtVersionFactory; + WinRtPhoneQtVersionFactory phoneQtVersionFactory; WinRtAppDeployConfigurationFactory appDeployConfigFactory; WinRtPhoneDeployConfigurationFactory phoneDeployConfigFactory; WinRtEmulatorDeployConfigurationFactory emulatorDeployFactory; diff --git a/src/plugins/winrt/winrtqtversionfactory.cpp b/src/plugins/winrt/winrtqtversionfactory.cpp index 2daf2e36121..828d7b98806 100644 --- a/src/plugins/winrt/winrtqtversionfactory.cpp +++ b/src/plugins/winrt/winrtqtversionfactory.cpp @@ -46,8 +46,7 @@ WinRtQtVersionFactory::~WinRtQtVersionFactory() bool WinRtQtVersionFactory::canRestore(const QString &type) { - return type == QLatin1String(Constants::WINRT_WINRTQT) - || type == QLatin1String(Constants::WINRT_WINPHONEQT); + return type == QLatin1String(Constants::WINRT_WINRTQT); } QtSupport::BaseQtVersion *WinRtQtVersionFactory::restore(const QString &type, @@ -55,11 +54,7 @@ QtSupport::BaseQtVersion *WinRtQtVersionFactory::restore(const QString &type, { if (!canRestore(type)) return nullptr; - WinRtQtVersion *v = nullptr; - if (type == QLatin1String(Constants::WINRT_WINPHONEQT)) - v = new WinRtPhoneQtVersion; - else - v = new WinRtQtVersion; + WinRtQtVersion *v = new WinRtQtVersion; v->fromMap(data); return v; } @@ -76,23 +71,54 @@ QtSupport::BaseQtVersion *WinRtQtVersionFactory::create(const Utils::FileName &q if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) return nullptr; - bool isWinRt = false; - bool isPhone = false; foreach (const QString &value, evaluator->values(QLatin1String("QMAKE_PLATFORM"))) { - if (value == QStringLiteral("winrt")) { - isWinRt = true; - } else if (value == QStringLiteral("winphone")) { - isWinRt = true; - isPhone = true; - break; - } + if (value == QStringLiteral("winrt")) + return new WinRtQtVersion(qmakePath, isAutoDetected, autoDetectionSource); } - if (!isWinRt) + return nullptr; +} + + + +WinRtPhoneQtVersionFactory::WinRtPhoneQtVersionFactory(QObject *parent) + : QtSupport::QtVersionFactory(parent) +{ +} + +bool WinRtPhoneQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::WINRT_WINPHONEQT); +} + +QtSupport::BaseQtVersion *WinRtPhoneQtVersionFactory::restore(const QString &type, + const QVariantMap &data) +{ + if (!canRestore(type)) + return nullptr; + WinRtQtVersion *v = new WinRtPhoneQtVersion; + v->fromMap(data); + return v; +} + +int WinRtPhoneQtVersionFactory::priority() const +{ + return 10; +} + +QtSupport::BaseQtVersion *WinRtPhoneQtVersionFactory::create(const Utils::FileName &qmakePath, + ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + QFileInfo fi = qmakePath.toFileInfo(); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) return nullptr; - return isPhone ? new WinRtPhoneQtVersion(qmakePath, isAutoDetected, autoDetectionSource) - : new WinRtQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + foreach (const QString &value, evaluator->values(QLatin1String("QMAKE_PLATFORM"))) { + if (value == QStringLiteral("winphone")) + return new WinRtPhoneQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + } + + return nullptr; } } // Internal diff --git a/src/plugins/winrt/winrtqtversionfactory.h b/src/plugins/winrt/winrtqtversionfactory.h index 4a88ce40fa4..3c58775e657 100644 --- a/src/plugins/winrt/winrtqtversionfactory.h +++ b/src/plugins/winrt/winrtqtversionfactory.h @@ -44,5 +44,18 @@ public: bool isAutoDetected = false, const QString &autoDetectionSource = QString()); }; +class WinRtPhoneQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + explicit WinRtPhoneQtVersionFactory(QObject *parent = nullptr); + + bool canRestore(const QString &type); + QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data); + + int priority() const; + QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, + bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + } // Internal } // WinRt