69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include "mainwindow.h"
|
|
#include <QApplication>
|
|
#include "loginwindow.h"
|
|
#include "InputObject.h"
|
|
#include <QQmlApplicationEngine>
|
|
#include <src/db/SQLHelper.h>
|
|
#include <QTextCodec>
|
|
#include <QFontDatabase>
|
|
QString loadFontFromFile(QString path)
|
|
{
|
|
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;
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
//QLocale::setDefault(QLocale::English);
|
|
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
|
|
#ifdef CUTE_STYLE
|
|
qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("retro"));
|
|
#endif // CUTE_STYLE
|
|
|
|
//qputenv("QT_LOGGING_RULES", QByteArray("qt.virtualkeyboard=true"));
|
|
|
|
|
|
QApplication a(argc, argv);
|
|
QString layouts_path = QString(QCoreApplication::applicationDirPath()).append("/layouts");
|
|
qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", QByteArray(layouts_path.toStdString().c_str()));
|
|
|
|
QTextCodec* codec = QTextCodec::codecForName("utf8");
|
|
QTextCodec::setCodecForLocale(codec);
|
|
|
|
//QString fontName = loadFontFromFile(":/fonts/MicrosoftYahei.ttf");
|
|
QString fontName = loadFontFromFile(":/fonts/DroidSansFallback.ttf");
|
|
|
|
|
|
QFont font(fontName);
|
|
QApplication::setFont(font);
|
|
|
|
//a.installEventFilter(obj);
|
|
InputObject* obj = new InputObject();
|
|
a.installEventFilter(obj);
|
|
SQLHelper::Open();
|
|
MainWindow w;
|
|
w.showFullScreen();
|
|
LoginWindow l;
|
|
needLogin:
|
|
l.showFullScreen();
|
|
int rec = l.exec();
|
|
if (rec !=QDialog::Accepted )
|
|
{
|
|
return 0;
|
|
}
|
|
// l.deleteLater();
|
|
w.centerWidgetShow();
|
|
|
|
|
|
return a.exec();
|
|
}
|