增加report翻译

master
bob.pan 4 years ago
parent f36fb28516
commit c1995212ef

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -155,6 +155,9 @@
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets</IncludePath>
</QtMoc>
</ItemGroup>
<ItemGroup>
<None Include="report_en.ts" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(QtMsBuild)\qt.targets" />

@ -31,6 +31,11 @@
<Filter Include="db">
<UniqueIdentifier>{254918ee-db1e-4bc7-a132-e121174a9976}</UniqueIdentifier>
</Filter>
<Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
<ParseFiles>false</ParseFiles>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -96,4 +101,9 @@
<Filter>db</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="report_en.ts">
<Filter>Translation Files</Filter>
</None>
</ItemGroup>
</Project>

@ -2,11 +2,21 @@
#include "qstandarditemmodel.h"
#include "qmessagebox.h"
#include "qfontmetrics.h"
#include <QDir>
#include <QSettings>
#pragma execution_character_set("utf-8")
QCheckDataDlg::QCheckDataDlg(QWidget *parent)
: QDialog(parent), m_db(NULL), nPrevNum(0), nTotlaNumber(0)
{
ui.setupUi(this);
QString m_AppPath = QApplication::applicationDirPath();
QString m_CfgPath = m_AppPath + QString("//user//systemConfig.ini");
QSettings setting(m_CfgPath, QSettings::IniFormat);
QString m_CurLanguage = setting.value("language/select", "Chinese").toString();
SetLanguage(m_CurLanguage);
m_ViewImg = new QTpGraphView;
connect(ui.m_pbCheck, SIGNAL(clicked()), this, SLOT(onCheckOutData()));
connect(ui.Prev_checkShengchang, SIGNAL(clicked()), this, SLOT(onChenckButton()));
@ -296,6 +306,14 @@ void QCheckDataDlg::setPageShow(int page,int totalPage)
ui.showPage_Label_Checkdata->setText(str);
}
void QCheckDataDlg::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
ui.retranslateUi(this);
}
}
Q_SLOT void QCheckDataDlg::onTBUI_ItemClick(const QModelIndex & index)
{
QModelIndex nindex = m_tableModel->index(index.row(), 0);
@ -368,4 +386,84 @@ Q_SLOT void QCheckDataDlg::onSlowPixmap(QSqlQuery sql)
nFlag = false;
}
//======系统翻译相关
void QCheckDataDlg::SearchQmFile(const QString & strDir)
{
QDir dir(strDir);
if (!dir.exists())
{
return;
}
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
dir.setSorting(QDir::DirsFirst); // 文件夹优先
// 转换成一个List
QFileInfoList list = dir.entryInfoList();
if (list.size() < 1)
{
return;
}
int i = 0;
do
{
QFileInfo fileInfo = list.at(i);
QString tt = fileInfo.fileName();
// 如果是文件夹
bool bisDir = fileInfo.isDir();
if (bisDir)
{
SearchQmFile(fileInfo.filePath());
}
else
{
bool bQm = fileInfo.fileName().endsWith(".qm");
SetTranslator(fileInfo.filePath());
}
i++;
} while (i < list.size());
}
void QCheckDataDlg::rmTranslator()
{
if (m_VecTranPtr.size() > 0)
{
while (m_VecTranPtr.size())
{
QTranslator *pVa = m_VecTranPtr.takeFirst();
qApp->removeTranslator(pVa);
delete pVa;
pVa = NULL;
}
}
}
void QCheckDataDlg::SetLanguage(QString strLangage)
{
QString strDirPath = QString(QCoreApplication::applicationDirPath() + "/language/");
QString translatorFileName = strLangage;
if (!translatorFileName.isEmpty())
{
rmTranslator();
QLocale::setDefault(QLocale(translatorFileName));
QString transDir = strDirPath + translatorFileName;
SearchQmFile(transDir);
}
}
void QCheckDataDlg::SetTranslator(const QString strPath)
{
if (strPath.isEmpty())
{
return;
}
QTranslator *pTrans = new QTranslator;
if (pTrans->load(strPath)) // 如果加载成功
{
qApp->installTranslator(pTrans);
m_VecTranPtr.append(pTrans);
}
else
{
delete pTrans;
pTrans = NULL;
}
}

