农历日历 v1.0.4
载入中...
搜索中...
未找到
main.cpp
1
5#include "MainWindow.h"
6#include <QApplication>
7#include <QFile>
8#include <QTranslator>
9#include <QDir>
10#include <QScreen>
11#include <QLoggingCategory>
12#if defined(Q_OS_ANDROID)
13#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
14
15#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
16 #include <QtAndroid>
17#endif
18#else
19
20#endif
21#ifdef RABBITCOMMON
22 #include "RabbitCommonTools.h"
23 #include "FrmUpdater.h"
24 #include "RabbitCommonDir.h"
25#endif
26#include <QLocale>
27#include "LunarCalendar.h"
28
29static Q_LOGGING_CATEGORY(Logger, "App.main")
30
31
38int main(int argc, char *argv[])
39{
40 QApplication a(argc, argv);
41 a.setApplicationVersion(LunarCalendar_VERSION);
42 a.setApplicationName("LunarCalendar");
43
44#ifdef RABBITCOMMON
45 RabbitCommon::CTools::Instance()->Init();
46#endif
47 RabbitCommon::CTools::Instance()->InstallTranslator("LunarCalendarApp");
48
49 a.setApplicationDisplayName(QObject::tr("Calendar"));
50
51 qInfo(Logger) << QObject::tr("Calendar") + " " + CLunarCalendar::Version()
52 << QObject::tr("Rabbit Common: ")
53 + RabbitCommon::CTools::Version();
54
55#ifdef RABBITCOMMON
56 CFrmUpdater *pUpdate = new CFrmUpdater();
57 QIcon icon = QIcon::fromTheme("calendar");
58 if(!icon.isNull()) {
59 auto sizeList = icon.availableSizes();
60 if(!sizeList.isEmpty()) {
61 QPixmap p = icon.pixmap(*sizeList.begin());
62 pUpdate->SetTitle(p.toImage());
63 }
64 }
65
66 if(a.arguments().size() > 1) {
67 if(!pUpdate->GenerateUpdateJson())
68 return 0;
69 if(!pUpdate->GenerateUpdateXml())
70 return 0;
71 }
72#endif
73
74 MainWindow w;
75
76#if defined (Q_OS_ANDROID)
77 w.showMaximized();
78#else
79 #if defined (Q_OS_UNIX)
80 QRect rect = qApp->primaryScreen()->geometry();
81 int left = (rect.width() - 500) >> 1;
82 int top = (rect.height() - 500) >> 1;
83 w.move(left, top);
84 #endif
85 w.show();
86#endif
87 int nRet = a.exec();
88
89 return nRet;
90}
[Define CTaskHandler derived class]
Definition MainWindow.h:26