2
* Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import "../common" as Common
22
width: 208;height: 147
23
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
27
function setDefaultWeather() {
28
weatherIcon.source = "../../img/weather/d0.gif"
29
weatherText.text = qsTr("Weather");//天气
30
pmText.text = qsTr("AQI");//空气质量指数
31
tempText.text = qsTr("Current temperature");//当前温度(℃)
35
function resetCurrentWeather() {
36
var ptime = sessiondispatcher.getSingleWeatherInfo("ptime", "current");//eg: 08:00
37
var need_str = ptime.substr(0, ptime.lastIndexOf(":"));//eg: 08
39
var pIntTime = parseInt(need_str, 10);//eg: 8
40
if(pIntTime > 7 && pIntTime < 20) {
41
var img1 = sessiondispatcher.getSingleWeatherInfo("img1", "current");
42
weatherIcon.source = sessiondispatcher.getSingleWeatherInfo(img1, "weathericon");
45
var img2 = sessiondispatcher.getSingleWeatherInfo("img2", "current");
46
weatherIcon.source = sessiondispatcher.getSingleWeatherInfo(img2, "weathericon");
48
locationText.text = sessiondispatcher.getSingleWeatherInfo("city", "current");
49
ptimeText.text = sessiondispatcher.getSingleWeatherInfo("time", "current") + qsTr(" ");// 发布
50
weatherText.text = sessiondispatcher.getSingleWeatherInfo("weather", "current");
51
pmText.text = qsTr("AQI:") + sessiondispatcher.getSingleWeatherInfo("aqi", "current");;//空气质量指数:
52
tempText.text = qsTr("Current temperature:") + sessiondispatcher.getSingleWeatherInfo("temp", "current") + "℃";//当前温度:
56
function resetCurrentYahooWeather() {
57
weatherIcon.source = "http://l.yimg.com/a/i/us/we/52/" + sessiondispatcher.getSingleWeatherInfo("code", "yahoo") + ".gif";
58
locationText.text = sessiondispatcher.getSingleWeatherInfo("city", "yahoo");//城市
60
pmText.text = sessiondispatcher.getSingleWeatherInfo("time", "yahoo");//发布时间
61
weatherText.text = sessiondispatcher.getSingleWeatherInfo("text", "yahoo");//当前天气
62
tempText.text = qsTr("Current temperature:") + sessiondispatcher.getSingleWeatherInfo("temp", "yahoo");//当前温度:
67
target: sessiondispatcher
68
onStartUpdateForecastWeahter: {
69
if(flag == "weather") {
70
weahterzone.resetCurrentWeather();
72
else if(flag == "yahoo") {
73
weahterzone.resetCurrentYahooWeather();
78
onStartChangeQMLCity: {
79
sessiondispatcher.get_current_weather_qt();
83
Component.onCompleted: {
84
weahterzone.setDefaultWeather();
85
sessiondispatcher.get_current_weather_qt();//0104
89
text: qsTr("City")//城市
93
anchors.left: parent.left
97
anchors.left: locationText.right
98
wordname: qsTr("[Change]")//[切换]
100
height: locationText.height
102
sessiondispatcher.showWizardController();
108
text: qsTr("Publish")//发布时间
112
anchors.right: parent.right
117
top: ptimeText.bottom
121
width: 48; height: 48
125
anchors.top: parent.top
126
anchors.topMargin: 25
133
text: qsTr("N/A")//未知
139
text: qsTr("AQI:N/A")//空气质量指数:未知
145
text: qsTr("Temperature:N/A")//温度:未知
153
// interval: 600000;running: true;repeat: true
155
// sessiondispatcher.get_current_weather_qt();
156
//// console.log(Qt.formatDateTime(new Date(), "dddd\nyyyy-MM-dd\n-MMM-\nhh-mm-ss"));