refactor: Protocals text and update tanslate text.

This commit is contained in:
sunwen
2024-05-24 15:17:20 +08:00
parent 6b2abfdb55
commit 1a722ee521
9 changed files with 633 additions and 282 deletions

View File

@@ -34,6 +34,7 @@
#include "windows/LoginDialog.h" #include "windows/LoginDialog.h"
#include "screensaver/ScreenSaverWindow.h" #include "screensaver/ScreenSaverWindow.h"
#include "utilities/GetLockScreenTimeHelper.h" #include "utilities/GetLockScreenTimeHelper.h"
#include "utilities/GetProtocalHelper.h"
#include "appvals/AppGlobalValues.h" #include "appvals/AppGlobalValues.h"
#include "json/jsonobject.h" #include "json/jsonobject.h"
@@ -243,8 +244,8 @@ DialogResult DialogManager::requestSelectProtocal()
SelectDialog dialog(mTopWidget); SelectDialog dialog(mTopWidget);
setTopWidget(&dialog); setTopWidget(&dialog);
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
dialog.setValues(JsonObject::Instance()->protocals()); dialog.setValues(GetProtocalHelper::getProtocalList());
dialog.setSelectedValue(JsonObject::Instance()->defaultProtocal()); dialog.setSelectedValue(GetProtocalHelper::getProtocalStr());
int ret = dialog.exec(); int ret = dialog.exec();
releaseTopWidget(&dialog); releaseTopWidget(&dialog);
return DialogResult(ret,dialog.getSelectedValue()); return DialogResult(ret,dialog.getSelectedValue());

View File

@@ -4,6 +4,8 @@
#include "forms/select/PatientInformation.h" #include "forms/select/PatientInformation.h"
#include "json/jsonobject.h" #include "json/jsonobject.h"
#include "utilities/GetProtocalHelper.h"
#include <QButtonGroup> #include <QButtonGroup>
StartScanProcessDialog::StartScanProcessDialog(QWidget *aParent) : StartScanProcessDialog::StartScanProcessDialog(QWidget *aParent) :
@@ -35,26 +37,28 @@ void StartScanProcessDialog::initButtons()
buttonGroup->addButton(mUI->mOnlyLeftButton, LONE); buttonGroup->addButton(mUI->mOnlyLeftButton, LONE);
buttonGroup->addButton(mUI->mOnlyRightButton, RONE); buttonGroup->addButton(mUI->mOnlyRightButton, RONE);
QString protocol = JsonObject::Instance()->defaultProtocal(); int protocol = GetProtocalHelper::getProtocal();
if(protocol == "LSTAND") switch (protocol)
{ {
case LSTAND:
mUI->mLeftToRightButton->setChecked(true); mUI->mLeftToRightButton->setChecked(true);
mScanProtocal = LSTAND; mScanProtocal = LSTAND;
} break;
else if(protocol == "RSTAND") case RSTAND:
{
mUI->mRightToLeftButton->setChecked(true); mUI->mRightToLeftButton->setChecked(true);
mScanProtocal = RSTAND; mScanProtocal = RSTAND;
} break;
else if(protocol == "LONE") case LONE:
{
mUI->mOnlyLeftButton->setChecked(true); mUI->mOnlyLeftButton->setChecked(true);
mScanProtocal = LONE; mScanProtocal = LONE;
} break;
else case RONE:
{
mUI->mOnlyRightButton->setChecked(true); mUI->mOnlyRightButton->setChecked(true);
mScanProtocal = RONE; mScanProtocal = RONE;
break;
default:
mUI->mLeftToRightButton->setChecked(true);
mScanProtocal = LSTAND;
} }
} }

View File

