Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ternary-op-color-fix into lp:ubuntu-ui-toolkit

Proposed by Loïc Molinari
Status: Merged
Approved by: Florian Boucault
Approved revision: 584
Merged at revision: 583
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ternary-op-color-fix
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 23 lines (+9/-2)
1 file modified
modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml (+9/-2)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ternary-op-color-fix
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+173072@code.launchpad.net

Commit message

Added workaround for QML buggy support for color props in ternary ops.

Description of the change

Added workaround for QML buggy support for color props in ternary ops.

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

For code clarity and avoiding repetition, I would create a function:

function colorFromColor(color) {
    return Qt.rgba(color.r, color.g, color.b, color.a);
}

Revision history for this message
Florian Boucault (fboucault) wrote :

It'd be best to report the bug to Qt and put the link to that bug report along with our workaround before we merge.

Revision history for this message
Florian Boucault (fboucault) wrote :

> For code clarity and avoiding repetition, I would create a function:
>
> function colorFromColor(color) {
> return Qt.rgba(color.r, color.g, color.b, color.a);
> }

oh, and yeah colorFromColor is a terrible name!

Revision history for this message
Florian Boucault (fboucault) wrote :

> It'd be best to report the bug to Qt and put the link to that bug report along
> with our workaround before we merge.

Bug report in Qt just reported describing the issue: https://bugreports.qt-project.org/browse/QTBUG-32238

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Yup, this helps.

review: Approve
584. By Loïc Molinari

Added link to bug report and func for color hack.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml'
2--- modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml 2013-07-02 00:15:07 +0000
3+++ modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml 2013-07-04 21:56:26 +0000
4@@ -63,10 +63,17 @@
5 UbuntuShape {
6 id: background
7 anchors.fill: parent
8- color: isGradient ? gradientProxy.topColor : button.color
9- gradientColor: isGradient ? gradientProxy.bottomColor : button.color
10 borderSource: "radius_idle.sci"
11 visible: color.a != 0.0
12+
13+ // Color properties in a JS ternary operator don't work as expected in
14+ // QML because it overwrites alpha values with 1. A workaround is to use
15+ // Qt.rgba(). For more information, see
16+ // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1197802 and
17+ // https://bugreports.qt-project.org/browse/QTBUG-32238.
18+ function colorHack(color) { return Qt.rgba(color.r, color.g, color.b, color.a); }
19+ color: isGradient ? colorHack(gradientProxy) : colorHack(button)
20+ gradientColor: isGradient ? colorHack(gradientProxy) : colorHack(button.color)
21 }
22
23 UbuntuShape {

Subscribers

People subscribed via source and target branches

to status/vote changes: