From 8ef025f7326c37c2b74b33fa5979b83f816b8f23 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 14 Jun 2021 11:56:27 +0200 Subject: [PATCH] ManhattanStyle: ensure text isn't cut-off in some UI elements navigationWidgetHeight() is used in various places to calculate the height of UI widgets that display text, e.g. the line-edits in the search bar, hardconding a value results in the text being cut-off if bigger fonts are used; fix the issue by using the higher value of navigationWidgetHeight() and fontMetrics().height(), this ensures widgets will accommodate the text. Fixes: QTCREATORBUG-24535 Change-Id: I83ca7885840a75e05e913f7ecc77a60e61f8ef9b Reviewed-by: Eike Ziller Reviewed-by: Alessandro Portale --- src/plugins/coreplugin/manhattanstyle.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 875c228ab57..a6bf33491a0 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -282,15 +282,17 @@ void ManhattanStyle::polish(QWidget *widget) widget->setContentsMargins(0, 0, 0, 0); widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); + // So that text isn't cutoff in line-edits, comboboxes... etc. + const int height = qMax(StyleHelper::navigationWidgetHeight(), QApplication::fontMetrics().height()); if (qobject_cast(widget) || qobject_cast(widget)) { widget->setAttribute(Qt::WA_Hover); - widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2); + widget->setMaximumHeight(height - 2); } else if (qobject_cast(widget)) { widget->setPalette(panelPalette(widget->palette(), lightColored(widget))); } else if (widget->property("panelwidget_singlerow").toBool()) { - widget->setFixedHeight(StyleHelper::navigationWidgetHeight()); + widget->setFixedHeight(height); } else if (qobject_cast(widget)) { - widget->setFixedHeight(StyleHelper::navigationWidgetHeight() + 2); + widget->setFixedHeight(height + 2); } else if (qobject_cast(widget)) { const bool isLightColored = lightColored(widget); QPalette palette = panelPalette(widget->palette(), isLightColored); @@ -298,7 +300,7 @@ void ManhattanStyle::polish(QWidget *widget) palette.setBrush(QPalette::All, QPalette::WindowText, creatorTheme()->color(Theme::ComboBoxTextColor)); widget->setPalette(palette); - widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2); + widget->setMaximumHeight(height - 2); widget->setAttribute(Qt::WA_Hover); } }