From c1479a9d971b1add0aad43a5e06ad266b2dff9d1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Date: Mon, 25 Mar 2013 18:42:21 +0100 Subject: [PATCH] ComboBox: Fix style content size calculation Expression taken from QComboBox. Also, cleaner way of setting the popup item font size where needed. Change-Id: Ic6997e8d887dafc519a3827c2a40cb8f91503ebc Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> --- src/controls/ComboBox.qml | 8 ++++++-- src/styles/Desktop/ComboBoxStyle.qml | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index fadd2a16e..5127954eb 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -104,7 +104,11 @@ Control { onPressedChanged: if (pressed) popup.show() } - StyleItem { id: styleItem } + StyleItem { + id: styleItem + elementType: "comboboxitem" + visible: false + } Component.onCompleted: { if (currentIndex === -1) @@ -112,7 +116,6 @@ Control { if (styleItem.style == "mac") { popup.x -= 10 popup.y += 4 - popup.__font.pointSize = 13 } popup.ready = true @@ -136,6 +139,7 @@ Control { property int y: isPopup ? (comboBox.__panel.height - comboBox.__panel.implicitHeight) / 2.0 : comboBox.__panel.height __minimumWidth: comboBox.width __visualItem: comboBox + __font: styleItem.font property ExclusiveGroup eg: ExclusiveGroup { id: eg } diff --git a/src/styles/Desktop/ComboBoxStyle.qml b/src/styles/Desktop/ComboBoxStyle.qml index 252d59723..36d00dc4d 100644 --- a/src/styles/Desktop/ComboBoxStyle.qml +++ b/src/styles/Desktop/ComboBoxStyle.qml @@ -54,7 +54,8 @@ Style { enabled: control.enabled text: control.currentText hasFocus: control.activeFocus - contentHeight: 18 + // contentHeight as in QComboBox + contentHeight: Math.max(Math.ceil(textHeight("")), 14) + 2 contentWidth: textWidth(text) } -- GitLab