aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythoneditor.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2024-01-15 16:31:41 +0100
committerhjk <hjk@qt.io>2024-01-16 10:43:06 +0000
commit5de41fb40df2bc229fb32b1d7d3836daea5e0474 (patch)
tree4e516c026646a46724429726d478568654ef4bb7 /src/plugins/python/pythoneditor.cpp
parent1992efddfc2617d77d3e39ac3c2e6a4bf8d66a19 (diff)
Python: Use new plugin items setup pattern for PythonEditor
Change-Id: Ie8516960a106ddeff415b6412d9af66f7d2f0f36 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/python/pythoneditor.cpp')
-rw-r--r--src/plugins/python/pythoneditor.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/plugins/python/pythoneditor.cpp b/src/plugins/python/pythoneditor.cpp
index 1c74838ea4b..a4efb19e63d 100644
--- a/src/plugins/python/pythoneditor.cpp
+++ b/src/plugins/python/pythoneditor.cpp
@@ -10,7 +10,6 @@
#include "pythonindenter.h"
#include "pythonkitaspect.h"
#include "pythonlanguageclient.h"
-#include "pythonplugin.h"
#include "pythonsettings.h"
#include "pythontr.h"
#include "pythonutils.h"
@@ -28,6 +27,7 @@
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
+#include <texteditor/texteditor.h>
#include <texteditor/texteditoractionhandler.h>
#include <utils/stylehelper.h>
@@ -278,28 +278,6 @@ void PythonEditorWidget::updateInterpretersSelector()
});
}
-PythonEditorFactory::PythonEditorFactory()
-{
- registerReplAction(&m_guard);
-
- setId(Constants::C_PYTHONEDITOR_ID);
- setDisplayName(::Core::Tr::tr(Constants::C_EDITOR_DISPLAY_NAME));
- addMimeType(Constants::C_PY_MIMETYPE);
-
- setEditorActionHandlers(TextEditorActionHandler::Format
- | TextEditorActionHandler::UnCommentSelection
- | TextEditorActionHandler::UnCollapseAll
- | TextEditorActionHandler::FollowSymbolUnderCursor);
-
- setDocumentCreator([]() { return new PythonDocument; });
- setEditorWidgetCreator([]() { return new PythonEditorWidget; });
- setIndenterCreator(&createPythonIndenter);
- setSyntaxHighlighterCreator(&createPythonHighlighter);
- setCommentDefinition(CommentDefinition::HashStyle);
- setParenthesesMatchingEnabled(true);
- setCodeFoldingSupported(true);
-}
-
PythonDocument::PythonDocument()
: TextDocument(Constants::C_PYTHONEDITOR_ID)
{
@@ -331,4 +309,35 @@ void PythonDocument::updatePython(const FilePath &python)
emit pythonUpdated(python);
}
+class PythonEditorFactory final : public TextEditorFactory
+{
+public:
+ PythonEditorFactory()
+ {
+ setId(Constants::C_PYTHONEDITOR_ID);
+ setDisplayName(::Core::Tr::tr(Constants::C_EDITOR_DISPLAY_NAME));
+ addMimeType(Constants::C_PY_MIMETYPE);
+
+ setEditorActionHandlers(TextEditorActionHandler::Format
+ | TextEditorActionHandler::UnCommentSelection
+ | TextEditorActionHandler::UnCollapseAll
+ | TextEditorActionHandler::FollowSymbolUnderCursor);
+
+ setDocumentCreator([]() { return new PythonDocument; });
+ setEditorWidgetCreator([]() { return new PythonEditorWidget; });
+ setIndenterCreator(&createPythonIndenter);
+ setSyntaxHighlighterCreator(&createPythonHighlighter);
+ setCommentDefinition(CommentDefinition::HashStyle);
+ setParenthesesMatchingEnabled(true);
+ setCodeFoldingSupported(true);
+ }
+};
+
+void setupPythonEditorFactory(QObject *guard)
+{
+ static PythonEditorFactory thePythonEditorFactory;
+
+ registerReplAction(guard);
+}
+
} // Python::Internal