11 import com.nokia.meego 1.0
12 import org.kde.edu.marble 0.11
19 id: weatherActivityPage
22 property bool horizontal: width / height > 1.20
24 tools: ToolBarLayout {
26 iconSource:
main.
icon(
"actions/go-home", 48 );
30 iconSource:
main.
icon(
"places/user-identity", 48 );
32 marbleWidget.centerOn( marbleWidget.tracking.lastKnownPosition.longitude, marbleWidget.tracking.lastKnownPosition.latitude )
33 if (marbleWidget.zoom < 403 ) {
34 marbleWidget.zoom = 22026
42 checked: marbleWidget.renderPlugin(
"weather").favoriteItemsOnly
45 iconSource:
main.
icon(
"places/favorites", 48 );
46 onCheckedChanged: marbleWidget.renderPlugin(
"weather").favoriteItemsOnly = checked
55 iconSource:
main.
icon(
"actions/edit-find", 48 );
61 anchors.left: parent.left
62 anchors.right: parent.right
63 anchors.top: parent.top
64 visible: searchButton.checked
66 searchField.
busy =
true
67 marbleWidget.find( term )
70 Component.onCompleted: {
71 marbleWidget.search.searchFinished.connect( searchFinished )
74 function searchFinished() {
75 searchField.busy =
false
81 property bool minimized: station ===
""
84 property string identifier
85 property string station
86 property double temperature
88 property string description
89 property bool favorite:
false
91 anchors.bottom: weatherActivityPage.bottom
92 anchors.left: weatherActivityPage.left
93 width: weatherActivityPage.horizontal ? (minimized ? 0 : weatherActivityPage.width / 2) : weatherActivityPage.width
94 height: weatherActivityPage.horizontal ? weatherActivityPage.height : (minimized ? 0 : 20 + label.height + Math.max(descriptionLabel.height, icon.height))
97 border.color:
"darkgray"
106 anchors.right: parent.right
108 iconSource: stationDetails.favorite ?
"qrc:/icons/bookmark.png" :
"qrc:/icons/bookmark-disabled.png"
114 onClicked: stationDetails.favorite = !stationDetails.favorite
119 text: stationDetails.temperature +
" °C " + stationDetails.station
120 anchors.left: parent.left
121 anchors.right: bookmarkButton.left
128 anchors.top: label.bottom
129 anchors.left: icon.right
130 text: stationDetails.description
135 anchors.top: label.bottom
136 source: stationDetails.image !==
"" ? (
"file://" + stationDetails.image) :
""
141 enabled: !weatherActivityPage.horizontal;
143 easing.type: Easing.InOutQuad;
151 anchors.left: weatherActivityPage.horizontal ? stationDetails.right : weatherActivityPage.left
152 anchors.bottom: weatherActivityPage.horizontal ? weatherActivityPage.bottom : stationDetails.top
153 anchors.right: weatherActivityPage.right
154 anchors.top: searchButton.checked ? searchField.bottom : weatherActivityPage.top
157 function embedMarbleWidget() {
158 marbleWidget.parent = mapContainer
159 settings.projection =
"Spherical"
160 var plugins = settings.defaultRenderPlugins
161 plugins.push(
"weather" )
162 settings.activeRenderPlugins = plugins
163 settings.mapTheme = settings.streetMapTheme
164 settings.gpsTracking =
true
165 settings.showPositionIndicator =
false
166 settings.showTrack =
false
168 marbleWidget.visible =
true
169 marbleWidget.setDataPluginDelegate(
"weather", weatherDelegate )
172 Component.onDestruction: {
173 marbleWidget.setDataPluginDelegate(
"weather", 0 )
174 if ( marbleWidget.parent === mapContainer ) {
175 marbleWidget.parent = null
176 marbleWidget.visible =
false
182 if ( status === PageStatus.Activating ) {
183 mapContainer.embedMarbleWidget()
188 anchors.top: parent.top
189 anchors.left: parent.left
190 anchors.topMargin: 30
191 anchors.leftMargin: 15
193 height: legend.height
195 color: Qt.rgba(192/255, 192/255, 192/255, 192/255)
197 border.color:
"black"
205 height: items*(10+spacing)+2*x
206 property
int items: 22
216 property int temperature: -3*index+36
219 anchors.verticalCenter: parent.verticalCenter
224 color: Qt.hsla( weatherActivityPage.temperatureToHue(parent.temperature)/255.0, 1.0, 0.5, 1.0 )
228 text: parent.temperature +
" °C"
230 horizontalAlignment: Text.AlignRight
231 anchors.verticalCenter: parent.verticalCenter
242 width: Math.max(icon.width, label.width)
243 height: Math.max(icon.height, label.height)
245 property bool showDetails:
false
253 fillMode: Image.PreserveAspectFit
254 source: image !==
"" ? (
"file://" + image) :
""
258 onClicked: containerItem.updateDetails()
265 visible: !icon.visible
266 anchors.centerIn: parent
270 color: Qt.hsla( weatherActivityPage.temperatureToHue(temperature)/255.0, 1.0, 0.5, 1.0 )
272 text: temperature.toFixed(0) +
" °C"
276 onClicked: containerItem.updateDetails()
280 SequentialAnimation {
282 PauseAnimation { duration: Math.random() * 100 }
291 function updateDetails() {
292 stationDetails.identifier = identifier
293 stationDetails.favorite = favorite
294 stationDetails.station = station
295 stationDetails.description = description
296 stationDetails.image = image
297 stationDetails.temperature = temperature
301 target: stationDetails
303 if (stationDetails.identifier === identifier) {
304 favorite = stationDetails.favorite
309 Component.onCompleted: {
310 icon.visible = image !==
"" && Math.random() >= 0.3
311 appearAnimation.running =
true
316 function temperatureToHue(temperature) {
317 var factor = temperature > 20 ? 1.8 : ( temperature > 5 ? 2.1 : 2.7 )
318 return -factor*(Math.max(-40, Math.min(40, temperature))-40)
static qreal radius(qreal zoom)