View Single Post
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, España
#1
Hi,
as the title suggests, I'm trying to associate colours to weather temperature, mostly it seems to work until I get to single figures and minus temperatures.

Here is my clunky code, this code is used in `/usr/lib/qt5/qml/Sailfish/Weather/WeatherDetailsHeader.qml`

Code:
slotted in @ line: 124
           
    Rectangle {
        id: colorTemperature
        width: 100; height: 140
        radius: 12
        anchors.centerIn: temperatureHighLabel
        color: {
            ((temperatureHighLabel.text  >= '38'  && '#b20012' || // dark red
              temperatureHighLabel.text  >= '32'  && '#bd0014' || // red
              temperatureHighLabel.text  >= '27'  && '#ec0019' || // scarlet
              temperatureHighLabel.text  >= '21'  && '#ec9649' || // orange
              temperatureHighLabel.text  >= '16'  && '#f7c200' || // yellow
              temperatureHighLabel.text  >= '10'  && '#9ad346' || // rich green
              temperatureHighLabel.text  >= '4'   && '#47b04b' || // green
              temperatureHighLabel.text  >= '-1'  && '#4293ff' || // sky blue
              temperatureHighLabel.text  >= '-7'  && '#3c00ff' || // blue
              temperatureHighLabel.text  >= '-12' && '#6a28a3' || // purple
              temperatureHighLabel.text  >= '-18' && '#8d009a' || // pinky purple
              temperatureHighLabel.text  >= '-23' && '#ff00ff' )) // magenta
         }
    }
    Label {
        id: temperatureHighLabel
The colour shows correctly until I get down to single and minus figures, for example, a day that is '8º' which should be shown as 'green' but is shown as 'dark red', in fact 'dark red' is the colour of all single figures, yet 'dark red' is associated with temps greater than or equal to 38º. I have also tried using plus+ and minus- symbols with temps but to no avail.

I've played with this extensively, originally it was in if/else format but the same problem occurred. I've tried different java operators, I've tried adding plus/minus symbols to temp figures, but still I get dark red for single and minus figures. Any ideas appreciated.

The format used for laying out my code, was taken directly from harbour-nationalrail used for associating rail operator colours. Originally, the code was laid out in the same way as my windDirection patch, that being inthe style of 'if/else' statements, but that yielded the same problem as does the above.
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..

Last edited by Markkyboy; 2018-09-04 at 09:57.