forked from FelixdelasPozas/TrayWeather
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeatherDialog.h
130 lines (107 loc) · 3.66 KB
/
WeatherDialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
File: WeatherDialog.h
Created on: 24/11/2016
Author: Felix de las Pozas Alvarez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WEATHERDIALOG_H_
#define WEATHERDIALOG_H_
// Project
#include <Utils.h>
// Qt
#include "ui_WeatherDialog.h"
#include <QDialog>
#include <qwebview.h>
// C++
#include <memory>
namespace QtCharts
{
class QChartView;
class QLineSeries;
}
class QWebView;
class TooltipWidget;
/** \class WeatherDialog
* \brief Implements the dialog showing the current weather and the forecast.
*
*/
class WeatherDialog
: public QDialog
, public Ui_WeatherDialog
{
Q_OBJECT
public:
/** \brief WeatherDialog class constructor.
* \param[in] parent pointer of the widget parent of this one.
* \param[in] flags window flags.
*
*/
WeatherDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
/** \brief WeatherDialog class virtual destructor.
*
*/
virtual ~WeatherDialog()
{};
/** \brief Sets the weather and forecast data.
* \param[in] current current weather data.
* \param[in] data forecast data.
* \param[in] config application configuration.
*
*/
void setData(const ForecastData ¤t, const Forecast &data, Configuration &config);
/** \brief Returns true if the maps tab is visible and false otherwise.
*
*/
bool mapsEnabled() const;
private slots:
/** \brief Shows weather data when the user hovers on the temperature line.
* \param[in] point hover point.
* \param[in] state true when user has hovered over the series and false when hover has moved away from the series.
*
*/
void onChartHover(const QPointF &point, bool state);
/** \brief Resets the chart's zoom to the original one.
*
*/
void onResetButtonPressed();
/** \brief Updates the GUI when the user changes the tab.
* \param[in] index index of the current tab.
*
*/
void onTabChanged(int index);
/** \brief Shows the maps tab once it has finished loading.
* \param[in] value true on load success and false otherwise.
*
*/
void onLoadFinished(bool value);
/** \brief Shows/hides the maps tab.
*
*/
void onMapsButtonPressed();
/** \brief Helper method to update the maps tab title on load progress.
* \param[in] progress progress value in [0-100].
*
*/
void onLoadProgress(int progress);
/** \brief Updates the state of the reset chart zoom button.
*
*/
void onAreaChanged();
private:
QtCharts::QChartView *m_chartView; /** chart view. */
QtCharts::QLineSeries *m_temperatureLine; /** temperature series line. */
const Forecast *m_forecast; /** forecast data for tooltip. */
Configuration *m_config; /** configuration data for tooltip. */
std::shared_ptr<TooltipWidget> m_tooltip; /** tooltip widget. */
QWebView *m_webpage; /** maps webpage. */
};
#endif // WEATHERDIALOG_H_