refactor: Protocals text and update tanslate text.
This commit is contained in:
72
src/utilities/GetProtocalHelper.cpp
Normal file
72
src/utilities/GetProtocalHelper.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user