From 95edda95b439c66148a15905c83243a6475b5df0 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 26 Aug 2022 22:23:23 +0900 Subject: [PATCH] Set ElideMiddle for the editor combobox When Qt Creator opens more than one file with same name, the path to be shown tend to long. In this case last part (file name) is as important as first part. paths in Locator and Open Document are elided in the middle of path already. Change-Id: I953a8068b50331f9ef20ad9efbd947b4dbcf0845 Reviewed-by: Alessandro Portale Reviewed-by: --- src/plugins/coreplugin/editortoolbar.cpp | 1 + src/plugins/coreplugin/manhattanstyle.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 85923d697fb..76f10ba15ef 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -119,6 +119,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) : d->m_editorList->setProperty("hideicon", true); d->m_editorList->setProperty("notelideasterisk", true); + d->m_editorList->setProperty("elidemode", Qt::ElideMiddle); d->m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); d->m_editorList->setMinimumContentsLength(20); d->m_editorList->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index af050a3e850..43b30b65550 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -886,7 +886,10 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt elideWidth -= option->fontMetrics.horizontalAdvance(asterisk); text = asterisk; } - text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); + Qt::TextElideMode elideMode = Qt::ElideRight; + if (widget && widget->dynamicPropertyNames().contains("elidemode")) + elideMode = widget->property("elidemode").value(); + text.prepend(option->fontMetrics.elidedText(cb->currentText, elideMode, elideWidth)); if (creatorTheme()->flag(Theme::ComboBoxDrawTextShadow) && (option->state & State_Enabled))