🐞 fix(UI模块): 添加文件类型,修改文件图标显示

176100 【多端协同】A设备中新建wps文件,B设备在多端协同应用中查看此文件图标为问号图标且点击无法打开;177415 【单元测试】【多端协同】麒麟间建立连接后,无法直接在对端文件夹打开大文件和wps默认格式的文件
This commit is contained in:
huheng@kylinos.cn 2023-06-16 15:00:26 +08:00
parent e86da602a5
commit 25ec014da7
1 changed files with 41 additions and 37 deletions

View File

@ -115,9 +115,11 @@ QMap<QString, QString> FileInfo::initMimeMap()
map.insert("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
map.insert("doc", "application/msword");
map.insert("xls", "application/vnd.ms-excel");
map.insert("et", "application/vnd.ms-excel");
map.insert("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
map.insert("pps", "application/vnd.ms-powerpoint");
map.insert("ppt", "application/vnd.ms-powerpoint");
map.insert("dps", "application/vnd.ms-powerpoint");
map.insert("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
map.insert("wps", "application/vnd.ms-works");
map.insert("bin", "application/octet-stream");
@ -145,7 +147,7 @@ QMap<QString, QString> FileInfo::initMimeMap()
map.insert("tar", "application/x-tar");
map.insert("tgz", "application/x-compressed");
map.insert("rc", "text/plain");
map.insert("xml", "text/xml"); // text/plain
map.insert("xml", "text/xml"); // text/plain
map.insert("z", "application/x-compress");
map.insert("zip", "application/x-zip-compressed");
map.insert("pdf", "application/pdf");
@ -170,6 +172,7 @@ QMap<QString, QString> FileInfo::initIconNameMap()
map.insert("application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application-vnd.openxmlformats-officedocument.wordprocessingml.document");
map.insert("application/msword", "application-msword");
map.insert("application/vnd.ms-works", "application-msword");
map.insert("application/vnd.ms-excel", "application-vnd.ms-excel");
map.insert("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application-vnd.openxmlformats-officedocument.spreadsheetml.sheet");
@ -356,6 +359,7 @@ void FileInfo::setDate(const QString &date)
}
QString FileInfo::getContentType() const
{
qDebug() << m_name << m_type << m_contentType;
return m_contentType;
}
@ -376,16 +380,16 @@ FileInfo::FileType FileInfo::judgmentType(QString fileName)
} else if (mime.name().startsWith("video/")) {
// 视频 video/mp4, video/x-flv, video/webm, video/ogg
return FileType::Video;
} else if (fileType == "doc" || fileType == "docx") {
} else if (fileType == "doc" || fileType == "docx" || fileType == "wps") {
// word doc docx
return FileType::Doc;
} else if (fileType == "pdf") {
// pdf
return FileType::Pdf;
} else if (fileType == "xlsx" || fileType == "xls") {
} else if (fileType == "xlsx" || fileType == "xls" || fileType == "et") {
// excel
return FileType::Excel;
} else if (fileType == "pptx") {
} else if (fileType == "pptx" || fileType == "dps") {
// ppt
return FileType::Ppt;
} else if (fileType == "zip") {
@ -404,39 +408,39 @@ void FileInfo::fileOpen(QString fileName)
FileInfo::FileType fileType = judgmentType(fileName);
QString command = "";
switch (fileType) {
case FileInfo::FileType::Image:
command = QString("kylin-photo-viewer");
break;
case FileInfo::FileType::Video:
command = QString("kylin-video");
break;
case FileInfo::FileType::Txt:
command = QString("pluma");
break;
case FileInfo::FileType::Audio:
command = QString("kylin-music");
break;
case FileInfo::FileType::Doc:
command = QString("wps");
break;
case FileInfo::FileType::Excel:
command = QString("et");
break;
case FileInfo::FileType::Pdf:
command = QString("wpspdf");
break;
case FileInfo::FileType::Ppt:
command = QString("wpp");
break;
case FileInfo::FileType::Zip:
command = QString("engrampa");
break;
case FileInfo::FileType::Other:
command = QString("pluma");
break;
default:
command = QString("pluma");
break;
case FileInfo::FileType::Image:
command = QString("kylin-photo-viewer");
break;
case FileInfo::FileType::Video:
command = QString("kylin-video");
break;
case FileInfo::FileType::Txt:
command = QString("pluma");
break;
case FileInfo::FileType::Audio:
command = QString("kylin-music");
break;
case FileInfo::FileType::Doc:
command = QString("wps");
break;
case FileInfo::FileType::Excel:
command = QString("et");
break;
case FileInfo::FileType::Pdf:
command = QString("wpspdf");
break;
case FileInfo::FileType::Ppt:
command = QString("wpp");
break;
case FileInfo::FileType::Zip:
command = QString("engrampa");
break;
case FileInfo::FileType::Other:
command = QString("pluma");
break;
default:
command = QString("pluma");
break;
}
QProcess::startDetached(command, QStringList() << filePath);
}