@@ -21,36 +21,7 @@
#include "log/UserOperationLog.h" #include "log/UserOperationLog.h"
#include "utilities/DiskInfoWorker.h" #include "utilities/DiskInfoWorker.h"
#include "utilities/GetLockScreenTimeHelper.h" #include "utilities/GetLockScreenTimeHelper.h"
#include "utilities/GetProtocalHelper.h"
namespace
{
const int MINIMUM_LOCKTIME = 30;
QString toTimeString(int aSeconds)
{
if(aSeconds == 0)
{
return "-";
}
if(aSeconds < 3600)
{
return QString("%1%2%3 %4%5%6 ").arg(QString::number((aSeconds % 3600) / 600))
.arg(QString::number((aSeconds % 600) / 60))
.arg(QObject::tr("Min"))
.arg(QString::number((aSeconds % 60) / 10))
.arg(QString::number(aSeconds % 10))
.arg(QObject::tr("Sec"));
}
return QString("%1%2%3 %4%5%6 ").arg(QString::number(aSeconds / 36000))
.arg(QString::number((aSeconds / 3600) % 10))
.arg(QObject::tr("Hour"))
.arg(QString::number((aSeconds % 3600) / 600))
.arg(QString::number((aSeconds % 600) / 60))
.arg(QObject::tr("Min"));
}
}
GeneralForm::GeneralForm(QWidget* aParent) GeneralForm::GeneralForm(QWidget* aParent)
: QWidget(aParent) : QWidget(aParent)
@@ -114,7 +85,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
scanProtocalHeaderLayout->addWidget(scanProtocolLabel); scanProtocalHeaderLayout->addWidget(scanProtocolLabel);
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* scanProtocolButton = new ListBox(scanProtocolHeader); ListBox* scanProtocolButton = new ListBox(scanProtocolHeader);
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str())); scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
scanProtocalHeaderLayout->addWidget(scanProtocolButton); scanProtocalHeaderLayout->addWidget(scanProtocolButton);
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed)); scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
@@ -201,8 +172,6 @@ GeneralForm::GeneralForm(QWidget* aParent)
}); });
connect(lockTime, &QToolButton::clicked, [=]() connect(lockTime, &QToolButton::clicked, [=]()
{ {
//take effect
//int second = JsonObject::Instance()->lockScreenTimeout().toInt();
DialogResult result = DialogManager::Default()->requestSelectLockScreenTime(); DialogResult result = DialogManager::Default()->requestSelectLockScreenTime();
if (result.ResultCode == false) if (result.ResultCode == false)
{ {
@@ -211,24 +180,6 @@ GeneralForm::GeneralForm(QWidget* aParent)
QString lockTimeStr = result.ResultData.toString(); QString lockTimeStr = result.ResultData.toString();
lockTime->setText(lockTimeStr); lockTime->setText(lockTimeStr);
GetLockScreenTimeHelper::setLockScreenTime(lockTimeStr); GetLockScreenTimeHelper::setLockScreenTime(lockTimeStr);
//second = result.ResultData.toInt();
//LOG_USER_OPERATION(QString("Set Screen Lock Time to %1 seconds").arg(second))
// if(second == 0)
// {
// JsonObject::Instance()->setLockScreenTimeout(QString::number(second));
// lockTime->setText(toTimeString(second));
// Locker::getInstance()->setTimer(-1);
// Locker::getInstance()->setIsEnable(false);
// return;
// }
// if (MINIMUM_LOCKTIME < second)
// {
// JsonObject::Instance()->setLockScreenTimeout(QString::number(second));
// Locker::getInstance()->setTimer(second * 1000);
// Locker::getInstance()->setIsEnable(true);
// lockTime->setText(toTimeString(second));
// }
}); });
@@ -259,7 +210,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
screenSaverLabel->setText(tr("Screen Saver")); screenSaverLabel->setText(tr("Screen Saver"));
diskLabel->setText(tr("Disk Storage")); diskLabel->setText(tr("Disk Storage"));
anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode()); anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode());
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str())); scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
updateStorageSize(); updateStorageSize();
updateStorageUsed(); updateStorageUsed();
}); });
@@ -280,8 +231,8 @@ GeneralForm::GeneralForm(QWidget* aParent)
{ {
QString pro = result.ResultData.toString(); QString pro = result.ResultData.toString();
//take effect //take effect
JsonObject::Instance()->setDefaultProtocal(pro); GetProtocalHelper::setProtocal(pro);
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str())); scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
} }
}); });

