aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/jsoneditor.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2024-01-26 16:01:31 +0100
committerhjk <hjk@qt.io>2024-01-29 14:22:22 +0000
commitd4635d438939a7195c81df2d387b553358504e84 (patch)
tree8f894854e3901dd9a8f530cf9590ef8633f1140e /src/plugins/texteditor/jsoneditor.cpp
parentd2db92e248bbd78e5a602361fcb28f7ef07c3ba7 (diff)
TextEditor: Use new setup pattern for markdown and json editor
And remove the now-empty plugin pimpl. Change-Id: Ie00b747a4a41bc6efc84ea43db81a71e8364df3d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/texteditor/jsoneditor.cpp')
-rw-r--r--src/plugins/texteditor/jsoneditor.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/plugins/texteditor/jsoneditor.cpp b/src/plugins/texteditor/jsoneditor.cpp
index eb0ed132786..d06f215c688 100644
--- a/src/plugins/texteditor/jsoneditor.cpp
+++ b/src/plugins/texteditor/jsoneditor.cpp
@@ -5,6 +5,7 @@
#include "autocompleter.h"
#include "textdocument.h"
+#include "texteditor.h"
#include "texteditoractionhandler.h"
#include "texteditortr.h"
#include "textindenter.h"
@@ -149,19 +150,28 @@ public:
}
};
-JsonEditorFactory::JsonEditorFactory()
+class JsonEditorFactory final : public TextEditorFactory
{
- setId(JSON_EDITOR_ID);
- setDisplayName(Tr::tr("JSON Editor"));
- addMimeType(Utils::Constants::JSON_MIMETYPE);
-
- setEditorCreator([] { return new BaseTextEditor; });
- setEditorWidgetCreator([] { return new TextEditorWidget; });
- setDocumentCreator([] { return new TextDocument(JSON_EDITOR_ID); });
- setAutoCompleterCreator([] { return new JsonAutoCompleter; });
- setIndenterCreator([](QTextDocument *doc) { return new JsonIndenter(doc); });
- setEditorActionHandlers(TextEditorActionHandler::Format);
- setUseGenericHighlighter(true);
+public:
+ JsonEditorFactory()
+ {
+ setId(JSON_EDITOR_ID);
+ setDisplayName(Tr::tr("JSON Editor"));
+ addMimeType(Utils::Constants::JSON_MIMETYPE);
+
+ setEditorCreator([] { return new BaseTextEditor; });
+ setEditorWidgetCreator([] { return new TextEditorWidget; });
+ setDocumentCreator([] { return new TextDocument(JSON_EDITOR_ID); });
+ setAutoCompleterCreator([] { return new JsonAutoCompleter; });
+ setIndenterCreator([](QTextDocument *doc) { return new JsonIndenter(doc); });
+ setEditorActionHandlers(TextEditorActionHandler::Format);
+ setUseGenericHighlighter(true);
+ }
+};
+
+void setupJsonEditor()
+{
+ static JsonEditorFactory theJsonEditorFactory;
}
-} // namespace TextEditor::Internal
+} // TextEditor::Internal