aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2022-03-21 13:36:44 +0100
committerDoris Verria <doris.verria@qt.io>2022-03-24 09:35:38 +0000
commitbb7891f35026c3a9cf8641c2d0e815580d4a9a43 (patch)
tree141f60cc4b1841c52cc0ad05baf187c6fadf0203
parente02285d01823ded3530cb961d655a780f9a0393a (diff)
iOS Style: Set appropriate color if the button doesn't draw background
The UIButton can have different configurations (styles), one of which being a filled button style, which draws a background on the button, and a plain style that doesn't, making the button look more like a label. For our Button control in the iOS style, we opted to go with the latter look (plain style, no background) for the flat button, and draw a background for the normal state. In that case, draw the button text in the appropriate colors, similar to the native look. Change-Id: Ic19c2eb82a3184869af26fcf2980d94d6ceeb189 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quickcontrols2/ios/Button.qml4
-rw-r--r--src/quickcontrols2/ios/qquickiostheme.mm10
2 files changed, 11 insertions, 3 deletions
diff --git a/src/quickcontrols2/ios/Button.qml b/src/quickcontrols2/ios/Button.qml
index ca603004c3..72f17a9c3c 100644
--- a/src/quickcontrols2/ios/Button.qml
+++ b/src/quickcontrols2/ios/Button.qml
@@ -67,7 +67,9 @@ T.Button {
icon: control.icon
text: control.text
font: control.font
- color: control.palette.buttonText
+ color: control.flat ? (control.enabled ? (control.down ? control.palette.highlight : control.palette.button)
+ : control.palette.mid)
+ : control.palette.buttonText
}
background: Rectangle {
diff --git a/src/quickcontrols2/ios/qquickiostheme.mm b/src/quickcontrols2/ios/qquickiostheme.mm
index 9df29435f7..bcda134e81 100644
--- a/src/quickcontrols2/ios/qquickiostheme.mm
+++ b/src/quickcontrols2/ios/qquickiostheme.mm
@@ -56,18 +56,22 @@ void QQuickIOSTheme::initialize(QQuickTheme *theme)
QColor blue;
QColor white;
QColor disabled;
+ QColor grey;
#ifdef Q_OS_IOS
blue = qt_mac_toQColor(UIColor.systemBlueColor.CGColor);
disabled = qt_mac_toQColor(UIColor.tertiarySystemFillColor.CGColor);
white = qt_mac_toQColor(UIColor.whiteColor.CGColor);
+ grey = qt_mac_toQColor(UIColor.systemGrayColor.CGColor);
#else
blue = QColor(qRgba(0, 122, 255, 255));
white = QColor(qRgba(255, 255, 255, 255));
disabled = QColor(qRgba(118, 118, 128, 31));
+ grey = QColor(qRgba(142, 142, 147, 255));
#endif
- systemPalette.setColor(QPalette::Active, QPalette::Button, blue);
+ systemPalette.setColor(QPalette::Button, blue);
systemPalette.setColor(QPalette::Disabled, QPalette::Button, disabled);
- systemPalette.setColor(QPalette::Active, QPalette::ButtonText, white);
+
+ systemPalette.setColor(QPalette::ButtonText, white);
white.setAlphaF(0.5);
systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText, white);
@@ -75,6 +79,8 @@ void QQuickIOSTheme::initialize(QQuickTheme *theme)
blue.setAlphaF(0.8);
systemPalette.setColor(QPalette::Highlight, blue);
+ systemPalette.setColor(QPalette::Mid, grey);
+
theme->setPalette(QQuickTheme::System, systemPalette);
}