summaryrefslogtreecommitdiff
path: root/src/controls/Styles/Android
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2014-11-09 13:12:21 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2014-11-10 12:18:25 +0100
commit6c9ba0eb17e28719c50eef00c69f812aa2deba0a (patch)
tree24dd80fb57637c18aeb8372ec73d219d9dfdc006 /src/controls/Styles/Android
parent1e985e46476398bf75118480edc4d15547764f7e (diff)
downloadqtquickcontrols-6c9ba0eb17e28719c50eef00c69f812aa2deba0a.tar.gz
Android/SwitchStyle: use TextMetrics instead of FontMetrics
Ensures that the thumb text width is correctly calculated regardless of QML's arbitrary binding evaluation order. Change-Id: I71526db963fec6d54ad717f46382537591268e37 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
Diffstat (limited to 'src/controls/Styles/Android')
-rw-r--r--src/controls/Styles/Android/SwitchStyle.qml16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/controls/Styles/Android/SwitchStyle.qml b/src/controls/Styles/Android/SwitchStyle.qml
index 4c36c918..8401d353 100644
--- a/src/controls/Styles/Android/SwitchStyle.qml
+++ b/src/controls/Styles/Android/SwitchStyle.qml
@@ -81,16 +81,22 @@ SwitchStyle {
x: control.checked ? max : min
- FontMetrics {
- id: metrics
+ TextMetrics {
+ id: onMetrics
font: label.font
+ text: panel.styleDef.Switch_textOn
}
- readonly property real maxTextWidth: Math.max(metrics.boundingRect(panel.styleDef.Switch_textOn).width,
- metrics.boundingRect(panel.styleDef.Switch_textOff).width)
+ TextMetrics {
+ id: offMetrics
+ font: label.font
+ text: panel.styleDef.Switch_textOff
+ }
+
+ readonly property real maxTextWidth: Math.max(onMetrics.width, offMetrics.width)
implicitWidth: Math.max(loader.implicitWidth, maxTextWidth + 2 * panel.styleDef.Switch_thumbTextPadding)
- implicitHeight: Math.max(loader.implicitHeight, metrics.height)
+ implicitHeight: Math.max(loader.implicitHeight, onMetrics.height, offMetrics.height)
anchors.top: parent.top
anchors.bottom: parent.bottom