yhkylin-backup-tools/kybackup/functypeconverter.cpp

89 lines
2.1 KiB
C++
Raw Normal View History

2021-09-16 16:05:46 +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:
2022-02-11 13:48:46 +08:00
nameString = "ukui-bf-system-backup-symbolic";
2021-09-16 16:05:46 +08:00
break;
case RESTORE_SYSTEM:
2022-02-11 13:48:46 +08:00
nameString = "ukui-bf-system-restore-symbolic";
2021-09-16 16:05:46 +08:00
break;
case BACKUP_DATA:
2022-02-11 13:48:46 +08:00
nameString = "ukui-bf-data-backup-symbolic";
2021-09-16 16:05:46 +08:00
break;
case RESTORE_DATA:
2022-02-11 13:48:46 +08:00
nameString = "ukui-bf-data-restore-symbolic";
2021-09-16 16:05:46 +08:00
break;
case OPERATION_LOG:
nameString = "ukui-catalogue-symbolic";
2021-09-16 16:05:46 +08:00
break;
case GHOST_IMAGE:
2022-02-11 13:48:46 +08:00
nameString = "ukui-bf-ghost-mirror-symbolic";
2021-09-16 16:05:46 +08:00
break;
default:
break;
}
return nameString;
}