@ -10,6 +10,8 @@
#include "qdatetimeedit.h"
#include "QTextBrowser.h"
#include "cunstomgraphview.h"
#include <QTranslator>
class QCheckDataDlg : public QDialog
{
Q_OBJECT
@ -25,6 +27,12 @@ private:
Q_SLOT void onCheckOutData();
Q_SLOT void onTBUI_ItemClick(const QModelIndex & index);
Q_SLOT void onSlowPixmap(QSqlQuery sql);
void SearchQmFile(const QString & strDir);
void rmTranslator();
void SetLanguage(QString strLangage);
void SetTranslator(const QString strPath);
private:
int getLimitNumber();
int getTotalNumber();
@ -36,6 +44,8 @@ private:
void updateModelShowLog(QSqlQuery &sql);
void onCheckOutData(int nLimitNum, int nPrenum);
void setPageShow(int page, int totalPage);
protected:
virtual void changeEvent(QEvent *event);
private:
Ui::QCheckDataDlg ui;
@ -53,6 +63,9 @@ private:
int nTotlaNumber;
QTpGraphView *m_ViewImg{ nullptr };
QVector<QTranslator* > m_VecTranPtr;
QString m_strCurLanguage{ "Chinese" };
};
#endif // QCHECKDATADLG_H

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>QCheckDataDlg</name>
<message>
<location filename="qcheckdatadlg.ui" line="14"/>
<source></source>
<translation>History Recode</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="90"/>
<source></source>
<translation>operation</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="97"/>
<location filename="qcheckdatadlg.ui" line="124"/>
<source></source>
<translation>All</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="102"/>
<source>error</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="110"/>
<source></source>
<translation>End Time:</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="132"/>
<source></source>
<translation>Error Type:</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="145"/>
<source></source>
<translation>Start Time:</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="155"/>
<source></source>
<translation>Station:</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="171"/>
<source></source>
<translation>Check</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="212"/>
<source>()</source>
<translation>Show Recodes</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="237"/>
<source>50</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="250"/>
<source></source>
<translation>Previous</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="257"/>
<location filename="qcheckdatadlg.ui" line="284"/>
<location filename="qcheckdatadlg.ui" line="300"/>
<source>TextLabel</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="264"/>
<source></source>
<translation>Next</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="357"/>
<location filename="qcheckdatadlg.ui" line="382"/>
<source></source>
<translation>Statics</translation>
</message>
<message>
<location filename="qcheckdatadlg.ui" line="379"/>
<source></source>
<translation>The total number of query time records is collected</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="qcheckdatadlg.cpp" line="60"/>
<source></source>
<translation>Time</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="61"/>
<source></source>
<translation>Model</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="62"/>
<source>matchScore</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="63"/>
<source>BenchMark</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="64"/>
<source>Angle</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="65"/>
<source>errorType</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="66"/>
<source>resultTip</source>
<translation></translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="67"/>
<source></source>
<translation>Station</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="109"/>
<source>%1</source>
<translation>with %1 recodes</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="136"/>
<location filename="qcheckdatadlg.cpp" line="138"/>
<location filename="qcheckdatadlg.cpp" line="140"/>
<location filename="qcheckdatadlg.cpp" line="175"/>
<location filename="qcheckdatadlg.cpp" line="177"/>
<location filename="qcheckdatadlg.cpp" line="179"/>
<location filename="qcheckdatadlg.cpp" line="233"/>
<location filename="qcheckdatadlg.cpp" line="287"/>
<source></source>
<translation>All</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="201"/>
<location filename="qcheckdatadlg.cpp" line="219"/>
<source></source>
<translation>Info</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="201"/>
<source></source>
<translation>This is the last page</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="203"/>
<location filename="qcheckdatadlg.cpp" line="221"/>
<source></source>
<translation>OK</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="219"/>
<source></source>
<translation>This is the first page</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="295"/>
<source>%1 %2</source>
<translation>%1,%2</translation>
</message>
<message>
<location filename="qcheckdatadlg.cpp" line="328"/>
<source>(/)</source>
<translation>No Image(Image Deleted)</translation>
</message>
</context>
</TS>

@ -133,9 +133,9 @@ CMainWin::CMainWin(QWidget *parent)
m_TimerID_Status = startTimer(1000);
ui.actionSystem->setDisabled(true);
ui.actionTest->setDisabled(true);
ui.actionStandard->setDisabled(true);
//ui.actionSystem->setDisabled(true);
//ui.actionTest->setDisabled(true);
//ui.actionStandard->setDisabled(true);
}
CMainWin::~CMainWin()

Loading…
Cancel
Save