Commit 6c9ba0eb authored by J-P Nurmi's avatar J-P Nurmi
Browse files

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: default avatarMitch Curtis <mitch.curtis@digia.com>
Reviewed-by: default avatarCaroline Chao <caroline.chao@theqtcompany.com>
Showing with 11 additions and 5 deletions
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment