From d43f1662d0b44b3b930989f11604661c377bd67e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 11 Feb 2020 14:00:09 +0100 Subject: Make TextEditor setup more flexible So far it was only possible to combine TextEditorFactory, BaseTextEditor and TextEditorWidget directly. That TextEditorWidget is also directly a QPlainTextEdit made it impossible to "decorate" the text editor widget with something else without a lot of effort. Make it possible to create a text editor factory that returns an arbitrary widget, as long as it can be "cast" to a TextEditorWidget with either qobject_cast or Aggregation::query. That way the TextEditorWidget instance can be attached to the editor widget via Aggregation. Adapt other code that accesses TextEditorWidget from editors accordingly. Introduce a common method how to do that. Change-Id: I72b8721f3a8a8d8281c39af75253e9c80cbe1250 Reviewed-by: Orgad Shaneh Reviewed-by: David Schulz --- src/plugins/bookmarks/bookmarksplugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/bookmarks') diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 06eb6b49c9..911702cc1d 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -190,7 +190,7 @@ void BookmarksPluginPrivate::updateActions(bool enableToggle, int state) void BookmarksPluginPrivate::editorOpened(IEditor *editor) { - if (auto widget = qobject_cast(editor->widget())) { + if (auto widget = TextEditorWidget::fromEditor(editor)) { connect(widget, &TextEditorWidget::markRequested, this, [this, editor](TextEditorWidget *, int line, TextMarkRequestKind kind) { if (kind == BookmarkRequest && !editor->document()->isTemporary()) @@ -204,7 +204,7 @@ void BookmarksPluginPrivate::editorOpened(IEditor *editor) void BookmarksPluginPrivate::editorAboutToClose(IEditor *editor) { - if (auto widget = qobject_cast(editor->widget())) { + if (auto widget = TextEditorWidget::fromEditor(editor)) { disconnect(widget, &TextEditorWidget::markContextMenuRequested, this, &BookmarksPluginPrivate::requestContextMenu); } -- cgit v1.2.3