yhkylin-backup-tools/kybackup/functypeconverter.cpp

89 lines
2.1 KiB
C++
Raw Normal View History

2022-11-01 10:40:05 +08:00
#include "functypeconverter.h"
FuncTypeConverter::FuncTypeConverter()
{
m_metaModule = QMetaEnum::fromType<FuncTypeConverter::FunType>();
}
FuncTypeConverter::~FuncTypeConverter()
{
}
QString FuncTypeConverter::keycodeTokeystring(int code){
//未匹配到则返回空
return m_metaModule.valueToKey(code);
}
int FuncTypeConverter::keystringTokeycode(QString string){
//QString to const char *
QByteArray ba = string.toUpper().toLocal8Bit(); const char * str = ba.data();
return m_metaModule.keyToValue(str);
}
/**
* @brief
* @param code
* @return
*/
QString FuncTypeConverter::keycodeTokeyi18nstring(int code)
{
QString nameString;
switch (code) {
case BACKUP_SYSTEM:
nameString = tr("System Backup");
break;
case RESTORE_SYSTEM:
nameString = tr("System Recovery");
break;
case BACKUP_DATA:
nameString = tr("Data Backup");
break;
case RESTORE_DATA:
nameString = tr("Data Recovery");
break;
case OPERATION_LOG:
nameString = tr("Log Records");
break;
case GHOST_IMAGE:
nameString = tr("Ghost Image");
break;
default:
break;
}
return nameString;
}
/**
* @brief
* @param code
* @return
*/
QString FuncTypeConverter::keycodeToThemeIconString(int code)
{
QString nameString;
switch (code) {
case BACKUP_SYSTEM:
nameString = "ukui-bf-system-backup-symbolic";
break;
case RESTORE_SYSTEM:
nameString = "ukui-bf-system-restore-symbolic";
break;
case BACKUP_DATA:
nameString = "ukui-bf-data-backup-symbolic";
break;
case RESTORE_DATA:
nameString = "ukui-bf-data-restore-symbolic";
break;
case OPERATION_LOG:
nameString = "ukui-catalogue-symbolic";
break;
case GHOST_IMAGE:
nameString = "ukui-bf-ghost-mirror-symbolic";
break;
default:
break;
}
return nameString;
}