Apply new ttf for linux font.
This commit is contained in:
74
src/main.cpp
74
src/main.cpp
@@ -1,46 +1,68 @@
|
||||
#include "mainwindow.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include "loginwindow.h"
|
||||
#include "InputObject.h"
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <src/db/SQLHelper.h>
|
||||
#include <QTextCodec>
|
||||
int main(int argc, char *argv[])
|
||||
#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()));
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.addImportPath("/VirtualKeyboard/content/styles");
|
||||
#ifdef CUTE_STYLE
|
||||
qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("retro"));
|
||||
#else
|
||||
qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("default"));
|
||||
#endif
|
||||
QTextCodec *codec = QTextCodec::codecForName("utf8");
|
||||
QTextCodec::setCodecForLocale(codec);
|
||||
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();
|
||||
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 )
|
||||
{
|
||||
goto needLogin;
|
||||
}
|
||||
// l.deleteLater();
|
||||
w.centerWidgetShow();
|
||||
SQLHelper::Open();
|
||||
MainWindow w;
|
||||
w.showFullScreen();
|
||||
LoginWindow l;
|
||||
needLogin:
|
||||
l.showFullScreen();
|
||||
int rec = l.exec();
|
||||
if (rec != QDialog::Accepted)
|
||||
{
|
||||
goto needLogin;
|
||||
}
|
||||
// l.deleteLater();
|
||||
w.centerWidgetShow();
|
||||
|
||||
|
||||
return a.exec();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user