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)
: QObject(PythonPlugin::instance())
: QObject(pluginInstance())
, m_python(python)
{}

View File

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

View File

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

View File

@@ -13,6 +13,8 @@
#include "pythontr.h"
#include "pythonwizardpage.h"
#include <extensionsystem/iplugin.h>
#include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <projectexplorer/kitmanager.h>
@@ -28,7 +30,12 @@ using namespace Utils;
namespace Python::Internal {
static PythonPlugin *m_instance = nullptr;
static QObject *m_instance = nullptr;
QObject *pluginInstance()
{
return m_instance;
}
class PythonPluginPrivate
{
@@ -43,44 +50,51 @@ public:
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()
{
m_instance = nullptr;
delete d;
}
public:
PythonPlugin()
{
m_instance = this;
}
PythonPlugin *PythonPlugin::instance()
{
return m_instance;
}
~PythonPlugin() final
{
m_instance = nullptr;
delete d;
}
void PythonPlugin::initialize()
{
d = new PythonPluginPrivate;
private:
void initialize() final
{
d = new PythonPluginPrivate;
KitManager::setIrrelevantAspects(KitManager::irrelevantAspects()
+ QSet<Id>{PythonKitAspect::id()});
KitManager::setIrrelevantAspects(KitManager::irrelevantAspects()
+ QSet<Id>{PythonKitAspect::id()});
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);
ProjectManager::registerProjectType<PythonProject>(Constants::C_PY_PROJECT_MIME_TYPE_LEGACY);
}
void PythonPlugin::extensionsInitialized()
{
// Add MIME overlay icons (these icons displayed at Project dock panel)
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
::Constants::FILEOVERLAY_PY);
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
void extensionsInitialized() final
{
// Add MIME overlay icons (these icons displayed at Project dock panel)
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
::Constants::FILEOVERLAY_PY);
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
TaskHub::addCategory({PythonErrorTaskCategory,
"Python",
Tr::tr("Issues parsed from Python runtime output."),
true});
}
TaskHub::addCategory({PythonErrorTaskCategory,
"Python",
Tr::tr("Issues parsed from Python runtime output."),
true});
}
PythonPluginPrivate *d = nullptr;
};
} // Python::Internal
#include "pythonplugin.moc"

View File

@@ -3,28 +3,10 @@
#pragma once
#include <extensionsystem/iplugin.h>
#include <QObject>
namespace Python::Internal {
class PythonBuildConfigurationFactory;
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;
};
QObject *pluginInstance();
} // Python::Internal

View File

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