feat: Supplement translations.

This commit is contained in:
sunwen
2024-06-25 10:25:26 +08:00
parent 9d89a06c67
commit 749e125a95
10 changed files with 378 additions and 227 deletions

View File

@@ -90,7 +90,7 @@ void DeviceManager::initDevice()
{
if(!AppGlobalValues::DBconnected().toBool())
{
emitErrorCallback("Fail to connect to DB!Reboot device to try!");
emitErrorCallback(tr("Fail to connect to DB!Reboot device to try!"));
emit initializeFinished();
return;
}
@@ -140,10 +140,10 @@ void DeviceManager::initDevice()
mStartAutoLocateAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_MOTION_START, this, "responseStartAutoLocate(const QString&)", this);
mStopAutoLocateAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_MOTION_STOP, this, "responseStopAutoLocate(const QString&)", this);
mCheckDataQualityAction = new DmsSyncAction(USRV_SCAN, ACT_SCAN_IMGQUALITI, this, "responseCheckDataQuality(const QString&)", this);
mGetSoftwareVersionAction = new DmsSyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
//Async action
mGetScanProgressAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_PROGRESS_PASSIVE, this,"responseGetScanProgress(const QString&)", this);
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
mGetDeviceTemperatureAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_TEMP, this, "responseGetDeviceTemperature(const QString&)", this);
mStopTransferAction = new DmsAsyncAction(USRV_XFR, ACT_XFR_STOP, this, "responseStopTransfer(const QString&)", this);
mShutDownAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PWRDOWN, this, "responseShutDown(const QString&)", this);
@@ -216,6 +216,8 @@ void DeviceManager::initDevice()
mSetHeartBeatAction->setSendData("{ \"code\":0, \"info\":\"0\"}");
mSetHeartBeatAction->execute();
initDmsVersion();
mCheckInitStatusTimer = startTimer(500);
}
@@ -261,8 +263,6 @@ void DeviceManager::initGUI(bool aIsInitSucceed)
//process expired patient list
QDate date = QDate::currentDate().addDays(-JsonObject::Instance()->getPatientListExpireDays());
SQLHelper::exec(QString("DELETE FROM Patient WHERE AddDate <= %1").arg(date.toString("yyyy-MM-dd")));
mGetSoftwareVersionAction->execute();
}
void DeviceManager::processInitializeProgress(const QString& aProgress)
@@ -309,8 +309,7 @@ void DeviceManager::startScan(const QString& json, bool empty)
}
if (inf != DeviceStatus::Rready)
{
QString errMsg("Device is not ready, start scan operation fail!status is %1");
errMsg = errMsg.arg(getStatusString(inf));
QString errMsg(empty ? tr("Device is not ready, start empty scan operation failed!") : tr("Device is not ready, start scan operation failed!"));
THROW_ERROR(errMsg);
return;
}
@@ -416,7 +415,7 @@ void DeviceManager::prepareFinishScan(bool isNormalFinish, const QString& aReaso
if(isCompleteNotify)
{
QString msg = QString("Scan completed!");
QString msg = tr("Scan completed!");
TRIGGER_EVENT(InvokeOperationEnd, nullptr, (QObject *)&msg);
}
else
@@ -616,10 +615,9 @@ void DeviceManager::timerEvent(QTimerEvent* event)
}
void DeviceManager::emitErrorCallback(const char *msg)
void DeviceManager::emitErrorCallback(const QString& msg)
{
QString m(msg);
emit raiseGlobalError( m);
emit raiseGlobalError(msg);
}
void DeviceManager::emitInfoCallback(const QString& aMessage,const unsigned int aInfoType)
@@ -717,7 +715,6 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
{
case ACT_IFCFG_VERINFO :
emit responseGetSoftwareVersion(aContents);
processGetSoftwareVersion(aContents);
break;
case ACT_IFCFG_HBCFG :
emit responseSetHeartBeat(aContents);
@@ -783,14 +780,18 @@ void DeviceManager::processAlarm(const QString& aAlarm)
}
}
void DeviceManager::processGetSoftwareVersion(const QString& aSoftwareVersion)
void DeviceManager::initDmsVersion()
{
QJsonObject jsonObj = toJsonObject(aSoftwareVersion);
if(jsonObj["code"].toInt() != 0)
DmsSyncActionResult result = mGetSoftwareVersionAction->execute();
QJsonObject jsonObj = toJsonObject(result.mData);
if(result.mIsSucessful && jsonObj.contains("code") && jsonObj["code"].toInt() == 0)
{
return;
mSoftwareVersion = jsonObj["info"].toString();;
}
else
{
mSoftwareVersion = "Dms Fetch Error";
}
mSoftwareVersion = jsonObj["info"].toString();
}
void DeviceManager::scanTimeout()
@@ -803,7 +804,7 @@ DeviceStatus DeviceManager::getDeviceStatus()
DmsSyncActionResult result = mGetDeviceStatusAction->execute();
if(!result.mIsSucessful)
{
QString message = QString("Dms connection error. Reason:%1").arg(result.mData);
QString message = tr("DMS connection error");
THROW_ERROR(message);
return DeviceStatus::Unkonw;
}
@@ -841,7 +842,7 @@ bool DeviceManager::startFullScan(const QString& aPatientInfo)
int code = jsonObj["code"].toInt();
if(code != 0)
{
QString msg = jsonObj["info"].toString();
QString msg = tr("Start scan failed. Reason:%1").arg(jsonObj["info"].toString());
LOG_SYS_OPERATION("Start full scan failed. " + msg);
THROW_ERROR(msg);
TRIGGER_EVENT(StopScanProcess, nullptr, nullptr);
@@ -857,7 +858,7 @@ bool DeviceManager::startCEScan()
DmsSyncActionResult result = mCEScanAction->execute();
if(!result.mIsSucessful)
{
QString message = QString("Dms connection error. Reason:%1").arg(result.mData);
QString message = tr("Initialize Failed.");
THROW_ERROR(message);
return false;
}
@@ -930,7 +931,7 @@ void DeviceManager::processShutDownDms(const QString& aResponse)
void DeviceManager::shutdownOperationSystem()
{
qDebug()<< "shut down OS";
//QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
}
void DeviceManager::insertEmptyScanRecord()
@@ -994,8 +995,8 @@ void DeviceManager::startTransfer()
DmsSyncActionResult result = mTransferAction->execute();
if(!result.mIsSucessful)
{
QString message = QString("Dms connection error. Reason:%1").arg(result.mData);
THROW_ERROR(message);
QString msg = tr("Scan data transfer failed.");
emitInfoCallback(msg, MessageLevel::Error);
return;
}
@@ -1004,8 +1005,8 @@ void DeviceManager::startTransfer()
if(code != 0)
{
mStopTransferAction->execute();
QString msg = jsonObj["info"].toString();
THROW_ERROR(msg);
QString msg = tr("Scan data transfer failed.");
emitInfoCallback(msg, MessageLevel::Error);
return;
}
@@ -1058,7 +1059,7 @@ void DeviceManager::processTransferProgress(const QString& aProgress)
emitInfoCallback(msg, MessageLevel::Error);
break;
}
emitInfoCallback("Scan data transfer Succeeded!", MessageLevel::Sucess);
emitInfoCallback(tr("Scan data transfer Succeeded!"), MessageLevel::Sucess);
emit transferStatusUpdated();
if(ReconManager::getInstance()->isConnected())
{
@@ -1080,7 +1081,7 @@ void DeviceManager::processTransferProgress(const QString& aProgress)
emitInfoCallback(msg, MessageLevel::Error);
break;
}
QString message = QString("Scan data transfer failed.");
QString message = tr("Scan data transfer failed.");
emitInfoCallback(message, MessageLevel::Error);
break;
}
@@ -1100,7 +1101,7 @@ void DeviceManager::processReconCreateEmptyScan(bool aResult, const QString& aSc
return;
}
emitInfoCallback(aMessage, MessageLevel::Error);
emitInfoCallback(tr("Create empty scan data failed"), MessageLevel::Error);
QString sql = QString("UPDATE EScan set State = %1 where ScanID = '%2'").arg(aIsConnectSucceed ? "304" : "204").arg(aScanID);
if(!SQLHelper::exec(sql))
{
@@ -1122,7 +1123,7 @@ void DeviceManager::processReconCreateScan(bool aResult, const QString& aScanID,
return;
}
emitInfoCallback(aMessage, MessageLevel::Error);
emitInfoCallback(tr("Create scan data failed"), MessageLevel::Error);
QString sql = QString("UPDATE Scan set State = %1 where ScanID = '%2'").arg(aIsConnectSucceed ? "304" : "204").arg(aScanID);
if(!SQLHelper::exec(sql))
{
@@ -1199,7 +1200,7 @@ void DeviceManager::updateReconState()
emitInfoCallback(tr("Recon disconnected."), MessageLevel::Error);
return;
}
QString sql = "SELECT ScanID FROM Scan WHERE State < 999 And State >= 300";
QString sql = "SELECT ScanID FROM Scan WHERE State < 999 And State >= 300 And State != 304";
auto result = SQLHelper::queryValues(sql);
QStringList scanIDs;
for (const QVariant &variant : result)
@@ -1287,7 +1288,7 @@ void DeviceManager::updateReconConnectionState(bool aIsConnected)
void DeviceManager::startScanProcess()
{
LOG_SYS_OPERATION("Start scan process.")
LOG_SYS_OPERATION("Start scan process.");
if( !UsctStateManager::getInstance()->getState(ReconConnectionState) ||
!UsctStateManager::getInstance()->getState(ReconState) ||
!UsctStateManager::getInstance()->getState(ReconDBState))
@@ -1409,7 +1410,7 @@ void DeviceManager::checkDataQuality()
return;
}
}
QString errorMessage = tr("Dms connection error");
QString errorMessage = tr("DMS connection error");
prepareFinishScan(false, errorMessage);
TRIGGER_EVENT(StopScanProcess, nullptr, nullptr);
LOG_SYS_OPERATION("Check data quality failed. " + errorMessage)