View File

@@ -34,7 +34,7 @@ void JsonObject::init()
mProtocalList = QString::fromLocal8Bit(QByteArray::fromRawData(protocals.c_str(), protocals.size())).split(";"); mProtocalList = QString::fromLocal8Bit(QByteArray::fromRawData(protocals.c_str(), protocals.size())).split(";");
} }
mDefaultProtocal = getJsonString("protocol", "default"); mDefaultProtocal = QString(getJsonString("protocol", "default")).toInt();
first = cJSON_GetObjectItem((cJSON*)json_root, "general"); first = cJSON_GetObjectItem((cJSON*)json_root, "general");
second = cJSON_GetObjectItem(first, "lockScreenTimes"); second = cJSON_GetObjectItem(first, "lockScreenTimes");
@@ -236,14 +236,14 @@ QStringList JsonObject::protocals()
return mProtocalList; return mProtocalList;
} }
QString JsonObject::defaultProtocal() int JsonObject::defaultProtocal()
{ {
return mDefaultProtocal; return mDefaultProtocal;
} }
void JsonObject::setDefaultProtocal(const QString& str) void JsonObject::setDefaultProtocal(int str)
{ {
setJsonString("protocol", "default", str.toStdString().c_str()); setJsonString("protocol", "default", QString::number(str).toStdString().c_str());
mDefaultProtocal = str; mDefaultProtocal = str;
} }

View File

@@ -66,8 +66,8 @@ public:
QStringList protocals(); QStringList protocals();
QString defaultProtocal(); int defaultProtocal();
void setDefaultProtocal(const QString& str); void setDefaultProtocal(int str);
QStringList lockScreenTimes(); QStringList lockScreenTimes();
@@ -155,7 +155,6 @@ private:
QString mDefaultLanguage; QString mDefaultLanguage;
QString mInstitutionName; QString mInstitutionName;
QString mInstitutionAddr; QString mInstitutionAddr;
QString mDefaultProtocal;
QString mInterfaceName; QString mInterfaceName;
QString mGateway; QString mGateway;
@@ -166,6 +165,7 @@ private:
QStringList mScreenSaverInfoList; QStringList mScreenSaverInfoList;
int mLockScreenTime; int mLockScreenTime;
int mDefaultProtocal;
int mOperationLogExpireDays; int mOperationLogExpireDays;
int mPatientListExpireDays; int mPatientListExpireDays;

View File

