IosPlugin: Pimpl plugin class

Also generally follow the current plugin setup pattern,
remove unneeded uses of global plugin pool, move stuff
to the usual initialization phases.

Change-Id: I1eb1d8251be68aa095e07125d42451dae4a3dd06
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
hjk
2018-02-08 09:24:22 +01:00
parent 6a964d8d0b
commit 65078befce
2 changed files with 43 additions and 34 deletions

View File

@@ -48,18 +48,33 @@
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <QtPlugin>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace QtSupport;
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common")
}
IosPlugin::IosPlugin() Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common")
class IosPluginPrivate
{ {
qRegisterMetaType<Ios::IosToolHandler::Dict>("Ios::IosToolHandler::Dict"); public:
IosBuildConfigurationFactory buildConfigurationFactory;
IosToolChainFactory toolChainFactory;
IosRunConfigurationFactory runConfigurationFactory;
IosSettingsPage settingsPage;
IosQtVersionFactory qtVersionFactory;
IosDeviceFactory deviceFactory;
IosSimulatorFactory simulatorFactory;
IosBuildStepFactory buildStepFactory;
IosDeployStepFactory deployStepFactory;
IosDsymBuildStepFactory dsymBuildStepFactory;
IosDeployConfigurationFactory deployConfigurationFactory;
};
IosPlugin::~IosPlugin()
{
delete d;
} }
bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage) bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
@@ -67,22 +82,14 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
Q_UNUSED(arguments); Q_UNUSED(arguments);
Q_UNUSED(errorMessage); Q_UNUSED(errorMessage);
Internal::IosConfigurations::initialize(); qRegisterMetaType<Ios::IosToolHandler::Dict>("Ios::IosToolHandler::Dict");
addAutoReleasedObject(new Internal::IosBuildConfigurationFactory); IosConfigurations::initialize();
addAutoReleasedObject(new Internal::IosToolChainFactory);
addAutoReleasedObject(new Internal::IosRunConfigurationFactory); d = new IosPluginPrivate;
addAutoReleasedObject(new Internal::IosSettingsPage);
addAutoReleasedObject(new Internal::IosQtVersionFactory);
addAutoReleasedObject(new Internal::IosDeviceFactory);
addAutoReleasedObject(new Internal::IosSimulatorFactory);
addAutoReleasedObject(new Internal::IosBuildStepFactory);
addAutoReleasedObject(new Internal::IosDeployStepFactory);
addAutoReleasedObject(new Internal::IosDsymBuildStepFactory);
addAutoReleasedObject(new Internal::IosDeployConfigurationFactory);
auto constraint = [](RunConfiguration *runConfig) { auto constraint = [](RunConfiguration *runConfig) {
return qobject_cast<Internal::IosRunConfiguration *>(runConfig) != nullptr; return qobject_cast<IosRunConfiguration *>(runConfig) != nullptr;
}; };
RunControl::registerWorker<Internal::IosRunSupport> RunControl::registerWorker<Internal::IosRunSupport>
@@ -92,24 +99,20 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
RunControl::registerWorker<Internal::IosQmlProfilerSupport> RunControl::registerWorker<Internal::IosQmlProfilerSupport>
(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint); (ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint);
return true; connect(KitManager::instance(), &KitManager::kitsLoaded,
}
void IosPlugin::extensionsInitialized()
{
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitsLoaded,
this, &IosPlugin::kitsRestored); this, &IosPlugin::kitsRestored);
return true;
} }
void IosPlugin::kitsRestored() void IosPlugin::kitsRestored()
{ {
disconnect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitsLoaded, disconnect(KitManager::instance(), &KitManager::kitsLoaded,
this, &IosPlugin::kitsRestored); this, &IosPlugin::kitsRestored);
Internal::IosConfigurations::updateAutomaticKitList(); IosConfigurations::updateAutomaticKitList();
connect(QtSupport::QtVersionManager::instance(), connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
&QtSupport::QtVersionManager::qtVersionsChanged, IosConfigurations::instance(), &IosConfigurations::updateAutomaticKitList);
Internal::IosConfigurations::instance(),
&Internal::IosConfigurations::updateAutomaticKitList);
} }
} // namespace Internal
} // namespace Ios } // namespace Ios

View File

@@ -28,6 +28,7 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
namespace Ios { namespace Ios {
namespace Internal {
class IosPlugin : public ExtensionSystem::IPlugin class IosPlugin : public ExtensionSystem::IPlugin
{ {
@@ -35,12 +36,17 @@ class IosPlugin : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Ios.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Ios.json")
public: public:
IosPlugin(); IosPlugin() = default;
~IosPlugin() final;
bool initialize(const QStringList &arguments, QString *errorMessage) override;
void extensionsInitialized() override;
private: private:
bool initialize(const QStringList &arguments, QString *errorMessage) final;
void extensionsInitialized() final {}
void kitsRestored(); void kitsRestored();
class IosPluginPrivate *d = nullptr;
}; };
} // namespace Internal
} // namespace Ios } // namespace Ios