Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
main.cpp
1// Author: Kang Lin <kl222@126.com>
2
24#include "MainWindow.h"
25
26#include <QApplication>
27#include <QSettings>
28#include <QDebug>
29#include <QtGlobal>
30#include <QSharedPointer>
31#if defined(Q_OS_ANDROID)
32 #include <QtAndroid>
33#endif
34
35#include "RabbitCommonTools.h"
36#include "RabbitCommonDir.h"
37#ifdef HAVE_UPDATE
38#include "FrmUpdater/FrmUpdater.h"
39#endif
40#ifdef BUILD_QUIWidget
41 #include "QUIWidget/QUIWidget.h"
42#endif
43
44#include <QLoggingCategory>
45
46Q_LOGGING_CATEGORY(App, "App")
47
48int main(int argc, char *argv[])
49{
50 int nRet = 0;
51 QApplication::setApplicationVersion(RabbitRemoteControl_VERSION);
52 QApplication::setApplicationName("RabbitRemoteControlService");
53#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
54 QApplication::setDesktopFileName(QLatin1String("RabbitRemoteControlServiceConfigure.desktop"));
55#endif
56
57 QApplication a(argc, argv);
58
59 RabbitCommon::CTools::Instance()->Init();
60 // Install translator
61 QTranslator tApp;
62 QString szFile = RabbitCommon::CDir::Instance()->GetDirTranslations()
63 + QDir::separator() + "RabbitRemoteControlServiceConfigure_"
64 + QLocale::system().name() + ".qm";
65 tApp.load(szFile);
66 if(a.installTranslator(&tApp))
67 qInfo(App) << "Language:" << QLocale::system() << "File:" << szFile;
68 else
69 qCritical(App) << "Language:" << QLocale::system() << "File:" << szFile;
70
71 a.setApplicationDisplayName(QObject::tr("Rabbit remote control service configure"));
72 a.setOrganizationName(QObject::tr("Kang Lin studio"));
73
74 CMainWindow* w = new CMainWindow();
75 w->setWindowTitle(a.applicationDisplayName());
76 try {
77 //w->setWindowIcon(QIcon::fromTheme("app"));
78 //w->setWindowTitle(a.applicationDisplayName());
79
80#ifdef BUILD_QUIWidget
81 QSharedPointer<QUIWidget> quiwidget(new QUIWidget(nullptr, true));
82 bool check = quiwidget->connect(w, SIGNAL(sigFullScreen()),
83 SLOT(showFullScreen()));
84 Q_ASSERT(check);
85 check = quiwidget->connect(w, SIGNAL(sigShowNormal()),
86 SLOT(showNormal()));
87 Q_ASSERT(check);
88 //quiwidget.setPixmap(QUIWidget::Lab_Ico, ":/image/App");
89 //quiwidget.setTitle(a.applicationDisplayName());
90 quiwidget->setMainWidget(w);
91 quiwidget->show();
92#else
93 w->show();
94#endif
95
96 nRet = a.exec();
97 } catch (std::exception &e) {
98 qCritical(App) << "exception:" << e.what();
99 } catch(...) {
100 qCritical(App) << "exception";
101 }
102
103#ifndef BUILD_QUIWidget
104 delete w;
105#endif
106
107 RabbitCommon::CTools::Instance()->Clean();
108 a.removeTranslator(&tApp);
109
110 return nRet;
111}
The Main window class.
Definition MainWindow.h:18