Skip to content

Commit

Permalink
tip add sunset, sunrise
Browse files Browse the repository at this point in the history
  • Loading branch information
sonichy committed Oct 20, 2019
1 parent 0117689 commit bfa6137
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Binary file modified README.md
Binary file not shown.
6 changes: 4 additions & 2 deletions forcastwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ void ForcastWidget::updateWeather()
double lon = coord.value("lon").toDouble();
m_settings.setValue("lat", lat);
m_settings.setValue("lon", lon);
QDateTime time_sunrise = QDateTime::fromSecsSinceEpoch(JO_city.value("sunrise").toInt(), Qt::LocalTime);
QDateTime time_sunset = QDateTime::fromSecsSinceEpoch(JO_city.value("sunset").toInt(), Qt::LocalTime);
QJsonArray list = JD.object().value("list").toArray();
int r = 0;
for (int i=0; i<list.size(); i++) {
QDateTime date = QDateTime::fromSecsSinceEpoch(list[i].toObject().value("dt").toInt(), QTimeZone::utc());
QDateTime date = QDateTime::fromSecsSinceEpoch(list[i].toObject().value("dt").toInt(), Qt::UTC);
QString sdate = date.toString("MM-dd ddd");
QString dt_txt = list[i].toObject().value("dt_txt").toString();
double temp = list[i].toObject().value("main").toObject().value("temp").toDouble() - 273.15;
Expand Down Expand Up @@ -134,7 +136,7 @@ void ForcastWidget::updateWeather()
labelWImg[1]->setPixmap(QPixmap(icon_path).scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation));
labelTemp[1]->setText(weather + " " + stemp);
labelDate[1]->setText(sdate);
stip = city + ", " + country + "\n" + weather + "\n" + stemp + "\n" + humidity + "\n" + wind +"\nRefresh:" + currentDateTime.toString("HH:mm:ss");
stip = city + ", " + country + "\n" + weather + "\n" + stemp + "\n" + humidity + "\n" + wind + "\nSunrise: " + time_sunrise.toString("hh:mm") + "\nSunset: " + time_sunset.toString("hh:mm") + "\nRefresh:" + currentDateTime.toString("HH:mm:ss");
emit weatherNow(weather, stemp, stip, pixmap);
r++;
} else {
Expand Down
2 changes: 1 addition & 1 deletion weatherplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void WeatherPlugin::invokedMenuItem(const QString &itemKey, const QString &menuI

void WeatherPlugin::MBAbout()
{
QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.6", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: [email protected]\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5");
QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.7", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: [email protected]\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5");
aboutMB.setIconPixmap(QPixmap(":/icon/Default/01d.png"));
aboutMB.exec();
}
Expand Down

0 comments on commit bfa6137

Please sign in to comment.