diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2021-06-14 11:56:27 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-06-14 11:09:22 +0000 |
commit | 8ef025f7326c37c2b74b33fa5979b83f816b8f23 (patch) | |
tree | 94a913e15db12569600608cb7a044166e6140597 | |
parent | b1926e41c5528fc569f2e0ec9af762001bc101d0 (diff) | |
download | qt-creator-8ef025f7326c37c2b74b33fa5979b83f816b8f23.tar.gz |
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 <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
-rw-r--r-- | src/plugins/coreplugin/manhattanstyle.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 875c228ab5..a6bf33491a 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<QToolButton*>(widget) || qobject_cast<QLineEdit*>(widget)) { widget->setAttribute(Qt::WA_Hover); - widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2); + widget->setMaximumHeight(height - 2); } else if (qobject_cast<QLabel*>(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<QStatusBar*>(widget)) { - widget->setFixedHeight(StyleHelper::navigationWidgetHeight() + 2); + widget->setFixedHeight(height + 2); } else if (qobject_cast<QComboBox*>(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); } } |