forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -220,9 +220,6 @@ void CppEditorWidget::finalizeInitialization()
|
|||||||
d->m_cppSelectionChanger.onCursorPositionChanged(textCursor());
|
d->m_cppSelectionChanger.onCursorPositionChanged(textCursor());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Toolbar: Outline/Overview combo box
|
|
||||||
insertExtraToolBarWidget(TextEditorWidget::Left, d->m_cppEditorOutline->widget());
|
|
||||||
|
|
||||||
// Toolbar: Parse context
|
// Toolbar: Parse context
|
||||||
ParseContextModel &parseContextModel = cppEditorDocument()->parseContextModel();
|
ParseContextModel &parseContextModel = cppEditorDocument()->parseContextModel();
|
||||||
d->m_parseContextWidget = new ParseContextWidget(parseContextModel, this);
|
d->m_parseContextWidget = new ParseContextWidget(parseContextModel, this);
|
||||||
@@ -233,6 +230,10 @@ void CppEditorWidget::finalizeInitialization()
|
|||||||
this, [this](bool areMultipleAvailable) {
|
this, [this](bool areMultipleAvailable) {
|
||||||
d->m_parseContextAction->setVisible(areMultipleAvailable);
|
d->m_parseContextAction->setVisible(areMultipleAvailable);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Toolbar: Outline/Overview combo box
|
||||||
|
insertExtraToolBarWidget(TextEditorWidget::Left, d->m_cppEditorOutline->widget());
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
// Toolbar: '#' Button
|
// Toolbar: '#' Button
|
||||||
// TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model.
|
// TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model.
|
||||||
|
@@ -109,10 +109,9 @@ CppEditorOutline::CppEditorOutline(TextEditor::TextEditorWidget *editorWidget)
|
|||||||
// Set up combo box
|
// Set up combo box
|
||||||
m_combo->setModel(m_proxyModel);
|
m_combo->setModel(m_proxyModel);
|
||||||
|
|
||||||
m_combo->setMinimumContentsLength(22);
|
m_combo->setMinimumContentsLength(13);
|
||||||
QSizePolicy policy = m_combo->sizePolicy();
|
QSizePolicy policy = m_combo->sizePolicy();
|
||||||
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||||
policy.setHorizontalStretch(2);
|
|
||||||
m_combo->setSizePolicy(policy);
|
m_combo->setSizePolicy(policy);
|
||||||
m_combo->setMaxVisibleItems(40);
|
m_combo->setMaxVisibleItems(40);
|
||||||
|
|
||||||
|
@@ -607,11 +607,11 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TextEditorWidget *q;
|
TextEditorWidget *q;
|
||||||
|
QWidget *m_toolBarWidget = nullptr;
|
||||||
QToolBar *m_toolBar = nullptr;
|
QToolBar *m_toolBar = nullptr;
|
||||||
QWidget *m_stretchWidget = nullptr;
|
QWidget *m_stretchWidget = nullptr;
|
||||||
LineColumnLabel *m_cursorPositionLabel = nullptr;
|
LineColumnLabel *m_cursorPositionLabel = nullptr;
|
||||||
FixedSizeClickLabel *m_fileEncodingLabel = nullptr;
|
FixedSizeClickLabel *m_fileEncodingLabel = nullptr;
|
||||||
QAction *m_cursorPositionLabelAction = nullptr;
|
|
||||||
QAction *m_fileEncodingLabelAction = nullptr;
|
QAction *m_fileEncodingLabelAction = nullptr;
|
||||||
|
|
||||||
bool m_contentsChanged = false;
|
bool m_contentsChanged = false;
|
||||||
@@ -799,21 +799,27 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
|||||||
m_extraArea = new TextEditExtraArea(q);
|
m_extraArea = new TextEditExtraArea(q);
|
||||||
m_extraArea->setMouseTracking(true);
|
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 = new QWidget;
|
||||||
m_stretchWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
m_stretchWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
m_toolBar = new QToolBar;
|
m_toolBar = new QToolBar;
|
||||||
m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||||
m_toolBar->addWidget(m_stretchWidget);
|
m_toolBar->addWidget(m_stretchWidget);
|
||||||
|
m_toolBarWidget->layout()->addWidget(m_toolBar);
|
||||||
|
|
||||||
m_cursorPositionLabel = new LineColumnLabel(q);
|
m_cursorPositionLabel = new LineColumnLabel(q);
|
||||||
const int spacing = q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2;
|
const int spacing = q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2;
|
||||||
m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0);
|
m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0);
|
||||||
|
m_toolBarWidget->layout()->addWidget(m_cursorPositionLabel);
|
||||||
|
|
||||||
m_fileEncodingLabel = new FixedSizeClickLabel;
|
m_fileEncodingLabel = new FixedSizeClickLabel;
|
||||||
m_fileEncodingLabel->setContentsMargins(spacing, 0, spacing, 0);
|
m_fileEncodingLabel->setContentsMargins(spacing, 0, spacing, 0);
|
||||||
|
|
||||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
|
||||||
m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel);
|
m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel);
|
||||||
|
|
||||||
m_extraSelections.reserve(NExtraSelectionKinds);
|
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,7 +828,7 @@ TextEditorWidgetPrivate::~TextEditorWidgetPrivate()
|
|||||||
QObject::disconnect(m_document.data(), &TextDocument::markRemoved,
|
QObject::disconnect(m_document.data(), &TextDocument::markRemoved,
|
||||||
this, &TextEditorWidgetPrivate::markRemoved);
|
this, &TextEditorWidgetPrivate::markRemoved);
|
||||||
q->disconnect(this);
|
q->disconnect(this);
|
||||||
delete m_toolBar;
|
delete m_toolBarWidget;
|
||||||
delete m_highlightScrollBarController;
|
delete m_highlightScrollBarController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7808,7 +7814,7 @@ IDocument *BaseTextEditor::document()
|
|||||||
|
|
||||||
QWidget *BaseTextEditor::toolBar()
|
QWidget *BaseTextEditor::toolBar()
|
||||||
{
|
{
|
||||||
return editorWidget()->d->m_toolBar;
|
return editorWidget()->d->m_toolBarWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side,
|
QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side,
|
||||||
@@ -7821,7 +7827,7 @@ QAction * TextEditorWidget::insertExtraToolBarWidget(TextEditorWidget::Side side
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (side == Right)
|
if (side == Right)
|
||||||
return d->m_toolBar->insertWidget(d->m_cursorPositionLabelAction, widget);
|
return d->m_toolBar->insertWidget(d->m_fileEncodingLabelAction, widget);
|
||||||
else
|
else
|
||||||
return d->m_toolBar->insertWidget(d->m_toolBar->actions().constFirst(), widget);
|
return d->m_toolBar->insertWidget(d->m_toolBar->actions().constFirst(), widget);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user