🌈 style(翻译): 修改翻译相关处理

解决全局字符串翻译不起作用以及tip错误
This commit is contained in:
huheng@kylinos.cn 2022-11-30 09:36:57 +08:00
parent bfd36b482c
commit c15c3d0edf
4 changed files with 77 additions and 46 deletions

View File

@ -263,6 +263,28 @@ QStringList FileManageWin::getPathList()
return pathList;
}
QString FileManageWin::crumbText(CrumbTag type)
{
switch (type) {
case CrumbTag::FileList:
return m_fileListTag;
case CrumbTag::Picture:
return m_pictureTag;
case CrumbTag::Video:
return m_videoTag;
case CrumbTag::Music:
return m_musicTag;
case CrumbTag::Doc:
return m_docTag;
case CrumbTag::QQ:
return m_qqTag;
case CrumbTag::WeChat:
return m_wechatTag;
case CrumbTag::Storage:
return m_storageTag;
}
}
bool FileManageWin::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_searchLine) {
@ -325,7 +347,7 @@ void FileManageWin::changeTabMode(FileManageWin::TabType type)
m_refreshBtn->show();
} break;
case FileManageWin::TabType::AndroidHomePage: {
m_statusLab->setText(CrumbTag::FileList);
m_statusLab->setText(crumbText(CrumbTag::FileList));
m_lab1->show();
m_statusLab->show();
if (m_searchLine->isHidden()) {

View File

@ -13,18 +13,6 @@
#include "loadanimation.h"
#include "clicklabel.h"
namespace CrumbTag
{
const QString FileList = QObject::tr("List of Mobile Files");
const QString Picture = QObject::tr("Picture");
const QString Video = QObject::tr("Video");
const QString Music = QObject::tr("Music");
const QString Doc = QObject::tr("Doc");
const QString QQ = QObject::tr("QQ");
const QString WeChat = QObject::tr("WeChat");
const QString Storage = QObject::tr("Mobile Storage");
} // namespace CrumbTag
class FileManageWin : public QWidget
{
Q_OBJECT
@ -54,6 +42,17 @@ public:
EditFinishBtn, // 编辑完成按钮
};
enum CrumbTag {
FileList = 0, // 手机文件列表
Picture, // 图片
Video, // 视频
Music, // 音乐
Doc, // 文档
WeChat, // 微信
QQ, // QQ
Storage, // 手机存储
};
void setEditType(bool isSelectAll);
void setWidget(QWidget *win, FileManageWin::TabType type);
void pushCrumb(QString str);
@ -62,6 +61,7 @@ public:
void setGoBackEnabled(bool isEnabled);
void setGoForwardEnabled(bool isEnabled);
QStringList getPathList();
QString crumbText(CrumbTag type);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
@ -84,6 +84,15 @@ public Q_SLOTS:
void slotSearchTextChanged();
private:
QString m_fileListTag = tr("List of Mobile Files");
QString m_pictureTag = tr("Picture");
QString m_videoTag = tr("Video");
QString m_musicTag = tr("Music");
QString m_docTag = tr("Doc");
QString m_qqTag = tr("QQ");
QString m_wechatTag = tr("WeChat");
QString m_storageTag = tr("Mobile Storage");
enum PageIndex {
LoadPage = 0, // 加载页面
InfoPage, // 文件信息页面

View File

@ -11,7 +11,7 @@ TimeLineItem::TimeLineItem(QWidget *parent) : QWidget(parent)
m_dropDownBtn = new kdk::KToolButton(this);
connect(m_dropDownBtn, &kdk::KToolButton::clicked, this, &TimeLineItem::slotDropDownBtnClicked);
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-down-symbolic"));
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-up-symbolic"));
m_dropDownBtn->setIconSize(QSize(16, 16));
m_dropDownBtn->setToolTip(tr("pack up"));
m_dropDownBtn->setType(kdk::KToolButtonType::Flat);
@ -96,14 +96,14 @@ void TimeLineItem::getSelectInfoList(QList<FileInfo> &list)
void TimeLineItem::slotDropDownBtnClicked()
{
if (m_fileView->isHidden()) {
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-down-symbolic"));
m_dropDownBtn->setToolTip(tr("lay down"));
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-up-symbolic"));
m_dropDownBtn->setToolTip(tr("pack up"));
m_fileView->show();
setFixedHeight(m_fileView->height());
Q_EMIT sigSizeChanged(size());
} else {
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-up-symbolic"));
m_dropDownBtn->setToolTip(tr("pack up"));
m_dropDownBtn->setIcon(QIcon::fromTheme("ukui-down-symbolic"));
m_dropDownBtn->setToolTip(tr("lay down"));
m_fileView->hide();
setFixedHeight(HEIGHT);
Q_EMIT sigSizeChanged(size());

View File

@ -426,7 +426,7 @@ void MainWindow::connectUI()
} else if (m_connectInfo.deviceType == ConnectionService::DeviceType::ANDROID) {
m_connectedWin->setDeviceType(PublicAttributes::DeviceType::Android);
m_fileManageWin->pushCrumb(CrumbTag::FileList);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList));
m_isFileViewPage = false;
}
m_mainStackedWin->addWidget(m_connectedWin);
@ -751,8 +751,8 @@ void MainWindow::checkAndroidHomePage()
void MainWindow::checkFileView(QStringList &pathList)
{
pathList.removeAll(CrumbTag::Storage);
pathList.removeAll(CrumbTag::FileList);
pathList.removeAll(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Storage));
pathList.removeAll(m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList));
pathList.removeAll(m_connectInfo.deviceName);
QString path = "/";
path.append(pathList.join("/"));
@ -762,17 +762,17 @@ void MainWindow::checkFileView(QStringList &pathList)
void MainWindow::crumbTagToAndroidItemType(QString tag)
{
AndroidItem::Type type;
if (tag == CrumbTag::Picture) {
if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::Picture)) {
type = AndroidItem::Type::Picture;
} else if (tag == CrumbTag::Video) {
} else if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::Video)) {
type = AndroidItem::Type::Video;
} else if (tag == CrumbTag::Music) {
} else if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::Music)) {
type = AndroidItem::Type::Music;
} else if (tag == CrumbTag::Doc) {
} else if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::Doc)) {
type = AndroidItem::Type::Doc;
} else if (tag == CrumbTag::QQ) {
} else if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::QQ)) {
type = AndroidItem::Type::QQ;
} else if (tag == CrumbTag::WeChat) {
} else if (tag == m_fileManageWin->crumbText(FileManageWin::CrumbTag::WeChat)) {
type = AndroidItem::Type::WeChat;
}
slotAndroidBtnClicked(type);
@ -781,7 +781,7 @@ void MainWindow::crumbTagToAndroidItemType(QString tag)
void MainWindow::checkPage(QStringList crumbPathList)
{
m_fileManageWin->clearCrumb();
m_fileManageWin->pushCrumb(CrumbTag::FileList);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList));
if (crumbPathList.size() == 1) {
checkAndroidHomePage();
} else {
@ -796,12 +796,12 @@ void MainWindow::checkPage(QStringList crumbPathList)
crumbTagToAndroidItemType(crumbPathList.value(1));
} break;
case 3: {
if (crumbPathList.value(1) == CrumbTag::QQ) {
if (crumbPathList.value(1) == m_fileManageWin->crumbText(FileManageWin::CrumbTag::QQ)) {
m_fileKey = FileSyncManage::FileKey::QQ;
m_fileManageWin->pushCrumb(CrumbTag::QQ);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::QQ));
} else {
m_fileKey = FileSyncManage::FileKey::WeChat;
m_fileManageWin->pushCrumb(CrumbTag::WeChat);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::WeChat));
}
crumbTagToAndroidItemType(crumbPathList.value(2));
} break;
@ -1102,8 +1102,8 @@ void MainWindow::slotTransferProgress(qint64 readBytes, qint64 totalBytes)
if (!m_uploadPath.isEmpty()) {
m_fileManageWin->clearCrumb();
if (m_connectInfo.deviceType == ConnectionService::DeviceType::ANDROID) {
m_fileManageWin->pushCrumb(CrumbTag::FileList);
m_fileManageWin->pushCrumb(CrumbTag::Storage);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList));
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Storage));
} else {
m_fileManageWin->pushCrumb(m_connectInfo.deviceName);
}
@ -1400,17 +1400,17 @@ void MainWindow::slotUSBConnectOnClicked()
void MainWindow::slotCrumbIndexChange(QString text, QStringList &list)
{
addBackList(list);
if (text == CrumbTag::FileList) {
if (text == m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList)) {
checkAndroidHomePage();
} else if (text == CrumbTag::QQ) {
} else if (text == m_fileManageWin->crumbText(FileManageWin::CrumbTag::QQ)) {
m_downFileType = FileSyncManage::FileType::FileNum;
m_fileKey = FileSyncManage::FileKey::QQ;
m_fileSyncManage->updateFileInfo(m_fileKey, m_downFileType);
} else if (text == CrumbTag::WeChat) {
} else if (text == m_fileManageWin->crumbText(FileManageWin::CrumbTag::WeChat)) {
m_downFileType = FileSyncManage::FileType::FileNum;
m_fileKey = FileSyncManage::FileKey::WeChat;
m_fileSyncManage->updateFileInfo(m_fileKey, m_downFileType);
} else if (text == CrumbTag::Storage) {
} else if (text == m_fileManageWin->crumbText(FileManageWin::CrumbTag::Storage)) {
slotCdDirectory("/");
} else {
QStringList pathList = m_fileManageWin->getPathList();
@ -1532,8 +1532,8 @@ void MainWindow::slotUploadFile(QString dirName, const QStringList &localPathLis
// 上传文件埋点
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantUploadFile);
QStringList pathList = m_fileManageWin->getPathList();
pathList.removeAll(CrumbTag::Storage);
pathList.removeAll(CrumbTag::FileList);
pathList.removeAll(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Storage));
pathList.removeAll(m_fileManageWin->crumbText(FileManageWin::CrumbTag::FileList));
pathList.removeAll(m_connectInfo.deviceName);
m_uploadPath = "/";
m_uploadPath.append(pathList.join("/"));
@ -1609,38 +1609,38 @@ void MainWindow::slotAndroidBtnClicked(AndroidItem::Type type)
switch (type) {
case AndroidItem::Type::Picture: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantPictureList);
m_fileManageWin->pushCrumb(CrumbTag::Picture);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Picture));
m_downFileType = FileSyncManage::FileType::Picture;
} break;
case AndroidItem::Type::Video: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantVideoList);
m_fileManageWin->pushCrumb(CrumbTag::Video);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Video));
m_downFileType = FileSyncManage::FileType::Video;
} break;
case AndroidItem::Type::Music: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantAudioList);
m_fileManageWin->pushCrumb(CrumbTag::Music);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Music));
m_downFileType = FileSyncManage::FileType::Music;
} break;
case AndroidItem::Type::Doc: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantDocList);
m_fileManageWin->pushCrumb(CrumbTag::Doc);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Doc));
m_downFileType = FileSyncManage::FileType::Doc;
} break;
case AndroidItem::Type::QQ: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantQQFileList);
m_fileManageWin->pushCrumb(CrumbTag::QQ);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::QQ));
m_fileKey = FileSyncManage::FileKey::QQ;
m_downFileType = FileSyncManage::FileType::FileNum;
} break;
case AndroidItem::Type::WeChat: {
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantWechatFileList);
m_fileManageWin->pushCrumb(CrumbTag::WeChat);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::WeChat));
m_fileKey = FileSyncManage::FileKey::WeChat;
m_downFileType = FileSyncManage::FileType::FileNum;
} break;
case AndroidItem::Type::File: {
m_fileManageWin->pushCrumb(CrumbTag::Storage);
m_fileManageWin->pushCrumb(m_fileManageWin->crumbText(FileManageWin::CrumbTag::Storage));
m_isFileViewPage = true;
slotCdDirectory("/");
}