@@ -90,10 +90,6 @@
<source>Logout</source> <source>Logout</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Reset password to &quot;123456&quot; ?</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Inner error, can&apos;t find reference user!</source> <source>Inner error, can&apos;t find reference user!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -150,6 +146,22 @@
<source>Input User name</source> <source>Input User name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Do you want to logout the current user?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password and confirm password do not match!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset to default password?</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>AccountTableForm</name> <name>AccountTableForm</name>
@@ -256,11 +268,6 @@
</context> </context>
<context> <context>
<name>DeviceManager</name> <name>DeviceManager</name>
<message>
<source>Patient can leave.
</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Data is currently being transmitted, please shut down later.</source> <source>Data is currently being transmitted, please shut down later.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -281,6 +288,36 @@
<source>Initialize Failed.</source> <source>Initialize Failed.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Start auto locate failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DMS connection error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dms connection error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The data quality is low, please restart the data scan.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>progress:%1%</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Patient can leave.
progress:%1%</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data quality assessment in progress
progress:99%</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>DicomCfgDialog</name> <name>DicomCfgDialog</name>
@@ -339,10 +376,6 @@
<source>Form</source> <source>Form</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>AE</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Server Ip</source> <source>Server Ip</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -355,6 +388,10 @@
<source>Server Port</source> <source>Server Port</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Local AE</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>EditPatientDialog</name> <name>EditPatientDialog</name>
@@ -609,6 +646,18 @@
<source>Subnet Mask</source> <source>Subnet Mask</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Ip Address is not valid</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Subnet Mask is not valid</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gateway is not valid</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Keyboard</name> <name>Keyboard</name>
@@ -850,6 +899,18 @@
<source>Shut down failed, please push emergency button to shutdown.</source> <source>Shut down failed, please push emergency button to shutdown.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Please execute the empty scan, assist with system calibration, when empty scan is completed, the system should operate normally.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>There are %1 days left until the next empty scan. Please remind users to conduct the empty scan in time.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MppsSettingsDialog</name> <name>MppsSettingsDialog</name>
@@ -1109,19 +1170,47 @@
<source>Patient ID:</source> <source>Patient ID:</source>
<translation type="unfinished">ID:</translation> <translation type="unfinished">ID:</translation>
</message> </message>
<message>
<source>RSTAND</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LSTAND</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LONE</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RONE</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<source>Min</source> <source>Never</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Sec</source> <source> Minutes</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Hour</source> <source>LeftToRight</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RightToLeft</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@@ -1288,6 +1377,26 @@
<source>Shut Down</source> <source>Shut Down</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Stop Scan Process</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left side scan initiated, auto positioning in progress.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right side scan initiated, auto positioning in progress.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data scanning, please keep the current position and don&apos;t move.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data exporting, patient can leave the holder</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>ScanSearchCriteriaForm</name> <name>ScanSearchCriteriaForm</name>
@@ -1637,6 +1746,22 @@
<source>Log Date:</source> <source>Log Date:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Operation Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operation Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operation</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>WarningMessageWidget</name> <name>WarningMessageWidget</name>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
#include "GetProtocalHelper.h"
#include "json/jsonobject.h"
#include <QObject>
QStringList GetProtocalHelper::getProtocalList()
{
QStringList protocalList = JsonObject::Instance()->protocals();
QStringList result;
foreach(QString protocal, protocalList)
{
result << switchProtocalIntToProtocalString(protocal.toInt());
}
return result;
}
int GetProtocalHelper::getProtocal()
{
return JsonObject::Instance()->defaultProtocal();
}
QString GetProtocalHelper::getProtocalStr()
{
return switchProtocalIntToProtocalString(getProtocal());
}
void GetProtocalHelper::setProtocal(const QString& aProtocal)
{
JsonObject::Instance()->setDefaultProtocal(switchProtocalStringToProtocalInt(aProtocal));
}
QString GetProtocalHelper::switchProtocalIntToProtocalString(int aProtocal)
{
switch(aProtocal)
{
case 0 :
return QObject::tr("LeftToRight");
case 1 :
return QObject::tr("RightToLeft");
case 2 :
return QObject::tr("Left");
case 3 :
return QObject::tr("Right");
default:
return QObject::tr("LeftToRight");
}
}
int GetProtocalHelper::switchProtocalStringToProtocalInt(const QString& aPortocal)
{
if(aPortocal == QObject::tr("LeftToRight"))
{
return 0;
}
else if(aPortocal == QObject::tr("RightToLeft"))
{
return 1;
}
else if(aPortocal == QObject::tr("Left"))
{
return 2;
}
else if(aPortocal == QObject::tr("LeftToRight"))
{
return 3;
}
else
{
return 0;
}
}

View File

@@ -0,0 +1,22 @@
#ifndef GETPROTOCALHELPER_H
#define GETPROTOCALHELPER_H
#include <QStringList>
class GetProtocalHelper
{
public:
GetProtocalHelper() = delete ;
static QStringList getProtocalList();
static QString getProtocalStr();
static int getProtocal();
static void setProtocal(const QString& aPortocal);
private:
static QString switchProtocalIntToProtocalString(int aPortocal);
static int switchProtocalStringToProtocalInt(const QString& aPortocal);
};
#endif // GETPROTOCALHELPER_H