Files
vx4-GuiLin-Gear/.svn/pristine/31/315a468534152a92f38da742ee0029d2a43cafc4.svn-base
T

279 lines
9.3 KiB
Plaintext
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 <QtGui/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
/*
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>
int main(int argc, char *argv[])
{
// QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);//控制图片缩放质量
// // Open a display.
// Display *d = XOpenDisplay(NULL);
// // Get width and height of the display
// //int windowHeight = XDisplayHeight (d, 0);
// qreal windowWidth = XDisplayWidth(d, 0);
// qreal windowWidth = 800;
// qreal scale = windowWidth / 640;
// //qputenv("QT_SCALE_FACTOR", QString::number(scale).toLatin1());
//qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1.5");
// qputenv("QT_SCALE_FACTOR", QByteArray("1.25"));
// qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
// QByteArray byte = qgetenv("QT_SCALE_FACTOR");
// qDebug() << "qgutenv byte=============================" << byte;
// QByteArray byteModule = qgetenv("QT_IM_MODULE");
// qDebug() << "qgutenv byteModule=============================" << byteModule;
// QLocale::setDefault(QLocale(QLocale::Vietnamese, QLocale::VietNam));
QApplication a(argc, argv,QApplication::GuiServer);
// QDesktopWidget *desktop = a.desktop();
// int screen_number = desktop->primaryScreen();
// QRect rect = desktop->screenGeometry(screen_number);
//qDebug() << QStyleFactory::keys();
QApplication::setStyle(QStyleFactory::create("Windows"));
QFont f = a.font();
QString langurageFile;
QFile file(SYS_ROOT_DIR"UseEn");
if(file.exists())
{
#ifdef VNLG
QString langurageType = Public::ReadLanguageName();//"";//
//qDebug()<<"La:"<<langurageType;
if(langurageType=="中文"){
f.setFamily("WenQuanYiMH");// WenQuanYiMH -- 由 WenQuanYiMicroHei_12_50目录生成,
f.setPointSize(12);
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
else if(langurageType=="Vietnamese") {
f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(13);
//f.setFixedPitch(1);
f.setPixelSize(13);
langurageFile= "./vena.qm";
}
else if(langurageType=="English") {
f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(13);
f.setPixelSize(13);
langurageFile= "./english.qm";
}
else {
f.setPointSize(12);
//f.setFamily("wenquanyi_zh");//WenQuanYiMH
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("UnDotum"); //
f.setFamily("WenQuanYiMH");
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
#else
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 EnableArabic
// f.setFamily("Arial");
//#endif
#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{
f.setPointSize(16);
f.setFamily("WenQuanYiMH");
//f.setFamily("wenquanyi_zh");
f.setPixelSize(16);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
/*
f.setPointSize(12);
//f.setFamily("wenquanyi_zh");//WenQuanYiMH
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("UnDotum"); //
f.setFamily("WenQuanYiMH");
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";
//langurageFile= "./english.qm";
*/
#endif
// qDebug()<<"languageFile:"<<langurageType<<langurageFile;
//Việt Nam
}
else{
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
#ifdef ENGLISH
langurageFile= "./english.qm";
#endif
#ifdef VNLG
f.setFamily("WenQuanYiMH");
#else
//f.setFamily("wenquanyi_zh");
f.setFamily("wenquanyi");
#endif
//qDebug()<<"languageFile:"<<f.family()<<langurageFile;
}
a.setFont(f);
/*-------------------------------------------------*/
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
/*------------------语言国际化-------------------------*/
QTranslator *translator = new QTranslator();
if(translator->load(langurageFile)==false){
translator->deleteLater();
QMessageBox::critical(0,("错误"),("无法加载中文翻译文件") + langurageFile);
}
else {
QApplication::installTranslator(translator);
}
#ifndef Q_OS_WIN32
//QWSServer::setCurrentInputMethod(new MyInputMethod());
myInputMethod = new MyInputMethod();
QWSServer::setCurrentInputMethod(myInputMethod);
#endif
// 配置日志
//QString configFileName = QCoreApplication::applicationDirPath() + "/config.ini";
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(("比洋喷码"));
#if 0
w.setStyleSheet("QTabBar::tab {height:70px;} QTabBar::scroller{ width:40px;} QRadioButton::indicator{ width: 50px; height: 50px; } \
QCheckBox::indicator { width: 18px; height: 18px; } ");
#endif
//edit@11-28
const QString style_main2="QTabBar::tab {height:55px;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:57px;}\
QTabBar::tab:!selected {margin-top: 2px;}\
QTabBar::scroller{ width:40px;} \
QRadioButton::indicator{ width: 45px; height: 45px; } \
QCheckBox::indicator { width: 18px; height: 18px; } ";
w.setStyleSheet(style_main2);
w.showFullScreen(); /*保证全屏,看不到系统标题*/
#endif
w.show();
pInkJectPrinter = &w;
return a.exec();
}