Python: Move plugin class definition to .cpp

The plugin classes partially changed there purpose, they are no more
meant to provide internal utility functionality.

Change-Id: I9b9200995eaa95dcd924c94dcedb28e6d5db0be9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2024-01-15 16:21:30 +01:00
parent 590a54828c
commit 1992efddfc
6 changed files with 52 additions and 56 deletions

View File

@@ -221,7 +221,7 @@ QFuture<PipPackageInfo> Pip::info(const PipPackage &package)
} }
Pip::Pip(const Utils::FilePath &python) Pip::Pip(const Utils::FilePath &python)
: QObject(PythonPlugin::instance()) : QObject(pluginInstance())
, m_python(python) , m_python(python)
{} {}

View File

@@ -81,7 +81,7 @@ QString PySideInstaller::importedPySide(const QString &text)
} }
PySideInstaller::PySideInstaller() PySideInstaller::PySideInstaller()
: QObject(PythonPlugin::instance()) : QObject(pluginInstance())
{} {}
void PySideInstaller::installPyside(const FilePath &python, void PySideInstaller::installPyside(const FilePath &python,

View File

@@ -265,7 +265,7 @@ PyLSClient *PyLSClient::clientForPython(const FilePath &python)
PyLSConfigureAssistant *PyLSConfigureAssistant::instance() PyLSConfigureAssistant *PyLSConfigureAssistant::instance()
{ {
static auto *instance = new PyLSConfigureAssistant(PythonPlugin::instance()); static auto *instance = new PyLSConfigureAssistant(pluginInstance());
return instance; return instance;
} }

View File

@@ -13,6 +13,8 @@
#include "pythontr.h" #include "pythontr.h"
#include "pythonwizardpage.h" #include "pythonwizardpage.h"
#include <extensionsystem/iplugin.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h> #include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <projectexplorer/kitmanager.h> #include <projectexplorer/kitmanager.h>
@@ -28,7 +30,12 @@ using namespace Utils;
namespace Python::Internal { namespace Python::Internal {
static PythonPlugin *m_instance = nullptr; static QObject *m_instance = nullptr;
QObject *pluginInstance()
{
return m_instance;
}
class PythonPluginPrivate class PythonPluginPrivate
{ {
@@ -43,24 +50,26 @@ public:
PythonWizardPageFactory pythonWizardPageFactory; PythonWizardPageFactory pythonWizardPageFactory;
}; };
PythonPlugin::PythonPlugin() class PythonPlugin final : public ExtensionSystem::IPlugin
{ {
m_instance = this; Q_OBJECT
} Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Python.json")
PythonPlugin::~PythonPlugin() public:
{ PythonPlugin()
{
m_instance = this;
}
~PythonPlugin() final
{
m_instance = nullptr; m_instance = nullptr;
delete d; delete d;
} }
PythonPlugin *PythonPlugin::instance() private:
{ void initialize() final
return m_instance; {
}
void PythonPlugin::initialize()
{
d = new PythonPluginPrivate; d = new PythonPluginPrivate;
KitManager::setIrrelevantAspects(KitManager::irrelevantAspects() KitManager::setIrrelevantAspects(KitManager::irrelevantAspects()
@@ -68,10 +77,10 @@ void PythonPlugin::initialize()
ProjectManager::registerProjectType<PythonProject>(Constants::C_PY_PROJECT_MIME_TYPE); ProjectManager::registerProjectType<PythonProject>(Constants::C_PY_PROJECT_MIME_TYPE);
ProjectManager::registerProjectType<PythonProject>(Constants::C_PY_PROJECT_MIME_TYPE_LEGACY); ProjectManager::registerProjectType<PythonProject>(Constants::C_PY_PROJECT_MIME_TYPE_LEGACY);
} }
void PythonPlugin::extensionsInitialized() void extensionsInitialized() final
{ {
// Add MIME overlay icons (these icons displayed at Project dock panel) // Add MIME overlay icons (these icons displayed at Project dock panel)
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro, const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
::Constants::FILEOVERLAY_PY); ::Constants::FILEOVERLAY_PY);
@@ -81,6 +90,11 @@ void PythonPlugin::extensionsInitialized()
"Python", "Python",
Tr::tr("Issues parsed from Python runtime output."), Tr::tr("Issues parsed from Python runtime output."),
true}); true});
} }
PythonPluginPrivate *d = nullptr;
};
} // Python::Internal } // Python::Internal
#include "pythonplugin.moc"

View File

@@ -3,28 +3,10 @@
#pragma once #pragma once
#include <extensionsystem/iplugin.h> #include <QObject>
namespace Python::Internal { namespace Python::Internal {
class PythonBuildConfigurationFactory; QObject *pluginInstance();
class PythonPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Python.json")
public:
PythonPlugin();
~PythonPlugin() final;
static PythonPlugin *instance();
private:
void initialize() final;
void extensionsInitialized() final;
class PythonPluginPrivate *d = nullptr;
};
} // Python::Internal } // Python::Internal

View File

@@ -642,7 +642,7 @@ static void disableOutdatedPyls()
disableOutdatedPylsNow(); disableOutdatedPylsNow();
} else { } else {
QObject::connect(PluginManager::instance(), &PluginManager::initializationDone, QObject::connect(PluginManager::instance(), &PluginManager::initializationDone,
PythonPlugin::instance(), &disableOutdatedPylsNow); pluginInstance(), &disableOutdatedPylsNow);
} }
} }