diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-04-23 17:03:50 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-04-25 07:10:52 +0000 |
commit | a8aa4bbb312d163c1fffaa59102a49c77458404c (patch) | |
tree | 70292e2d37371fe8e9d3cafc3692667ee1020198 | |
parent | a09bc8d7fa91a4a4b07eeefa4d625ced2d96b078 (diff) | |
download | qt-creator-a8aa4bbb312d163c1fffaa59102a49c77458404c.tar.gz |
More improvements of text editor tool bar
Make line/column label always visible, and move context drop down to the
right, so it vanishes first. Reduce the minimum size and stretch of the
outline drop down, so the context drop down doesn't vanish too early
either.
Task-number: QTCREATORBUG-15218
Task-number: QTCREATORBUG-19386
Change-Id: Ie2ced1cb62a27a0129438f5605d5711bfac50cd0
Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r-- | src/plugins/cppeditor/cppeditorwidget.cpp | 7 | ||||
-rw-r--r-- | src/plugins/cpptools/cppeditoroutline.cpp | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 18 |
3 files changed, 17 insertions, 11 deletions
diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index d495af6c2a..c66ec3b284 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -220,9 +220,6 @@ void CppEditorWidget::finalizeInitialization() d->m_cppSelectionChanger.onCursorPositionChanged(textCursor()); }); - // Toolbar: Outline/Overview combo box - insertExtraToolBarWidget(TextEditorWidget::Left, d->m_cppEditorOutline->widget()); - // Toolbar: Parse context ParseContextModel &parseContextModel = cppEditorDocument()->parseContextModel(); d->m_parseContextWidget = new ParseContextWidget(parseContextModel, this); @@ -233,6 +230,10 @@ void CppEditorWidget::finalizeInitialization() this, [this](bool areMultipleAvailable) { d->m_parseContextAction->setVisible(areMultipleAvailable); }); + + // Toolbar: Outline/Overview combo box + insertExtraToolBarWidget(TextEditorWidget::Left, d->m_cppEditorOutline->widget()); + // clang-format on // Toolbar: '#' Button // TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model. diff --git a/src/plugins/cpptools/cppeditoroutline.cpp b/src/plugins/cpptools/cppeditoroutline.cpp index b3a751e664..a71e027cdc 100644 --- a/src/plugins/cpptools/cppeditoroutline.cpp +++ b/src/plugins/cpptools/cppeditoroutline.cpp @@ -109,10 +109,9 @@ CppEditorOutline::CppEditorOutline(TextEditor::TextEditorWidget *editorWidget) // Set up combo box m_combo->setModel(m_proxyModel); - m_combo->setMinimumContentsLength(22); + m_combo->setMinimumContentsLength(13); QSizePolicy policy = m_combo->sizePolicy(); policy.setHorizontalPolicy(QSizePolicy::Expanding); - policy.setHorizontalStretch(2); m_combo->setSizePolicy(policy); m_combo->setMaxVisibleItems(40); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 4fde5868b9..9d3b58f9b0 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -607,11 +607,11 @@ public: public: TextEditorWidget *q; + QWidget *m_toolBarWidget = nullptr; QToolBar *m_toolBar = nullptr; QWidget *m_stretchWidget = nullptr; LineColumnLabel *m_cursorPositionLabel = nullptr; FixedSizeClickLabel *m_fileEncodingLabel = nullptr; - QAction *m_cursorPositionLabelAction = nullptr; QAction *m_fileEncodingLabelAction = nullptr; bool m_contentsChanged = false; @@ -799,21 +799,27 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent) m_extraArea = new TextEditExtraArea(q); m_extraArea->setMouseTracking(true); + auto toolBarLayout = new QHBoxLayout; + toolBarLayout->setContentsMargins(0, 0, 0, 0); + toolBarLayout->setSpacing(0); + m_toolBarWidget = new QWidget; + m_toolBarWidget->setLayout(toolBarLayout); m_stretchWidget = new QWidget; m_stretchWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_toolBar = new QToolBar; m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); m_toolBar->addWidget(m_stretchWidget); + m_toolBarWidget->layout()->addWidget(m_toolBar); m_cursorPositionLabel = new LineColumnLabel(q); const int spacing = q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2; m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0); + m_toolBarWidget->layout()->addWidget(m_cursorPositionLabel); m_fileEncodingLabel = new FixedSizeClickLabel; m_fileEncodingLabel->setContentsMargins(spacing, 0, spacing, 0); - - m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel); m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel); + m_extraSelections.reserve(NExtraSelectionKinds); } @@ -822,7 +828,7 @@ TextEditorWidgetPrivate::~TextEditorWidgetPrivate() QObject::disconnect(m_document.data(), &TextDocument::markRemoved, this, &TextEditorWidgetPrivate::markRemoved); q->disconnect(this); - delete m_toolBar; + delete m_toolBarWidget; delete m_highlightScrollBarController; } @@ -7808,7 +7814,7 @@ IDocument *BaseTextEditor::document() QWidget *BaseTextEditor::toolBar() { - return editorWidget()->d->m_toolBar; + return editorWidget()->d->m_toolBarWidget; } QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side, @@ -7821,7 +7827,7 @@ QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side } if (side == Right) - return d->m_toolBar->insertWidget(d->m_cursorPositionLabelAction, widget); + return d->m_toolBar->insertWidget(d->m_fileEncodingLabelAction, widget); else return d->m_toolBar->insertWidget(d->m_toolBar->actions().constFirst(), widget); } |