From d01cbe31bb1f841230456069c1aa1c6f3885ff58 Mon Sep 17 00:00:00 2001 From: zhangpengfei Date: Thu, 7 Jan 2021 15:21:53 +0800 Subject: [PATCH] [FIX] Translation files(*.qm) can not be generated issue. Add desktop file,and some minor repairs. --- data/ukui-search.desktop | 10 + libsearch/index/index-generator.cpp | 21 +- libsearch/index/index-generator.h | 1 + src/control/highlight-item-delegate.cpp | 2 +- src/main.cpp | 2 +- src/res/translations/zh_CN.ts | 216 ----------------- src/src.pro | 19 +- .../ukui-search}/bo.ts | 73 +++--- .../ukui-search}/tr.ts | 73 +++--- translations/ukui-search/zh_CN.ts | 221 ++++++++++++++++++ 10 files changed, 332 insertions(+), 306 deletions(-) create mode 100644 data/ukui-search.desktop delete mode 100644 src/res/translations/zh_CN.ts rename {src/res/translations => translations/ukui-search}/bo.ts (76%) rename {src/res/translations => translations/ukui-search}/tr.ts (76%) create mode 100644 translations/ukui-search/zh_CN.ts diff --git a/data/ukui-search.desktop b/data/ukui-search.desktop new file mode 100644 index 0000000..14aa071 --- /dev/null +++ b/data/ukui-search.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=ukui-search +GenericName=UKUI Global Search +GenericName[zh_CN]=全局搜索 +Comment=ukui-search +Comment[zh_CN]=全局搜索 +Exec=usr/bin/ukui-search %U +Type=Application +Icon=ukui-search +Terminal=false diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index 78e8ea0..26d7c4a 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -58,7 +58,7 @@ bool IndexGenerator::creatAllIndex(QList > *messageList) } catch(const Xapian::Error &e) { - qWarning()<<__FILE__<<__LINE__<<__FUNCTION__<<"creatAllIndex fail!"<setValue(INDEX_DATABASE_STATE,"1"); Q_ASSERT(false); @@ -89,7 +89,7 @@ bool IndexGenerator::creatAllIndex(QList *messageList) } catch(const Xapian::Error &e) { - qWarning()<<__FILE__<<__LINE__<<__FUNCTION__<<"creat content Index fail!"<setValue(CONTENT_INDEX_DATABASE_STATE,"1"); Q_ASSERT(false); } @@ -193,18 +193,17 @@ Document IndexGenerator::GenerateDocument(const QVector &list) QString sourcePath = list.at(1); index_text = index_text.replace(".","").replace(""," "); index_text = index_text.simplified(); - //这个应该是写错了 -// QString pinyin_text = FileUtils::find(index_text.replace(".", "")).replace("", " "); //不带多音字版 // QString pinyin_text = FileUtils::find(QString(list.at(0)).replace(".","")).replace("", " ").simplified(); //多音字版 //现加入首字母 -// QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".","")); -// for (QString& i : pinyin_text_list){ -// i.replace("", " "); -// } + QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".","")); + for (QString& i : pinyin_text_list){ + i.replace("", " "); + i = i.simplified(); + } QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath)); // QString uniqueterm1 = QString::fromStdString(QCryptographicHash::hash(sourcePath.toUtf8(),QCryptographicHash::Md5).toStdString()); @@ -223,10 +222,8 @@ Document IndexGenerator::GenerateDocument(const QVector &list) doc.addValue(list.at(2)); QStringList temp; temp.append(index_text); -// temp.append(pinyin_text_list); + temp.append(pinyin_text_list); doc.setIndexText(temp); -// doc.setIndexText(QStringList()<subElementRect(QStyle::SE_ItemViewItemText, &optionV4); - textRect.adjust(0, 5, 0, 0); + textRect.adjust(0, 0, 0, 0); painter->save(); painter->translate(textRect.topLeft()); painter->setClipRect(textRect.translated(-textRect.topLeft())); diff --git a/src/main.cpp b/src/main.cpp index 202d251..8184b5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) // 加载国际化文件 QTranslator translator; try { - if (! translator.load("/usr/share/ukui-search/res/translations/" + QLocale::system().name())) throw -1; + if (! translator.load("/usr/share/ukui-search/translations/" + QLocale::system().name())) throw -1; app.installTranslator(&translator); } catch (...) { qDebug() << "Load translations file" << QLocale() << "failed!"; diff --git a/src/res/translations/zh_CN.ts b/src/res/translations/zh_CN.ts deleted file mode 100644 index 20ad8ee..0000000 --- a/src/res/translations/zh_CN.ts +++ /dev/null @@ -1,216 +0,0 @@ - - - - - ContentWidget - - - Recently Opened - 最近 - - - - Open Quickly - 快速 - - - - Commonly Used - 常用 - - - - Apps - 应用 - - - - Settings - 配置项 - - - - Files - 文件 - - - - Dirs - 文件夹 - - - - Best Matches - 最佳匹配 - - - - Unknown - 未知 - - - - FolderListItem - - - Delete the folder out of blacklist - 删除 - - - - MainWindow - - - Search - 从列表搜索 - - - - OptionView - - - Open - 打开 - - - - Add Shortcut to Desktop - 添加到桌面快捷方式 - - - - Add Shortcut to Panel - 添加到任务栏快捷方式 - - - - Open path - 打开文件所在路径 - - - - Copy path - 复制文件路径 - - - - QObject - - - ukui-search is already running! - - - - - SearchDetailView - - - Path - 路径 - - - - Last time modified - 上次修改时间 - - - - Application - 应用 - - - - Document - 文件 - - - - SettingsWidget - - - Search - 搜索 - - - - Settings - 配置项 - - - - Index State - 索引状态 - - - - - ... - - - - - File Index Settings - 文件索引设置 - - - - Following folders will not be searched. You can set it by adding and removing folders. - 搜索将不再查看以下文件夹。通过增加和删除文件夹可进行文件索引设置。 - - - - Add ignored folders - 添加禁止索引文件夹 - - - - Search Engine Settings - 搜索引擎设置 - - - - Please select search engine you preferred. - 设置互联网搜索引擎 - - - - baidu - 百度 - - - - sougou - 搜狗 - - - - 360 - 360 - - - - Cancel - 取消 - - - - Confirm - 确认 - - - - Creating ... - 正在索引 - - - - Done - 索引完成 - - - - Index Entry: %1 - 索引项: %1 - - - diff --git a/src/src.pro b/src/src.pro index 6b0671f..af9a791 100644 --- a/src/src.pro +++ b/src/src.pro @@ -7,7 +7,7 @@ TARGET = ukui-search TEMPLATE = app PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 -CONFIG += c++11 link_pkgconfig no_keywords +CONFIG += c++11 link_pkgconfig no_keywords lrelease LIBS += -lxapian -lgsettings-qt -lquazip5 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings @@ -43,19 +43,22 @@ HEADERS += \ target.path = /usr/bin !isEmpty(target.path): INSTALLS += target +data.path = /usr/share/applications +data.files += ../data/ukui-search.desktop +INSTALLS += data + RESOURCES += \ resource.qrc TRANSLATIONS += \ - res/translations/zh_CN.ts \ - res/translations/tr.ts \ - res/translations/bo.ts + ../translations/ukui-search/zh_CN.ts \ + ../translations/ukui-search/tr.ts \ + ../translations/ukui-search/bo.ts -qm_files.path = /usr/share/ukui-search/res/translations/ -qm_files.files = $$OUT_PWD/res/translations/*.qm +qm_files.path = /usr/share/ukui-search/translations/ +qm_files.files = $$OUT_PWD/.qm/*.qm -INSTALLS += \ - qm_files \ +INSTALLS += qm_files LIBS += -L$$OUT_PWD/../libsearch -lukui-search -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation diff --git a/src/res/translations/bo.ts b/translations/ukui-search/bo.ts similarity index 76% rename from src/res/translations/bo.ts rename to translations/ukui-search/bo.ts index ab9cae4..ef0ecd5 100644 --- a/src/res/translations/bo.ts +++ b/translations/ukui-search/bo.ts @@ -19,32 +19,37 @@ - + Apps - + Settings - + Files - + Dirs - + + File Contents + + + + Best Matches - + Unknown @@ -60,7 +65,7 @@ MainWindow - + Search @@ -68,27 +73,27 @@ OptionView - + Open - + Add Shortcut to Desktop - + Add Shortcut to Panel - + Open path - + Copy path @@ -96,7 +101,7 @@ QObject - + ukui-search is already running! @@ -104,22 +109,22 @@ SearchDetailView - + Path - + Last time modified - + Application - + Document @@ -132,83 +137,83 @@ - + Settings - + Index State - - + + ... - + File Index Settings - + Following folders will not be searched. You can set it by adding and removing folders. - + Add ignored folders - + Search Engine Settings - + Please select search engine you preferred. - + baidu - + sougou - + 360 - + Cancel - + Confirm - + Creating ... - + Done - + Index Entry: %1 diff --git a/src/res/translations/tr.ts b/translations/ukui-search/tr.ts similarity index 76% rename from src/res/translations/tr.ts rename to translations/ukui-search/tr.ts index ab9cae4..ef0ecd5 100644 --- a/src/res/translations/tr.ts +++ b/translations/ukui-search/tr.ts @@ -19,32 +19,37 @@ - + Apps - + Settings - + Files - + Dirs - + + File Contents + + + + Best Matches - + Unknown @@ -60,7 +65,7 @@ MainWindow - + Search @@ -68,27 +73,27 @@ OptionView - + Open - + Add Shortcut to Desktop - + Add Shortcut to Panel - + Open path - + Copy path @@ -96,7 +101,7 @@ QObject - + ukui-search is already running! @@ -104,22 +109,22 @@ SearchDetailView - + Path - + Last time modified - + Application - + Document @@ -132,83 +137,83 @@ - + Settings - + Index State - - + + ... - + File Index Settings - + Following folders will not be searched. You can set it by adding and removing folders. - + Add ignored folders - + Search Engine Settings - + Please select search engine you preferred. - + baidu - + sougou - + 360 - + Cancel - + Confirm - + Creating ... - + Done - + Index Entry: %1 diff --git a/translations/ukui-search/zh_CN.ts b/translations/ukui-search/zh_CN.ts new file mode 100644 index 0000000..fd0be29 --- /dev/null +++ b/translations/ukui-search/zh_CN.ts @@ -0,0 +1,221 @@ + + + + + ContentWidget + + + Recently Opened + 最近 + + + + Open Quickly + 快速 + + + + Commonly Used + 常用 + + + + Apps + 应用 + + + + Settings + 配置项 + + + + Files + 文件 + + + + Dirs + 文件夹 + + + + File Contents + + + + + Best Matches + 最佳匹配 + + + + Unknown + 未知 + + + + FolderListItem + + + Delete the folder out of blacklist + 删除 + + + + MainWindow + + + Search + 从列表搜索 + + + + OptionView + + + Open + 打开 + + + + Add Shortcut to Desktop + 添加到桌面快捷方式 + + + + Add Shortcut to Panel + 添加到任务栏快捷方式 + + + + Open path + 打开文件所在路径 + + + + Copy path + 复制文件路径 + + + + QObject + + + ukui-search is already running! + + + + + SearchDetailView + + + Path + 路径 + + + + Last time modified + 上次修改时间 + + + + Application + 应用 + + + + Document + 文件 + + + + SettingsWidget + + + Search + 搜索 + + + + Settings + 配置项 + + + + Index State + 索引状态 + + + + + ... + + + + + File Index Settings + 文件索引设置 + + + + Following folders will not be searched. You can set it by adding and removing folders. + 搜索将不再查看以下文件夹。通过增加和删除文件夹可进行文件索引设置。 + + + + Add ignored folders + 添加禁止索引文件夹 + + + + Search Engine Settings + 搜索引擎设置 + + + + Please select search engine you preferred. + 设置互联网搜索引擎 + + + + baidu + 百度 + + + + sougou + 搜狗 + + + + 360 + 360 + + + + Cancel + 取消 + + + + Confirm + 确认 + + + + Creating ... + 正在索引 + + + + Done + 索引完成 + + + + Index Entry: %1 + 索引项: %1 + + +