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

@@ -21,36 +21,7 @@
#include "log/UserOperationLog.h"
#include "utilities/DiskInfoWorker.h"
#include "utilities/GetLockScreenTimeHelper.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"));
}
}
#include "utilities/GetProtocalHelper.h"
GeneralForm::GeneralForm(QWidget* aParent)
: QWidget(aParent)
@@ -114,7 +85,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
scanProtocalHeaderLayout->addWidget(scanProtocolLabel);
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* scanProtocolButton = new ListBox(scanProtocolHeader);
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str()));
scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
scanProtocalHeaderLayout->addWidget(scanProtocolButton);
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
@@ -201,8 +172,6 @@ GeneralForm::GeneralForm(QWidget* aParent)
});
connect(lockTime, &QToolButton::clicked, [=]()
{
//take effect
//int second = JsonObject::Instance()->lockScreenTimeout().toInt();
DialogResult result = DialogManager::Default()->requestSelectLockScreenTime();
if (result.ResultCode == false)
{
@@ -211,24 +180,6 @@ GeneralForm::GeneralForm(QWidget* aParent)
QString lockTimeStr = result.ResultData.toString();
lockTime->setText(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"));
diskLabel->setText(tr("Disk Storage"));
anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode());
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str()));
scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
updateStorageSize();
updateStorageUsed();
});
@@ -280,8 +231,8 @@ GeneralForm::GeneralForm(QWidget* aParent)
{
QString pro = result.ResultData.toString();
//take effect
JsonObject::Instance()->setDefaultProtocal(pro);
scanProtocolButton->setText(tr(JsonObject::Instance()->defaultProtocal().toStdString().c_str()));
GetProtocalHelper::setProtocal(pro);
scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
}
});