forked from qt-creator/qt-creator
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 <orgads@gmail.com> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -556,6 +556,7 @@ public:
|
||||
void setContextHelpItem(const Core::HelpItem &item);
|
||||
|
||||
static TextEditorWidget *currentTextEditorWidget();
|
||||
static TextEditorWidget *fromEditor(const Core::IEditor *editor);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
@@ -641,7 +642,8 @@ public:
|
||||
|
||||
using EditorCreator = std::function<BaseTextEditor *()>;
|
||||
using DocumentCreator = std::function<TextDocument *()>;
|
||||
using EditorWidgetCreator = std::function<TextEditorWidget *()>;
|
||||
// editor widget must be castable (qobject_cast or Aggregate::query) to TextEditorWidget
|
||||
using EditorWidgetCreator = std::function<QWidget *()>;
|
||||
using SyntaxHighLighterCreator = std::function<SyntaxHighlighter *()>;
|
||||
using IndenterCreator = std::function<Indenter *(QTextDocument *)>;
|
||||
using AutoCompleterCreator = std::function<AutoCompleter *()>;
|
||||
|
||||
Reference in New Issue
Block a user