Apply new ttf for linux font.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractSpinBox>
|
||||
|
||||
InputObject::InputObject(QWidget *parent) :
|
||||
InputObject::InputObject(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::InputObject)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ void InputObject::initUi()
|
||||
"QLineEdit,QDateEdit{background-color: rgba(0,0,0,0.5);\
|
||||
min-height:100px;max-height:100px; min-width:500px;max-width:500px;\
|
||||
border: 2px solid #ef9cba; border-radius:20px;\
|
||||
font-family:Microsoft YaHei; color:white;margin:0;font-size:36px;}"
|
||||
color:white;margin:0;font-size:36px;}"
|
||||
"QTextEdit{background-color: rgba(0,0,0,0.5);\
|
||||
min-height:300px;max-height:300px; min-width:700px;max-width:700px;\
|
||||
border: 2px solid #ef9cba; border-radius:20px;\
|
||||
@@ -55,7 +55,7 @@ void InputObject::initUi()
|
||||
"QLineEdit,QDateEdit,QTextEdit{\
|
||||
background:qlineargradient(x1:0,y1:0,x2:1,y2:1,stop: 0.0 silver, stop: 1.0 grey);\
|
||||
border: 1px solid #1e1b18; border-radius:20px;\
|
||||
font-family:Microsoft YaHei; color:black;margin:0;font-size:36px;}"
|
||||
color:black;margin:0;font-size:36px;}"
|
||||
|
||||
"QLineEdit,QDateEdit{min-height:100px; max-height:100px; min-width:500px; max-width:500px;}"
|
||||
"QTextEdit{min-height:300px;max-height:300px; min-width:700px;max-width:700px;}"
|
||||
@@ -82,7 +82,7 @@ void InputObject::initUi()
|
||||
});
|
||||
}
|
||||
|
||||
bool InputObject::eventFilter(QObject *obj, QEvent *event)
|
||||
bool InputObject::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
|
||||
//mouse button release means setfocus is useless
|
||||
@@ -92,7 +92,7 @@ bool InputObject::eventFilter(QObject *obj, QEvent *event)
|
||||
|
||||
if (obj->objectName() == QString("qt_spinbox_lineedit"))
|
||||
{
|
||||
QDateEdit *_date = qobject_cast<QDateEdit*>(obj->parent());
|
||||
QDateEdit* _date = qobject_cast<QDateEdit*>(obj->parent());
|
||||
if (_date == ui->dateEdit)return true;
|
||||
if (_date->isEnabled())
|
||||
{
|
||||
@@ -102,7 +102,7 @@ bool InputObject::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
if (obj->objectName() == QString("qt_scrollarea_viewport"))
|
||||
{
|
||||
QTextEdit *_text= qobject_cast<QTextEdit*>(obj->parent());
|
||||
QTextEdit* _text = qobject_cast<QTextEdit*>(obj->parent());
|
||||
if (!_text) return false;
|
||||
if (_text == ui->textEdit) return true; //
|
||||
if (_text->isEnabled())
|
||||
@@ -113,7 +113,7 @@ bool InputObject::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
|
||||
if (obj->inherits("QLineEdit")) {
|
||||
QLineEdit *tbx = qobject_cast<QLineEdit*>(obj);
|
||||
QLineEdit* tbx = qobject_cast<QLineEdit*>(obj);
|
||||
//you have to tell whether it is coming from qdateedit!!!
|
||||
if (ui->lineEdit != tbx && tbx->isEnabled())
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ LoginWindow::~LoginWindow()
|
||||
|
||||
void LoginWindow::initUi()
|
||||
{
|
||||
QString style = "*{background-color:#3c3c3c; font-family:Microsoft YaHei; color:white;margin:0;font-size:16px;}"
|
||||
QString style = "*{background-color:#3c3c3c; color:white;margin:0;font-size:16px;}"
|
||||
"QLabel#title{font-Size:98px;color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
||||
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);}"
|
||||
"QLabel#warn{color:#930000;background:transparent;font-size:20px;}"
|
||||
@@ -61,22 +61,22 @@ void LoginWindow::initUi()
|
||||
m_pVMainLayout = new QVBoxLayout(this);
|
||||
m_pVMainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_pVMainLayout->setSpacing(0);
|
||||
m_pVMainLayout->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Minimum,QSizePolicy::Expanding));
|
||||
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
|
||||
QLabel* title = new QLabel(this);
|
||||
title->setObjectName("title");
|
||||
title->setText("U S C T");
|
||||
m_pVMainLayout->addWidget(title,0,Qt::AlignCenter);
|
||||
m_pVMainLayout->addWidget(title, 0, Qt::AlignCenter);
|
||||
m_pUserCodeFrame = new QFrame(this);
|
||||
m_pUserCodeFrame->setObjectName("login_frame_username");
|
||||
m_pUserCodeLayout = new QVBoxLayout(m_pUserCodeFrame);
|
||||
m_pUserCodeLayout->setSpacing(30);
|
||||
m_pUserCodeLayout->setContentsMargins(20,60,20,20);
|
||||
m_pUserCodeLayout->setContentsMargins(20, 60, 20, 20);
|
||||
warn = new QLabel(this);
|
||||
warn->setObjectName("warn");
|
||||
warn->setText("Login failed, username or password error!");
|
||||
warn->setVisible(false);
|
||||
m_pUserCodeLayout->addWidget(warn,0,Qt::AlignCenter);
|
||||
m_pUserCodeLayout->addWidget(warn, 0, Qt::AlignCenter);
|
||||
m_pUserCodeEdit = new QLineEdit(m_pUserCodeFrame);
|
||||
m_pUserCodeEdit->setObjectName("combobox_UserName");
|
||||
|
||||
@@ -84,7 +84,7 @@ void LoginWindow::initUi()
|
||||
|
||||
m_pUserCodeEdit->setPlaceholderText(tr("Username"));
|
||||
m_pUserCodeLayout->addWidget(m_pUserCodeEdit);
|
||||
m_pVMainLayout->addWidget(m_pUserCodeFrame,0,Qt::AlignCenter);
|
||||
m_pVMainLayout->addWidget(m_pUserCodeFrame, 0, Qt::AlignCenter);
|
||||
|
||||
m_pPassWordEdit = new QLineEdit(this);
|
||||
m_pPassWordEdit->setObjectName("edt_Password");
|
||||
@@ -92,12 +92,12 @@ void LoginWindow::initUi()
|
||||
m_pPassWordEdit->setPlaceholderText(tr("Password"));
|
||||
m_pUserCodeLayout->addWidget(m_pPassWordEdit);
|
||||
|
||||
ADD_TOOL_BTN_TO_LAYOUT(login,":/icons/login.png",m_pUserCodeLayout);
|
||||
ADD_TOOL_BTN_TO_LAYOUT(login, ":/icons/login.png", m_pUserCodeLayout);
|
||||
m_pUserCodeLayout->removeWidget(btnlogin);
|
||||
m_pUserCodeLayout->addWidget(btnlogin,0,Qt::AlignCenter);
|
||||
m_pUserCodeLayout->addWidget(btnlogin, 0, Qt::AlignCenter);
|
||||
m_pLoginButton = btnlogin;
|
||||
// m_pUserCodeLayout->addWidget(m_pLoginButton, 0, Qt::AlignCenter);
|
||||
m_pVMainLayout->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Minimum,QSizePolicy::Expanding));
|
||||
// m_pUserCodeLayout->addWidget(m_pLoginButton, 0, Qt::AlignCenter);
|
||||
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
|
||||
initUserList();
|
||||
}
|
||||
@@ -109,14 +109,14 @@ void LoginWindow::init()
|
||||
|
||||
void LoginWindow::initUserList()
|
||||
{
|
||||
// userList = UserService::queryUserInfo("");
|
||||
// for (int i = 0; i < userList.count(); i++)
|
||||
// {
|
||||
// QString userCode = userList.at(i)->getUserCode();
|
||||
// //QString userName = userList.at(i)->getUserName();
|
||||
// //m_pUserCodeEdit->addItem(userCode + splitFlag + userName);
|
||||
// m_pUserCodeEdit->addItem(userCode);
|
||||
// }
|
||||
// userList = UserService::queryUserInfo("");
|
||||
// for (int i = 0; i < userList.count(); i++)
|
||||
// {
|
||||
// QString userCode = userList.at(i)->getUserCode();
|
||||
// //QString userName = userList.at(i)->getUserName();
|
||||
// //m_pUserCodeEdit->addItem(userCode + splitFlag + userName);
|
||||
// m_pUserCodeEdit->addItem(userCode);
|
||||
// }
|
||||
}
|
||||
|
||||
void LoginWindow::clearInputData()
|
||||
@@ -147,25 +147,26 @@ void LoginWindow::doLogin()
|
||||
QString encryptPwd = getEncryptedPassword(strPassWord);
|
||||
QString sql = QString("select UserCode from Account where UserCode='%1' and Password='%2'")
|
||||
.arg(strUserCode).arg(encryptPwd);
|
||||
if (SQLHelper::QueryCount(sql)>0)
|
||||
if (SQLHelper::QueryCount(sql) > 0)
|
||||
{
|
||||
accept();
|
||||
} else{
|
||||
}
|
||||
else {
|
||||
warn->setVisible(true);
|
||||
}
|
||||
// bool isLoginSuccess = UserService::ValidateAccount(strUserCode, encryptedPassword);
|
||||
// if (isLoginSuccess)
|
||||
// {
|
||||
// accept();
|
||||
// emit sigUserLoginSuccessful(strUserCode);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EQ9MessageBox box;
|
||||
// box.setMessage(tr("login failed, please check input data"));
|
||||
// box.exec();
|
||||
// return;
|
||||
// }
|
||||
// bool isLoginSuccess = UserService::ValidateAccount(strUserCode, encryptedPassword);
|
||||
// if (isLoginSuccess)
|
||||
// {
|
||||
// accept();
|
||||
// emit sigUserLoginSuccessful(strUserCode);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EQ9MessageBox box;
|
||||
// box.setMessage(tr("login failed, please check input data"));
|
||||
// box.exec();
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
//void LoginWindow::onUserCodeFocusOut(QFocusEvent* e)
|
||||
|
||||
50
src/main.cpp
50
src/main.cpp
@@ -1,44 +1,66 @@
|
||||
#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* 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:
|
||||
needLogin:
|
||||
l.showFullScreen();
|
||||
int rec = l.exec();
|
||||
if (rec !=QDialog::Accepted )
|
||||
if (rec != QDialog::Accepted)
|
||||
{
|
||||
goto needLogin;
|
||||
}
|
||||
// l.deleteLater();
|
||||
// l.deleteLater();
|
||||
w.centerWidgetShow();
|
||||
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "guimessagedialog.h"
|
||||
#include "device/DeviceManager.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
const QString style = "*{background-color:#3c3c3c; font-family:Microsoft YaHei; color:white;margin:0;font-size:16px;}"
|
||||
const QString style = "*{background-color:#3c3c3c; color:white;margin:0;font-size:16px;}"
|
||||
"QTabBar::tab {\n"
|
||||
"height:60px;"
|
||||
"width:300px;"
|
||||
@@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
"background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\"\n"
|
||||
"stop: 0 #333333, stop: 1.0 #555555);"
|
||||
"border: 2px solid #505050;\n"
|
||||
// "border-bottom-color: #323232; /* same as the pane color */\n"
|
||||
// "border-bottom-color: #323232; /* same as the pane color */\n"
|
||||
"border-bottom-left-radius: 50%;\n"
|
||||
"border-bottom-right-radius: 50%;\n"
|
||||
"min-width: 8ex;\n"
|
||||
@@ -70,63 +70,66 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
;
|
||||
this->setStyleSheet(style);
|
||||
ui->setupUi(this);
|
||||
QTabWidget *tab = new QTabWidget(this);
|
||||
QTabWidget* tab = new QTabWidget(this);
|
||||
tab->setTabPosition(QTabWidget::South);
|
||||
tab->setContentsMargins(0,0,0,0);
|
||||
connect(EventCenter::Default(),&EventCenter::PatientSelected,[=](QObject* sender,QObject* data){
|
||||
tab->setContentsMargins(0, 0, 0, 0);
|
||||
connect(EventCenter::Default(), &EventCenter::PatientSelected, [=](QObject* sender, QObject* data) {
|
||||
tab->setCurrentIndex(1);
|
||||
});
|
||||
SelectFormWidget* select_form= new SelectFormWidget(this);
|
||||
SelectFormWidget* select_form = new SelectFormWidget(this);
|
||||
tab->addTab(select_form, "Select");
|
||||
ScanFormWidget* scan_form= new ScanFormWidget(this);
|
||||
ScanFormWidget* scan_form = new ScanFormWidget(this);
|
||||
tab->addTab(scan_form, "Scan");
|
||||
TabFormWidget* verify_form= new TabFormWidget(this);
|
||||
TabFormWidget* verify_form = new TabFormWidget(this);
|
||||
tab->addTab(verify_form, "Verify");
|
||||
tab->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
tab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(tab);
|
||||
ui->centralWidget->setLayout(layout);
|
||||
this->setWindowFlags (Qt::Window);
|
||||
connect(EventCenter::Default(),&EventCenter::GUIErrorRaise,[=](QObject*,QObject* msg){
|
||||
this->setWindowFlags(Qt::Window);
|
||||
connect(EventCenter::Default(), &EventCenter::GUIErrorRaise, [=](QObject*, QObject* msg) {
|
||||
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||
if (msg)
|
||||
{
|
||||
QString* str = (QString*)msg;
|
||||
msgDialog->showMessage(*str);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
msgDialog->showMessage("Something went error!");
|
||||
}
|
||||
msgDialog->showExitButton();
|
||||
msgDialog->stopLoading();
|
||||
msgDialog->showFullScreen();
|
||||
});
|
||||
connect(EventCenter::Default(),&EventCenter::InvokeOperationStart,[=](QObject*,QObject* msg){
|
||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationStart, [=](QObject*, QObject* msg) {
|
||||
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||
if (msg)
|
||||
{
|
||||
QString* str = (QString*)msg;
|
||||
msgDialog->showMessage(*str);
|
||||
} else{
|
||||
}
|
||||
else {
|
||||
msgDialog->hideMessage();
|
||||
}
|
||||
msgDialog->hideExitButton();
|
||||
msgDialog->startLoading();
|
||||
msgDialog->showFullScreen();
|
||||
});
|
||||
connect(EventCenter::Default(),&EventCenter::InvokeOperationProgress,[=](QObject*,QObject* msg){
|
||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress, [=](QObject*, QObject* msg) {
|
||||
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||
if (msg)
|
||||
{
|
||||
QVariant* var = (QVariant*)msg;
|
||||
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat()*100.0f)));
|
||||
} else{
|
||||
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat() * 100.0f)));
|
||||
}
|
||||
else {
|
||||
msgDialog->hideMessage();
|
||||
}
|
||||
msgDialog->hideExitButton();
|
||||
msgDialog->showFullScreen();
|
||||
});
|
||||
connect(EventCenter::Default(),&EventCenter::InvokeOperationEnd,[=](){
|
||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
|
||||
if (!msgDialog) return;
|
||||
msgDialog->stopLoading();
|
||||
msgDialog->hide();
|
||||
|
||||
Reference in New Issue
Block a user