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>
This commit is contained in:
Ahmad Samir
2021-06-14 11:56:27 +02:00
parent b1926e41c5
commit 8ef025f732

View File

@@ -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);
}
}