~rpadovani/ubuntu-weather-app/1198544

« back to all changes in this revision

Viewing changes to components/CurrentWeather.qml

  • Committer: Raúl Yeguas
  • Date: 2013-03-04 20:10:29 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: neokore@gmail.com-20130304201029-ck3em0xzutepx212
Added Current Weather Component

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 0.1
 
3
import "OpenWeatherMap.js" as Weather
 
4
 
 
5
Rectangle {
 
6
    id: currentWeather
 
7
 
 
8
    // For Status I take the same condition codes from OpenWeatherMap (http://openweathermap.org/wiki/API/Weather_Condition_Codes)
 
9
    property int condition
 
10
    property int currentTemp
 
11
    property int minTemp
 
12
    property int maxTemp
 
13
 
 
14
    width: units.gu(50)
 
15
    height: units.gu(60)
 
16
 
 
17
    Image {
 
18
        id: image1
 
19
        width: units.gu(30)
 
20
        height: units.gu(30)
 
21
        sourceSize.height: units.gu(30)
 
22
        sourceSize.width: units.gu(30)
 
23
        anchors.horizontalCenter: parent.horizontalCenter
 
24
        //source: "../resources/images/"+Weather.getConditionIcon(condition)+".jpg"
 
25
        source: "../resources/images/suncloud.jpg"
 
26
        fillMode: Image.PreserveAspectFit
 
27
    }
 
28
 
 
29
    Row {
 
30
        id: row1
 
31
        width: units.gu(50)
 
32
        height: units.gu(10)
 
33
        anchors.top: image1.bottom
 
34
        anchors.topMargin: 0
 
35
 
 
36
        Column {
 
37
            id: column1
 
38
            width: units.gu(5)
 
39
            height: units.gu(5)
 
40
            anchors.rightMargin: 0
 
41
            anchors.verticalCenter: parent.verticalCenter
 
42
            anchors.right: tempCurrent.left
 
43
 
 
44
            Label {
 
45
                text: i18n.tr("Max.")
 
46
                anchors.horizontalCenter: parent.horizontalCenter
 
47
                font.pixelSize: FontUtils.sizeToPixels("x-small")
 
48
                horizontalAlignment: Text.AlignHCenter
 
49
            }
 
50
 
 
51
            Label {
 
52
                text: maxTemp+"°"
 
53
                anchors.horizontalCenter: parent.horizontalCenter
 
54
                font.pixelSize: FontUtils.sizeToPixels("medium")
 
55
                horizontalAlignment: Text.AlignHCenter
 
56
            }
 
57
        }
 
58
 
 
59
        Text {
 
60
            width: units.gu(17)
 
61
            height: units.gu(10)
 
62
            id: tempCurrent
 
63
            text: currentTemp+"°"
 
64
            style: Text.Normal
 
65
            font.bold: false
 
66
            font.family: "Ubuntu"
 
67
            verticalAlignment: Text.AlignVCenter
 
68
            anchors.horizontalCenter: parent.horizontalCenter
 
69
            anchors.verticalCenter: parent.verticalCenter
 
70
            font.pointSize: 52
 
71
            horizontalAlignment: Text.AlignHCenter
 
72
 
 
73
        }
 
74
 
 
75
        Column {
 
76
            id: column2
 
77
            width: units.gu(5)
 
78
            height: units.gu(5)
 
79
            anchors.leftMargin: 0
 
80
            anchors.verticalCenter: parent.verticalCenter
 
81
            anchors.left: tempCurrent.right
 
82
 
 
83
            Label {
 
84
                text: i18n.tr("Min.")
 
85
                horizontalAlignment: Text.AlignHCenter
 
86
                anchors.horizontalCenter: parent.horizontalCenter
 
87
                font.pixelSize: FontUtils.sizeToPixels("x-small")
 
88
            }
 
89
 
 
90
            Label {
 
91
                text: minTemp+"°"
 
92
                horizontalAlignment: Text.AlignHCenter
 
93
                anchors.horizontalCenter: parent.horizontalCenter
 
94
                font.pixelSize: FontUtils.sizeToPixels("medium")
 
95
            }
 
96
        }
 
97
    }
 
98
}