Files
VX5-DiaphragmPump/main.cpp
T
2026-10-19 17:03:47 +08:00

257 lines
8.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <QApplication>
#include <QVBoxLayout>
#include <InputMethod.h>
#include <QKeyEvent>
#include <QTextCodec>
#include <QTextEdit>
#include <QFont>
//#include <QWSServer>
#include <stdio.h>
#include "InkJetPrinter.h"
#include "logo_form.h"
#include "MyInputMethod.h"
#include "mainwindow.h"
#include <QDebug>
#include <QTranslator>
#include <QMessageBox>
#include <QStyleFactory>
#include "myinclude.h"
#include "Public.h"
#include "Log/filelogger.h"
//#define SYS_CN
#include "dump.h"
QString gAppNameStr = "";
/*
1. WenQuanYiMH_12_50.qpf2 是由 Zfull-GB_12_50(Zpix.ttf)在PCMAKEQPF软件下生成的,它包含较完整的字体库 nono 20160302
2. 基于WenQuanYiCN编越南语,中文通用字库
3. 基于WenQuanYiMicroHei编 普通版本字库
#git commit -am "测试提交新数据"
#git push
#git clone xiongnie@119.23.201.56:/var/repo_dir/QtUI.git
#git pull xiongnie@119.23.201.56:/var/repo_dir/QtUI.git
#git remote add origin git@github.com:username/Hello-World.git
#git push origin master 将本地项目给提交到服务器中
#-----------------------------------------------------------
#git pull 本地与服务器端同步
#-----------------------------------------------------------------
#git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
#git push origin serverfix:awesomebranch
git remote add origin xiongnie@119.23.201.56:/var/repo_dir/QRUIV53.git
###
*/
InkJetPrinter *pInkJectPrinter;
MyInputMethod *myInputMethod;
//#include <X11/Xlib.h>
//#include <X11/X.h>
//#include <X11/Xutil.h>
void loadApplicationFonts();
int main(int argc, char *argv[])
{
QString keyBoardType = Public::ReadKeyBoardUse();
if(keyBoardType == "MultiLanguage")
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QApplication a(argc, argv);
gAppNameStr = QString::fromUtf8(argv[0]);
installSignalHandlers();
loadApplicationFonts();
QApplication::setStyle(QStyleFactory::create("Windows"));
QFont f = a.font();
QString langurageFile;
QFile file(SYS_ROOT_DIR"UseEn");
if(file.exists())
{
QString langurageType = Public::ReadLanguageName();//"";//
qDebug()<<"La:"<<langurageType;
if(langurageType=="Turkish") {
f.setFamily("wenquanyi_zh");
langurageFile= "./turkey.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Spanish")
{
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("wenquanyi_zh");
langurageFile= "./spanish.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Thai")
{
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("Kanit");
langurageFile= "./thai.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Vietnamese") {
f.setFamily("Arial");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(12);
//f.setFixedPitch(1);
f.setPixelSize(12);
langurageFile= "./vena.qm";
}
else if(langurageType=="English") {
f.setFamily("Arial");
#ifdef EnableBangla
f.setFamily("wenquanyi_zh");
#endif
langurageFile= "./english.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Farsi") {
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("Arial");
langurageFile= "./farsi.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="korean") {
f.setFamily("Microsoft YaHei Light");
langurageFile= "./korean.qm";
f.setPointSize(14);
f.setPixelSize(14);
// f.setLetterSpacing(1,8);
}
else{
f.setFamily("WenQuanYi Micro Hei");
f.setPointSize(16);
f.setPixelSize(16);
langurageFile ="./qt_zh_CN.qm";
}
}
else{
langurageFile ="./qt_zh_CN.qm";
f.setFamily("WenQuanYi Micro Hei");
f.setPointSize(16);
f.setPixelSize(16);
}
a.setFont(f);
/*-------------------------------------------------*/
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
/*------------------语言国际化-------------------------*/
QTranslator *translator = new QTranslator();
if(translator->load(langurageFile)==false){
translator->deleteLater();
QMessageBox::critical(0,("错误"),("无法加载中文翻译文件") + langurageFile);
}
else {
QApplication::installTranslator(translator);
}
myInputMethod = new MyInputMethod();//edit@02-07
// 配置日志
QString configFileName = ":/conf/config.ini";
QSettings* logSettings = new QSettings(configFileName, QSettings::IniFormat, &a);
logSettings->beginGroup("logging");
FileLogger* logger = new FileLogger(logSettings, 10000, &a);
logger->installMsgHandler();
InkJetPrinter w;
#ifndef Q_OS_WIN32
w.setWindowTitle(("比洋喷码"));
//edit@11-28
const QString style_main2="QTabBar::tab {height:65px;border-top-left-radius: 6px;border-top-right-radius: 6px;padding-left: 11px;padding-right: 11px;border: 2px solid #C4C4C3;} \
QTabBar::tab:selected {background-color: rgb(255, 170, 127);height:70px;}\
QTabBar::tab:!selected {margin-top: 5px;}\
QTabBar::scroller{ width:80px;} \
QRadioButton::indicator{ width: 24px; height: 24px; } \
QCheckBox::indicator { width: 18px; height: 18px; } ";
w.setStyleSheet(style_main2);
//w.showFullScreen(); /*保证全屏,看不到系统标题*/
#endif
if (QSysInfo::buildCpuArchitecture().contains("x86")) {
qDebug() << "Running in Debug mode";
w.show();
} else {
qDebug() << "Running in Release mode";
w.showFullScreen();
}
// w.show();
pInkJectPrinter = &w;
return a.exec();
}
void loadApplicationFonts() {
QStringList fontPaths = {
"/usr/lib/fonts/YaHeiBold-5pt-6.bdf",
"/usr/lib/fonts/YaHeiBold-7pt-8.bdf",
"/usr/lib/fonts/YaHeiBold-9pt-10.bdf",
"/usr/lib/fonts/YaHeiBold-12pt-13.bdf",
"/usr/lib/fonts/YaHeiBold-16pt-17.bdf",
"/usr/lib/fonts/WenQuanYiMedium-5pt-6.bdf",
"/usr/lib/fonts/WenQuanYiMedium-7pt-8.bdf",
"/usr/lib/fonts/DinkieBitmap9pxMedium-9pt-10.bdf",
"/usr/lib/fonts/WenQuanYiMedium-12pt-13.bdf",
"/usr/lib/fonts/WenQuanYiMedium-16pt-17.bdf",
"/usr/lib/fonts/WenQuanYiMedium-24pt-25.bdf",
"/usr/lib/fonts/WenQuanYiMedium-32pt-33.bdf",
"/usr/lib/fonts/WenQuanYiMicroHei.ttf",
"/usr/lib/fonts/msyhl_12pt.bdf",
"/usr/lib/fonts/arial.ttf",
"/usr/lib/fonts/YanglabeldotMedium-12pt-13.bdf",
"/usr/lib/fonts/DinkieBitmap9MepxdiumL-9pt-10.bdf", // 添加左翻字体
"/usr/lib/fonts/WenQuanYiMediumL-5pt-6.bdf",
"/usr/lib/fonts/WenQuanYiMediumL-7pt-8.bdf",
"/usr/lib/fonts/WenQuanYiMediumL-12pt-13.bdf",
"/usr/lib/fonts/WenQuanYiMediumL-16pt-17.bdf",
"/usr/lib/fonts/WenQuanYiMediumL-24pt-25.bdf",
"/usr/lib/fonts/WenQuanYiMediumL-32pt-33.bdf",
"/usr/lib/fonts/DinkieBitmap9pxMediumR-9pt-10.bdf", // 添加右翻字体
"/usr/lib/fonts/WenQuanYiMediumR-5pt-6.bdf",
"/usr/lib/fonts/WenQuanYiMediumR-7pt-8.bdf",
"/usr/lib/fonts/WenQuanYiMediumR-12pt-13.bdf",
"/usr/lib/fonts/WenQuanYiMediumR-16pt-17.bdf",
"/usr/lib/fonts/WenQuanYiMediumR-24pt-25.bdf",
"/usr/lib/fonts/WenQuanYiMediumR-32pt-33.bdf"
};
foreach (const QString &path, fontPaths) {
if (QFile::exists(path)) {
int fontId = QFontDatabase::addApplicationFont(path);
if (fontId == -1) {
qDebug()<< "Failed to load font:" << path;
} else {
qDebug()<< "Loaded font:" << path<< "ID:"<< fontId;
}
}
}
}