From 2e353aa1b24151dbb6a410aa30f05a01c9f40179 Mon Sep 17 00:00:00 2001 From: Mathias Hasselmann Date: Mon, 8 Jan 2024 16:54:15 +0100 Subject: [PATCH] TextEditor: Give access to m_toolBarWidget The TextEditor doesn't export its actual toolbar via IEditor::toolBar(), but an internal container widget. This forces other editors that want to reuse TextEditorWidget to poke into internal details of TextEditorWidget if they want to provide the full toolbar including line number button. By giving access to m_toolBarWidget, other editors like the Markdown editor can show the full toolbar including line numbers without risking to break, if TextEditorWidget should refactor its toolbar container. Task-number: QTCREATORBUG-30166 Change-Id: Ic54f21be1897f00801c6a3cfe29c89131d61e3a5 Reviewed-by: David Schulz --- src/plugins/texteditor/texteditor.cpp | 9 +++++++-- src/plugins/texteditor/texteditor.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 49de5496d41..f9713c4df42 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -8762,7 +8762,7 @@ IDocument *BaseTextEditor::document() const QWidget *BaseTextEditor::toolBar() { - return editorWidget()->d->m_toolBarWidget; + return editorWidget()->toolBarWidget(); } QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side, @@ -8923,7 +8923,12 @@ void TextEditorWidget::setCursorPosition(int pos) setTextCursor(tc); } -QToolBar *TextEditorWidget::toolBar() +QWidget *TextEditorWidget::toolBarWidget() const +{ + return d->m_toolBarWidget; +} + +QToolBar *TextEditorWidget::toolBar() const { return d->m_toolBar; } diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 2674c1811c7..a2a1aafb2b8 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -179,7 +179,8 @@ public: using QPlainTextEdit::cursorRect; QRect cursorRect(int pos) const; void setCursorPosition(int pos); - QToolBar *toolBar(); + QWidget *toolBarWidget() const; + QToolBar *toolBar() const; void print(QPrinter *);