-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (64 loc) · 2.54 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (64 loc) · 2.54 KB
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
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QJsonArray>
#include <QJsonObject>
#include "weatherApi.h"
#include "WeatherCache.h"
#include "ForecastStore.h"
#include "AirQualityStore.h"
#include "SolarAstronomyStore.h"
#include "CityDetailStore.h"
#include "AppSettings.h"
#include "GlobalClock.h"
#include "BackgroundManager.h"
#include "TransitionController.h"
#include "SkyState.h"
int main(int argc, char *argv[])
{
qputenv("QT_QUICK_CONTROLS_STYLE", "Fusion");
QApplication app(argc, argv);
app.setApplicationName("QWeather");
app.setOrganizationName("QWeatherApp");
qRegisterMetaType<QJsonArray>("QJsonArray");
qRegisterMetaType<QJsonObject>("QJsonObject");
WeatherCache cache;
WeatherAPI weatherapi;
weatherapi.setCache(&cache);
ForecastStore forecastStore;
forecastStore.setWeatherApi(&weatherapi);
AirQualityStore airQualityStore;
airQualityStore.setWeatherApi(&weatherapi);
AppSettings appSettings;
SolarAstronomyStore solarAstronomyStore;
solarAstronomyStore.setWeatherApi(&weatherapi);
solarAstronomyStore.setAppSettings(&appSettings);
CityDetailStore cityDetailStore;
cityDetailStore.setWeatherApi(&weatherapi);
// === V3 天空系统 ===
qRegisterMetaType<SkyState>("SkyState");
GlobalClock globalClock;
BackgroundManager bgManager;
TransitionController transitionCtrl;
bgManager.setTransitionController(&transitionCtrl);
globalClock.start();
QQmlApplicationEngine engine;
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.rootContext()->setContextProperty("weatherApi", &weatherapi);
engine.rootContext()->setContextProperty("weatherCache", &cache);
engine.rootContext()->setContextProperty("forecastStore", &forecastStore);
engine.rootContext()->setContextProperty("airQualityStore", &airQualityStore);
engine.rootContext()->setContextProperty("solarAstronomyStore", &solarAstronomyStore);
engine.rootContext()->setContextProperty("cityDetailStore", &cityDetailStore);
engine.rootContext()->setContextProperty("appSettings", &appSettings);
engine.rootContext()->setContextProperty("globalClock", &globalClock);
engine.rootContext()->setContextProperty("backgroundManager", &bgManager);
engine.rootContext()->setContextProperty("transitionCtrl", &transitionCtrl);
engine.loadFromModule("qml1", "Main");
return QApplication::exec();
}