2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2019-07-15 12:50:29 +02:00
|
|
|
#include "pythonplugin.h"
|
2019-07-22 14:39:01 +02:00
|
|
|
|
2023-11-01 15:05:03 +01:00
|
|
|
#include "pythonbuildconfiguration.h"
|
|
|
|
|
#include "pythonconstants.h"
|
2014-08-20 15:05:32 +02:00
|
|
|
#include "pythoneditor.h"
|
2023-10-19 13:00:48 +02:00
|
|
|
#include "pythonkitaspect.h"
|
2019-07-22 14:39:01 +02:00
|
|
|
#include "pythonproject.h"
|
|
|
|
|
#include "pythonrunconfiguration.h"
|
2023-03-07 13:00:44 +01:00
|
|
|
#include "pythonsettings.h"
|
2023-07-11 14:14:40 +02:00
|
|
|
#include "pythontr.h"
|
2023-03-07 13:00:44 +01:00
|
|
|
#include "pythonwizardpage.h"
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2024-01-12 14:04:37 +01:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
|
2024-01-15 16:21:30 +01:00
|
|
|
#include <extensionsystem/iplugin.h>
|
|
|
|
|
|
2018-03-06 15:28:06 +01:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
2023-03-07 13:00:44 +01:00
|
|
|
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
2023-10-19 13:00:48 +02:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2018-03-29 15:29:17 +02:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2015-06-09 15:19:54 +02:00
|
|
|
|
2022-05-31 11:16:44 +02:00
|
|
|
#include <utils/fsengine/fileiconprovider.h>
|
2019-07-22 14:39:01 +02:00
|
|
|
#include <utils/theme/theme.h>
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2024-01-12 14:04:37 +01:00
|
|
|
using namespace Debugger;
|
2015-06-09 15:19:54 +02:00
|
|
|
using namespace ProjectExplorer;
|
2023-04-04 13:39:56 +02:00
|
|
|
using namespace Utils;
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2023-01-06 13:56:00 +01:00
|
|
|
namespace Python::Internal {
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2024-01-15 16:21:30 +01:00
|
|
|
static QObject *m_instance = nullptr;
|
|
|
|
|
|
|
|
|
|
QObject *pluginInstance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
2019-10-18 10:31:14 +02:00
|
|
|
|
2019-07-15 12:50:29 +02:00
|
|
|
class PythonPluginPrivate
|
2013-01-14 23:11:10 +04:00
|
|
|
{
|
2018-02-06 12:46:02 +01:00
|
|
|
public:
|
2019-08-06 10:57:59 +02:00
|
|
|
PythonOutputFormatterFactory outputFormatterFactory;
|
2018-02-06 12:46:02 +01:00
|
|
|
PythonRunConfigurationFactory runConfigFactory;
|
2022-03-30 14:42:33 +02:00
|
|
|
PySideBuildStepFactory buildStepFactory;
|
2023-11-01 15:05:03 +01:00
|
|
|
PythonBuildConfigurationFactory buildConfigFactory;
|
2023-01-06 13:56:00 +01:00
|
|
|
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
|
2024-01-12 14:04:37 +01:00
|
|
|
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}, {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE}};
|
2022-11-16 15:07:36 +01:00
|
|
|
PythonSettings settings;
|
2023-08-17 11:02:25 +02:00
|
|
|
PythonWizardPageFactory pythonWizardPageFactory;
|
2018-02-06 12:46:02 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-15 16:21:30 +01:00
|
|
|
class PythonPlugin final : public ExtensionSystem::IPlugin
|
2013-01-14 23:11:10 +04:00
|
|
|
{
|
2024-01-15 16:21:30 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Python.json")
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2024-01-15 16:21:30 +01:00
|
|
|
public:
|
|
|
|
|
PythonPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~PythonPlugin() final
|
|
|
|
|
{
|
|
|
|
|
m_instance = nullptr;
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void initialize() final
|
|
|
|
|
{
|
|
|
|
|
d = new PythonPluginPrivate;
|
|
|
|
|
|
2024-01-15 16:31:41 +01:00
|
|
|
setupPythonEditorFactory(this);
|
|
|
|
|
|
2024-01-15 16:21:30 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void extensionsInitialized() final
|
|
|
|
|
{
|
|
|
|
|
// Add MIME overlay icons (these icons displayed at Project dock panel)
|
|
|
|
|
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
|
2024-01-12 14:04:37 +01:00
|
|
|
ProjectExplorer::Constants::FILEOVERLAY_PY);
|
2024-01-15 16:21:30 +01:00
|
|
|
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
|
|
|
|
|
|
|
|
|
|
TaskHub::addCategory({PythonErrorTaskCategory,
|
|
|
|
|
"Python",
|
|
|
|
|
Tr::tr("Issues parsed from Python runtime output."),
|
|
|
|
|
true});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PythonPluginPrivate *d = nullptr;
|
|
|
|
|
};
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2023-01-06 13:56:00 +01:00
|
|
|
} // Python::Internal
|
2024-01-15 16:21:30 +01:00
|
|
|
|
|
|
|
|
#include "pythonplugin.moc"
|