2022-06-08 17:06:38 +08:00
|
|
|
|
#include "windows/MainWindow.h"
|
2022-06-14 14:03:19 +08:00
|
|
|
|
#include "UsctApplication.h"
|
2022-06-08 17:06:38 +08:00
|
|
|
|
#include "windows/LoginDialog.h"
|
2021-12-23 10:09:35 +08:00
|
|
|
|
#include "db/SQLHelper.h"
|
2021-10-21 15:56:42 +08:00
|
|
|
|
#include <QTextCodec>
|
2021-10-25 15:00:09 +08:00
|
|
|
|
#include <QFontDatabase>
|
2021-11-19 13:20:17 +08:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
#include <QTimer>
|
2021-11-19 15:36:12 +08:00
|
|
|
|
#include "log/UserOperationLog.h"
|
2021-12-07 14:14:20 +08:00
|
|
|
|
#include <QTranslator>
|
2022-01-11 13:07:42 +08:00
|
|
|
|
#include <src/device/DeviceManager.h>
|
2022-07-19 14:15:00 +08:00
|
|
|
|
#include "dialogs/DialogManager.h"
|
2022-07-28 16:27:51 +08:00
|
|
|
|
#include "dialogs/MultyMessageDialogManager.h"
|
2022-09-29 17:36:55 +08:00
|
|
|
|
#include "action/AsyncAction.h"
|
2021-12-07 14:14:20 +08:00
|
|
|
|
#include "json/jsonobject.h"
|
2022-06-14 14:03:19 +08:00
|
|
|
|
#include "src/utilities/Locker.h"
|
|
|
|
|
|
#include "src/utilities/LanguageSwitcher.h"
|
|
|
|
|
|
#include "utilities/TouchScreenSignalSender.h"
|
2023-08-21 14:22:41 +08:00
|
|
|
|
#include "keyboard/KeyboardManager.h"
|
2023-11-13 17:54:40 +08:00
|
|
|
|
#include "appvals/AppGlobalValues.h"
|
2022-06-14 14:03:19 +08:00
|
|
|
|
|
2021-10-25 15:00:09 +08:00
|
|
|
|
QString loadFontFromFile(QString path)
|
|
|
|
|
|
{
|
2022-06-13 13:26:49 +08:00
|
|
|
|
static QString font;
|
|
|
|
|
|
static bool loaded = false;
|
|
|
|
|
|
if (!loaded)
|
|
|
|
|
|
{
|
|
|
|
|
|
loaded = true;
|
|
|
|
|
|
int loadedFontID = QFontDatabase::addApplicationFont(path);
|
|
|
|
|
|
QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
|
|
|
|
|
|
if (!loadedFontFamilies.empty())
|
|
|
|
|
|
font = loadedFontFamilies.at(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
return font;
|
2021-10-25 15:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
2021-10-09 16:38:34 +08:00
|
|
|
|
{
|
2022-06-13 13:26:49 +08:00
|
|
|
|
//QLocale::setDefault(QLocale::English);
|
2022-07-20 17:05:50 +08:00
|
|
|
|
//qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
|
2021-10-25 15:00:09 +08:00
|
|
|
|
#ifdef CUTE_STYLE
|
2022-07-20 17:05:50 +08:00
|
|
|
|
//qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("retro"));
|
2021-10-25 15:00:09 +08:00
|
|
|
|
#endif // CUTE_STYLE
|
|
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
//qputenv("QT_LOGGING_RULES", QByteArray("qt.virtualkeyboard=true"));
|
2021-10-15 11:52:23 +08:00
|
|
|
|
|
2021-10-25 15:00:09 +08:00
|
|
|
|
|
2022-06-14 14:03:19 +08:00
|
|
|
|
UsctApplication a(argc, argv);
|
2022-08-25 14:53:43 +08:00
|
|
|
|
qRegisterMetaType<QPair<QString, uint>>("QPair<QString, uint>");
|
2022-09-29 17:36:55 +08:00
|
|
|
|
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
|
|
|
|
|
|
qRegisterMetaType<ActionResult>("ActionResult");
|
2023-08-21 14:22:41 +08:00
|
|
|
|
qRegisterMetaType<QMap<QString,int>>("QMap<QString,int>");
|
2022-09-29 17:36:55 +08:00
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
QString layouts_path = QString(QCoreApplication::applicationDirPath()).append("/layouts");
|
|
|
|
|
|
qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", QByteArray(layouts_path.toStdString().c_str()));
|
2021-10-20 15:55:15 +08:00
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
QTextCodec* codec = QTextCodec::codecForName("utf8");
|
|
|
|
|
|
QTextCodec::setCodecForLocale(codec);
|
2021-10-25 15:00:09 +08:00
|
|
|
|
|
2021-12-23 10:09:35 +08:00
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
//multi-language suppport
|
|
|
|
|
|
LanguageSwitcher::getInstance()->setDefaultLanguage(JsonObject::Instance()->defaultLanguage());
|
|
|
|
|
|
a.installTranslator(LanguageSwitcher::getInstance()->getTranslator());
|
2021-10-25 15:00:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
//QString fontName = loadFontFromFile(":/fonts/MicrosoftYahei.ttf");
|
|
|
|
|
|
QString fontName = loadFontFromFile(":/fonts/DroidSansFallback.ttf");
|
|
|
|
|
|
QFont font(fontName);
|
|
|
|
|
|
QApplication::setFont(font);
|
2021-10-25 15:00:09 +08:00
|
|
|
|
|
2022-07-19 14:15:00 +08:00
|
|
|
|
QFile file(":/stylesheet/Dark2.css");
|
|
|
|
|
|
file.open(QFile::ReadOnly);
|
|
|
|
|
|
if (file.isOpen())
|
|
|
|
|
|
{
|
|
|
|
|
|
a.setStyleSheet(QLatin1String(file.readAll()));
|
|
|
|
|
|
}
|
2023-11-13 17:54:40 +08:00
|
|
|
|
AppGlobalValues::setDBconnected(false);
|
2022-06-13 13:26:49 +08:00
|
|
|
|
MainWindow w;
|
2022-08-18 17:09:16 +08:00
|
|
|
|
DialogManager::Default()->init(&w);
|
2022-06-13 13:26:49 +08:00
|
|
|
|
UserOperationLog::Default()->init();
|
2021-12-07 14:14:20 +08:00
|
|
|
|
|
2023-08-21 14:22:41 +08:00
|
|
|
|
Locker::getInstance()->start();
|
|
|
|
|
|
QObject::connect(TouchScreenSignalSender::getInstance(), SIGNAL(touchScreen()), Locker::getInstance(), SLOT(refreshTimer()));
|
2022-06-13 13:26:49 +08:00
|
|
|
|
QList<Qt::GestureType> gestures;
|
|
|
|
|
|
gestures << Qt::SwipeGesture;
|
|
|
|
|
|
gestures << Qt::PanGesture;
|
|
|
|
|
|
w.grabGestures(gestures);
|
2021-10-25 15:00:09 +08:00
|
|
|
|
|
2022-06-13 13:26:49 +08:00
|
|
|
|
QStringList app_args = a.arguments();
|
|
|
|
|
|
int ret = 0;
|
2022-07-28 16:27:51 +08:00
|
|
|
|
KeyboardManager::getInstance();
|
2023-09-05 16:32:38 +08:00
|
|
|
|
UserOperationLog::cleanHistoryLog();
|
2022-01-19 14:24:16 +08:00
|
|
|
|
|
2023-11-13 17:54:40 +08:00
|
|
|
|
w.showFullScreen();
|
|
|
|
|
|
DeviceManager::Default()->initDevice();
|
2022-01-19 14:24:16 +08:00
|
|
|
|
|
2023-11-13 17:54:40 +08:00
|
|
|
|
ret = a.exec();
|
2022-06-13 13:26:49 +08:00
|
|
|
|
DeviceManager::Default()->close();
|
|
|
|
|
|
return ret;
|
2021-10-09 16:38:34 +08:00
|
|
|
|
}
|