This commit is contained in:
2026-05-04 16:24:48 +02:00
parent 55a76be186
commit 0549437776
7 changed files with 610 additions and 60 deletions

View File

@@ -1,20 +1,58 @@
#pragma once
#include <array>
#include <glibmm/dispatcher.h>
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <sigc++/sigc++.h>
#include "gtkmm/scrolledwindow.h"
class WeatherWidget : public Gtk::Box {
public:
struct CurrentWeather {
double temperature;
double apparent_temperature;
double precipitation;
int weather_code;
};
struct DailyWeather {
double temperature_2m_max;
double temperature_2m_min;
double apparent_temperature_min;
double apparent_temperature_max;
double precipitation_sum;
int weather_code;
std::string time;
};
struct HourlyWeather {
double temperature_2m;
double apparent_temperature;
double precipitation_probability;
double precipitation;
int weather_code;
std::string time;
};
WeatherWidget();
private:
Gtk::Label titleLabel;
Gtk::Label currentLabel;
Gtk::Label todayLabel;
std::array<DailyWeather, 7> daily_weather{};
std::array<HourlyWeather, 24> hourly_weather{};
CurrentWeather current_weather{};
Gtk::ScrolledWindow currentScroll;
Gtk::ScrolledWindow hourlyScroll;
Gtk::ScrolledWindow dailyScroll;
Glib::Dispatcher m_dispatcher;
bool onRefreshTick();
void fetchWeather();
void applyWeatherText(const std::string &current_text,
const std::string &today_text);
void refreshCurrentWeather();
void refreshHourlyWeather();
void refreshDailyWeather();
};