Merge pull request #1 from CrankyPants123/main

Use ukui-log4qt instead of message handler module
This commit is contained in:
张佳萍 2021-04-21 11:01:19 +08:00 committed by GitHub
commit d1a3fd1688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 9086 additions and 1168 deletions

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Name=ukui-search
Name=Search
Name[zh_CN]=搜索
GenericName=UKUI Global Search
GenericName[zh_CN]=全局搜索

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Name=ukui-search
Name=Search
Name[zh_CN]=搜索
GenericName=UKUI Global Search
GenericName[zh_CN]=全局搜索

107
debian/changelog vendored
View File

@ -1,3 +1,110 @@
ukui-search (0.3.0+0406) v101; urgency=medium
* Add support for '.xls', '.dot','.wps', '.pps', '.dps', '.et','.ppt'.
- 增加了对'.xls', '.dot','.wps', '.pps', '.dps',
'.et','.ppt'格式文本内容索引的支持。
* Fix: symbolic links may cause main blocked.
- 解决了符号链接有可能导致索引卡死的bug。
* Fix: Snippet will not be displayed correctly when file content is too short.
- 修复了当文件内容太短时,显示详情错误的问题。
-- zhangpengfei <zhangpengfei@kylinos.cn> Tue, 06 Apr 2021 08:40:38 +0800
ukui-search (0.3.0+0401) v101; urgency=medium
* Remove qtwebengineview dependence, remove web page load function.
- 移除了网页加载功能,点击网页搜索直接跳转到浏览器。
* Use kwin effect for settings widget.
- 设置页面使用了窗管特效,避免了失焦变黑的问题(45200)。
-- zhangpengfei <zhangpengfei@kylinos.cn> Thu, 01 Apr 2021 11:38:51 +0800
ukui-search (0.2.0+0330) v101; urgency=medium
* Fix:Title bar will appear if open mainwindow which closed in panel.
- 修复了从任务栏预览窗关闭搜索后再打开搜索会出现两个标题栏的问题。
* Add function of historycal record.
- 增加搜索历史记录功能。
* Fix:Add support for polysyllabic character in app search and settings
search.
- 在应用搜索和设置搜索中增加对多音字的支持(43441,46289)。
-- zhangpengfei <zhangpengfei@kylinos.cn> Tue, 30 Mar 2021 09:52:15 +0800
ukui-search (0.2.0+0325) v101; urgency=medium
* Changed name displayed in ukui-menu from 'ukui-search' to 'Search'.
- 更改了英文模式下开始菜单中显示的名字。
-- zhangpengfei <zhangpengfei@kylinos.cn> Thu, 25 Mar 2021 11:00:09 +0800
ukui-search (0.2.0+0322) v101; urgency=medium
* Fit muti-screens mode.
- 适配990多屏显示。
* Feat:Clear cache after web searching.
- 清除网页搜索缓存。
* Fix(frontend): Complete translations.
- 修复提示框按钮未汉化问题(bug38128)。
* Fix(frontend): NameLabel do not update when font-size changed.
- 修复字体大小更改时主页标签不刷新的bug(bug42681)。
* Feat(frontend): Reset geometry for ukui-search.
- 重新计算搜索主界面的显示位置,修复任务栏隐藏时主界面显示位置有误的问题(43730)。
* Fix(frontend): Mainwindow is blocked when searching.
- 修复搜索时主界面阻塞的问题(43315)。
* Fix:mkfifo fail when fifo path is not exits
- 修复切换用户后打开搜索失败的问题(42486)。
* Feat(frontend): Add tips when there is no network avaliable.
- 当无网络可用时添加提示图案。
-- zhangpengfei <zhangpengfei@kylinos.cn> Mon, 22 Mar 2021 10:43:51 +0800
ukui-search (0.2.0+0312) v101; urgency=medium
* Fix: Index process may crash while system first boot.
- 解决了系统首次启动时偶现的崩溃问题。
* Fix: File with space in name can not be opened.
- 修复文件名带空格时无法从最近打开列表打开的问题
* Feature: Add app description.
- 为未安装应用添加应用描述栏.
* Adjust spacing of UI controls according to blueprint.
- 根据设计稿调整UI控件间距.
* Fix: Software center will not refresh which is already opened.
- 修复软件商店打开后点击安装不会再跳转的bug.
-- zhangpengfei <zhangpengfei@kylinos.cn> Fri, 12 Mar 2021 08:59:29 +0800
ukui-search (0.2.0+0306) v101; urgency=medium
* Feature: Add support for 'doc' file in file content search.
- 文本索引增加了对doc格式文件的支持。
* Fix: There is no web search result when there is no local result.
- 修复没有本地搜索结果时不显示网页搜索列表的问题。
* Fix:Files with special charactors can not be opened successfully.
- 修复带有特殊字符的文件无法正常打开的问题。
* Fix:Occasional crash during the first boot of system.
- 修复了在系统首次启动时偶现的崩溃问题。
-- zhangpengfei <zhangpengfei@kylinos.cn> Sat, 06 Mar 2021 11:03:20 +0800
ukui-search (0.2.0+0301) v101; urgency=medium
* Fix: New result won't be added to expanded list.
- 修复展开列表后新增的搜索结果不会动态添加的bug。
* Fix: Selection canceled with 'Show More' button clicked.
- 修复点击显示更多按钮时列表选中项被取消的问题。
* Feature: Add web searching & web engine settings.
- 添加网页搜索功能和引擎设置功能。
* Fix: Two list items can be selected simultaneously.
- 修复可以同时选中两个列表项的bug(40056)。
* Fix: Web view will be refreshed when there is nothing to reload.
- 修复当网页未搜索新内容时每次打开会重新加载的问题。
* Feature: Connect with the latest API for app search.
- 对接应用搜索新接口(可搜索未安装应用)。
* Fix: Excessive use of resources。
- 优化了资源占用。
-- zhangpengfei <zhangpengfei@kylinos.cn> Mon, 01 Mar 2021 13:55:27 +0800
ukui-search (0.1.1+0219-1) v101; urgency=medium
* Remove QWebEngineView dependence.

10
debian/control vendored
View File

@ -16,7 +16,9 @@ Build-Depends: debhelper (>=9.0.0),
libkf5windowsystem-dev,
libgsettings-qt-dev,
libqt5x11extras5-dev,
libuchardet-dev
libuchardet-dev,
libpoppler-qt5-dev,
libukui-log4qt-dev
Standards-Version: 4.5.0
Homepage: https://www.ukui.org/
Vcs-Git: https://github.com/ukui/ukui-search.git
@ -47,7 +49,8 @@ Section: libs
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends},
libchinese-segmentation0 (= ${binary:Version})
libchinese-segmentation0 (= ${binary:Version}),
ukui-search-systemdbus (= ${binary:Version})
Provides: libukui-search,
Description: Libraries for ukui-search.
@ -57,7 +60,8 @@ Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends},
libukui-search0 (= ${binary:Version}),
libchinese-segmentation0 (= ${binary:Version})
libchinese-segmentation0 (= ${binary:Version}),
ukui-search-systemdbus (= ${binary:Version})
Description: Libraries for ukui-search(development files).
Package: ukui-search-systemdbus

View File

@ -55,14 +55,16 @@ ChineseSegmentation *ChineseSegmentation::getInstance()
return global_instance_chinese_segmentation;
}
QVector<SKeyWord> ChineseSegmentation::callSegement(QString& str)
QVector<SKeyWord> ChineseSegmentation::callSegement(QString str)
{
std::string s;
s=str.toStdString();
str.squeeze();
const size_t topk = -1;
std::vector<cppjieba::KeywordExtractor::Word> keywordres;
ChineseSegmentation::m_jieba->extractor.Extract(s, keywordres, topk);
std::string().swap(s);
QVector<SKeyWord> vecNeeds;
convert(keywordres, vecNeeds);

View File

@ -48,7 +48,7 @@ class CHINESESEGMENTATION_EXPORT ChineseSegmentation
public:
static ChineseSegmentation *getInstance();
~ChineseSegmentation();
QVector<SKeyWord> callSegement(QString &str);
QVector<SKeyWord> callSegement(QString str);
void convert(std::vector<cppjieba::KeywordExtractor::Word>& keywordres,QVector<SKeyWord>& kw);
private:
static QMutex m_mutex;

View File

@ -20,23 +20,52 @@
#include "app-match.h"
#include <glib.h>
#include "file-utils.h"
AppMatch::AppMatch(QObject *parent) : QObject(parent)
static AppMatch *app_match_Class = nullptr;
AppMatch *AppMatch::getAppMatch()
{
this->getDesktopFilePath();
if (!app_match_Class) {
app_match_Class = new AppMatch;
}
return app_match_Class;
}
AppMatch::AppMatch(QObject *parent) : QThread(parent)
// m_versionCommand(new QProcess(this))
{
m_watchAppDir=new QFileSystemWatcher(this);
m_watchAppDir->addPath("/usr/share/applications/");
qDBusRegisterMetaType<QMap<QString,QString>>();
qDBusRegisterMetaType<QList<QMap<QString,QString>>>();
m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults",
"com.kylin.getsearchresults",
QDBusConnection::sessionBus());
if (!m_interFace->isValid())
{
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
qDebug()<<"AppMatch is new";
}
QStringList AppMatch::startMatchApp(QString input){
input.replace(" ","");
m_sourceText=input;
m_returnResult.clear();
if(input.isEmpty()){
return m_returnResult;
AppMatch::~AppMatch(){
if(m_interFace){
delete m_interFace;
}
this->getAppName();
m_returnResult=m_midResult;
m_midResult.clear();
// qWarning()<<"m_returnResult :"<<m_returnResult;
return m_returnResult;
m_interFace=NULL;
if(m_watchAppDir){
delete m_watchAppDir;
}
m_watchAppDir=NULL;
}
void AppMatch::startMatchApp(QString input,QMap<NameString,QStringList> &installed,QMap<NameString,QStringList> &softwarereturn){
input.replace(" ","");
if(input.isEmpty())
return;
m_sourceText=input;
getAppName(installed);
softWareCenterSearch(softwarereturn);
qDebug()<<"match app is successful!";
}
/**
@ -45,6 +74,10 @@ QStringList AppMatch::startMatchApp(QString input){
*/
void AppMatch::getAllDesktopFilePath(QString path){
char* name;
char* icon;
QStringList applist;
GKeyFileFlags flags=G_KEY_FILE_NONE;
GKeyFile* keyfile=g_key_file_new ();
@ -60,7 +93,6 @@ void AppMatch::getAllDesktopFilePath(QString path){
return;
}
int i=0;
//递归算法的核心部分
do{
QFileInfo fileInfo = list.at(i);
@ -73,7 +105,7 @@ void AppMatch::getAllDesktopFilePath(QString path){
//过滤LXQt、KDE
QString filePathStr=fileInfo.filePath();
if(filePathStr.contains("KDE",Qt::CaseInsensitive)||
filePathStr.contains("mate",Qt::CaseInsensitive)||
// filePathStr.contains("mate",Qt::CaseInsensitive)||
filePathStr.contains("LX",Qt::CaseInsensitive) ){
i++;
continue;
@ -128,8 +160,15 @@ void AppMatch::getAllDesktopFilePath(QString path){
continue;
}
}
m_filePathList.append(filePathStr);
name=g_key_file_get_locale_string(keyfile,"Desktop Entry","Name", nullptr, nullptr);
icon=g_key_file_get_locale_string(keyfile,"Desktop Entry","Icon", nullptr, nullptr);
if(!m_filePathList.contains(filePathStr)){
NameString appname;
appname.app_name = QString::fromLocal8Bit(name);
m_installAppMap.insert(appname,applist<<filePathStr<<QString::fromLocal8Bit(icon)<<""<<"");
applist.clear();
}
// m_filePathList.append(filePathStr);
}
i++;
@ -144,80 +183,68 @@ void AppMatch::getAllDesktopFilePath(QString path){
void AppMatch::getDesktopFilePath()
{
m_filePathList.clear();
getAllDesktopFilePath("/usr/share/applications/");
m_filePathList.removeAll("/usr/share/applications/software-properties-livepatch.desktop");
m_filePathList.removeAll("/usr/share/applications/mate-color-select.desktop");
m_filePathList.removeAll("/usr/share/applications/blueman-adapters.desktop");
m_filePathList.removeAll("/usr/share/applications/blueman-manager.desktop");
m_filePathList.removeAll("/usr/share/applications/mate-user-guide.desktop");
m_filePathList.removeAll("/usr/share/applications/nm-connection-editor.desktop");
m_filePathList.removeAll("/usr/share/applications/debian-uxterm.desktop");
m_filePathList.removeAll("/usr/share/applications/debian-xterm.desktop");
m_filePathList.removeAll("/usr/share/applications/im-config.desktop");
m_filePathList.removeAll("/usr/share/applications/fcitx.desktop");
m_filePathList.removeAll("/usr/share/applications/fcitx-configtool.desktop");
m_filePathList.removeAll("/usr/share/applications/onboard-settings.desktop");
m_filePathList.removeAll("/usr/share/applications/info.desktop");
m_filePathList.removeAll("/usr/share/applications/ukui-power-preferences.desktop");
m_filePathList.removeAll("/usr/share/applications/ukui-power-statistics.desktop");
m_filePathList.removeAll("/usr/share/applications/software-properties-drivers.desktop");
m_filePathList.removeAll("/usr/share/applications/software-properties-gtk.desktop");
m_filePathList.removeAll("/usr/share/applications/gnome-session-properties.desktop");
m_filePathList.removeAll("/usr/share/applications/org.gnome.font-viewer.desktop");
m_filePathList.removeAll("/usr/share/applications/xdiagnose.desktop");
m_filePathList.removeAll("/usr/share/applications/gnome-language-selector.desktop");
m_filePathList.removeAll("/usr/share/applications/mate-notification-properties.desktop");
m_filePathList.removeAll("/usr/share/applications/transmission-gtk.desktop");
m_filePathList.removeAll("/usr/share/applications/mpv.desktop");
m_filePathList.removeAll("/usr/share/applications/system-config-printer.desktop");
m_filePathList.removeAll("/usr/share/applications/org.gnome.DejaDup.desktop");
m_filePathList.removeAll("/usr/share/applications/yelp.desktop");
m_filePathList.removeAll("/usr/share/applications/peony-computer.desktop");
m_filePathList.removeAll("/usr/share/applications/peony-home.desktop");
m_filePathList.removeAll("/usr/share/applications/peony-trash.desktop");
m_filePathList.removeAll("/usr/share/applications/peony.desktop");
m_installAppMap.clear();
m_filePathList.append("/usr/share/applications/software-properties-livepatch.desktop");
m_filePathList.append("/usr/share/applications/mate-color-select.desktop");
m_filePathList.append("/usr/share/applications/blueman-adapters.desktop");
m_filePathList.append("/usr/share/applications/blueman-manager.desktop");
m_filePathList.append("/usr/share/applications/mate-user-guide.desktop");
m_filePathList.append("/usr/share/applications/nm-connection-editor.desktop");
m_filePathList.append("/usr/share/applications/debian-uxterm.desktop");
m_filePathList.append("/usr/share/applications/debian-xterm.desktop");
m_filePathList.append("/usr/share/applications/im-config.desktop");
m_filePathList.append("/usr/share/applications/fcitx.desktop");
m_filePathList.append("/usr/share/applications/fcitx-configtool.desktop");
m_filePathList.append("/usr/share/applications/onboard-settings.desktop");
m_filePathList.append("/usr/share/applications/info.desktop");
m_filePathList.append("/usr/share/applications/ukui-power-preferences.desktop");
m_filePathList.append("/usr/share/applications/ukui-power-statistics.desktop");
m_filePathList.append("/usr/share/applications/software-properties-drivers.desktop");
m_filePathList.append("/usr/share/applications/software-properties-gtk.desktop");
m_filePathList.append("/usr/share/applications/gnome-session-properties.desktop");
m_filePathList.append("/usr/share/applications/org.gnome.font-viewer.desktop");
m_filePathList.append("/usr/share/applications/xdiagnose.desktop");
m_filePathList.append("/usr/share/applications/gnome-language-selector.desktop");
m_filePathList.append("/usr/share/applications/mate-notification-properties.desktop");
m_filePathList.append("/usr/share/applications/transmission-gtk.desktop");
m_filePathList.append("/usr/share/applications/mpv.desktop");
m_filePathList.append("/usr/share/applications/system-config-printer.desktop");
m_filePathList.append("/usr/share/applications/org.gnome.DejaDup.desktop");
m_filePathList.append("/usr/share/applications/yelp.desktop");
m_filePathList.append("/usr/share/applications/peony-computer.desktop");
m_filePathList.append("/usr/share/applications/peony-home.desktop");
m_filePathList.append("/usr/share/applications/peony-trash.desktop");
// m_filePathList.append("/usr/share/applications/peony.desktop");
//v10
m_filePathList.removeAll("/usr/share/applications/mate-about.desktop");
m_filePathList.removeAll("/usr/share/applications/time.desktop");
m_filePathList.removeAll("/usr/share/applications/network.desktop");
m_filePathList.removeAll("/usr/share/applications/shares.desktop");
m_filePathList.removeAll("/usr/share/applications/mate-power-statistics.desktop");
m_filePathList.removeAll("/usr/share/applications/display-im6.desktop");
m_filePathList.removeAll("/usr/share/applications/display-im6.q16.desktop");
m_filePathList.removeAll("/usr/share/applications/openjdk-8-policytool.desktop");
m_filePathList.removeAll("/usr/share/applications/kylin-io-monitor.desktop");
m_filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop");
m_filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop");
m_filePathList.append("/usr/share/applications/mate-about.desktop");
m_filePathList.append("/usr/share/applications/time.desktop");
m_filePathList.append("/usr/share/applications/network.desktop");
m_filePathList.append("/usr/share/applications/shares.desktop");
m_filePathList.append("/usr/share/applications/mate-power-statistics.desktop");
m_filePathList.append("/usr/share/applications/display-im6.desktop");
m_filePathList.append("/usr/share/applications/display-im6.q16.desktop");
m_filePathList.append("/usr/share/applications/openjdk-8-policytool.desktop");
m_filePathList.append("/usr/share/applications/kylin-io-monitor.desktop");
m_filePathList.append("/usr/share/applications/wps-office-uninstall.desktop");
// QString desktop;
// QStringList applist;
// QMap<QString, QList<QString>>::const_iterator i;
// for(i=m_installAppMap.constBegin();i!=m_installAppMap.constEnd();++i){
// applist=i.value();
// if(m_filePathList.contains(applist.at(0)))
// m_filterInstallAppMap.insert(i.key(),applist);
// }
}
/**
* @brief AppMatch::getAppName
*
*/
void AppMatch::getAppName()
void AppMatch::getAppName(QMap<NameString,QStringList> &installed)
{
GKeyFileFlags flags=G_KEY_FILE_NONE;
GKeyFile* keyfile=g_key_file_new ();
QByteArray fpbyte;
QString str;
char* filepath;
char* name;
QString namestr;
for(int i=0;i<m_filePathList.size();i++){
str=m_filePathList.at(i);
fpbyte=str.toLocal8Bit();
filepath=fpbyte.data();
g_key_file_load_from_file(keyfile,filepath,flags,nullptr);
name=g_key_file_get_locale_string(keyfile,"Desktop Entry","Name", nullptr, nullptr);
namestr=QString::fromLocal8Bit(name);
// qWarning()<<"namestr :"<<namestr;
appNameMatch(namestr,str);
}
g_key_file_load_from_file(keyfile,filepath,flags,nullptr);
g_key_file_free(keyfile);
QMap<NameString, QStringList>::const_iterator i;
for(i=m_installAppMap.constBegin();i!=m_installAppMap.constEnd();++i){
appNameMatch(i.key().app_name,installed);
}
qDebug()<<"installed app match is successful!";
}
/**
@ -225,23 +252,119 @@ void AppMatch::getAppName()
*
* @param appname
*
* @param desktoppath
* desktop路径
*/
void AppMatch::appNameMatch(QString appname,QString desktoppath){
void AppMatch::appNameMatch(QString appname,QMap<NameString,QStringList> &installed){
NameString name{appname};
QStringList list;
QStringList pinyinlist;
pinyinlist=FileUtils::findMultiToneWords(appname);
QMapIterator<NameString,QStringList> iter(m_installAppMap);
while(iter.hasNext())
{
iter.next();
if (iter.key().app_name == appname) {
list = iter.value();
break;
}
}
if(appname.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath);
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
QString shouzimu=FileUtils::findMultiToneWords(appname).at(1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath);
return;
}
if(m_sourceText.size()<2)
return;
QString pinyin=FileUtils::findMultiToneWords(appname).at(0);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath);
for(int i = 0;i<pinyinlist.size()/2;i++){
QString shouzimu=pinyinlist.at(2*i+1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
if(m_sourceText.size()<2)
return;
QString pinyin=pinyinlist.at(2*i);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
}
}
void AppMatch::softWareCenterSearch(QMap<NameString,QStringList> &softwarereturn){
if(m_interFace->timeout()!=-1){
qWarning()<<"softWareCente Dbus is timeout !";
return;
}
slotDBusCallFinished(softwarereturn);
qDebug()<<"softWareCenter match app is successful!";
}
void AppMatch::slotDBusCallFinished(QMap<NameString,QStringList> &softwarereturn){
QDBusReply<QList<QMap<QString,QString>>> reply = m_interFace->call("get_search_result",m_sourceText); //阻塞,直到远程方法调用完成。
// QDBusPendingReply<QList<QMap<QString,QString>>> reply = *call;
if (reply.isValid())
{
parseSoftWareCenterReturn(reply.value(),softwarereturn);
}
else
{
qWarning() << "value method called failed!";
}
// call->deleteLater();
}
void AppMatch::parseSoftWareCenterReturn(QList<QMap<QString,QString>> list,QMap<NameString,QStringList> &softwarereturn){
// qWarning()<<list;
QString appname;
NameString name;
QString appicon;
QString appdiscription;
QStringList applist;
QLocale locale;
QString pkgname;
for(int i=0;i<list.size();i++){
// qWarning()<<list.at(i).keys();
if(locale.language()==QLocale::Chinese){
appname=list.at(i).value("displayname_cn");
pkgname = list.at(i).value("appname");
}
if(locale.language()==QLocale::English){
appname=list.at(i).value("appname");
}
appdiscription=list.at(i).value("discription");
appicon=list.at(i).value("icon");
name.app_name = appname;
pkgname.isEmpty() ? softwarereturn.insert(name,applist<<""<<appicon<<""<<appdiscription) : softwarereturn.insert(name,applist<<""<<appicon<<pkgname<<appdiscription);
applist.clear();
}
}
void AppMatch::getInstalledAppsVersion(QString appname){
// qWarning()<<"apt show "+appname;
// m_versionCommand->start("apt show "+appname);
// m_versionCommand->startDetached(m_versionCommand->program());
// m_versionCommand->waitForFinished();
// connect(m_versionCommand,&QProcess::readyReadStandardOutput,this,[=](){
// QString result=m_versionCommand->readAllStandardOutput();
// if(!result.isEmpty()){
// QStringList strlist=result.split("\n");
// QString str=strlist.at(1);
// if(!str.contains("Version")){
// return;
// }
// qWarning()<<strlist.at(1);
// qWarning()<<"-----------------------------------------------";
// }
// });
// m_versionCommand->close();
}
void AppMatch::run(){
qDebug()<<"AppMatch is run";
this->getDesktopFilePath();
this->getAllDesktopFilePath("/usr/share/applications/");
connect(m_watchAppDir,&QFileSystemWatcher::directoryChanged,[this](){
this->getDesktopFilePath();
this->getAllDesktopFilePath("/usr/share/applications/");
});
}

View File

@ -24,24 +24,71 @@
#include <QDir>
#include <QLocale>
#include <QDebug>
class AppMatch : public QObject
#include <QDBusInterface>
#include <QDBusReply>
#include <QtDBus>
#include <QElapsedTimer>
#include <QThread>
class NameString
{
public:
explicit NameString(const QString &str_) : app_name(str_) {}
NameString() = default;
QString app_name;
bool operator<(const NameString& name) const {
return this->app_name.length() <= name.app_name.length();
}
};
//struct NameString
//{
// QString app_name;
// //重载操作符
// inline bool operator < (const NameString& name) const
// {
//// return name.app_name.length() >= app_name.length();
// return true;
// }
//};
class AppMatch : public QThread
{
Q_OBJECT
public:
explicit AppMatch(QObject *parent = nullptr);
QStringList startMatchApp(QString input);
static AppMatch *getAppMatch();
void startMatchApp(QString input,QMap<NameString,QStringList> &installed,QMap<NameString,QStringList> &softwarereturn);
private:
explicit AppMatch(QObject *parent = nullptr);
~AppMatch();
void getAllDesktopFilePath(QString path);
void getDesktopFilePath();
void getAppName();
void appNameMatch(QString appname,QString desktoppath);
void getAppName(QMap<NameString,QStringList> &installed);
// void appNameMatch(QString appname,QString desktoppath,QString appicon);
void appNameMatch(QString appname,QMap<NameString,QStringList> &installed);
void softWareCenterSearch(QMap<NameString,QStringList> &softwarereturn);
void parseSoftWareCenterReturn(QList<QMap<QString,QString>> list,QMap<NameString,QStringList> &softwarereturn);
void getInstalledAppsVersion(QString appname);
private:
QString m_sourceText;
QStringList m_filePathList;
QStringList m_returnResult;
QStringList m_midResult;
QDBusInterface *m_interFace=nullptr;
QFileSystemWatcher *m_watchAppDir=nullptr;
QMap<NameString,QStringList> m_installAppMap;
private Q_SLOTS:
void slotDBusCallFinished(QMap<NameString,QStringList> &softwarereturn);
//Q_SIGNALS:
protected:
void run() override;
};

View File

@ -20,18 +20,6 @@
*
*/
#include "file-utils.h"
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QUrl>
#include <QMap>
#include "quazip/quazip.h"
#include <quazip/quazipfile.h>
#include <QDomDocument>
#include <QMimeDatabase>
#include <QMimeType>
#include <QQueue>
#include "uchardet/uchardet.h"
size_t FileUtils::_max_index_count = 0;
@ -211,14 +199,12 @@ void FileUtils::loadHanziTable(const QString &fileName)
return;
}
QString FileUtils::getMimetype(QString &path, bool getsuffix)
QMimeType FileUtils::getMimetype(QString &path)
{
QMimeDatabase mdb;
QMimeType type = mdb.mimeTypeForFile(path,QMimeDatabase::MatchContent);
if(getsuffix)
return type.name();
else
return type.preferredSuffix();
return type;
}
//aborted
@ -506,6 +492,7 @@ QStringList FileUtils::findMultiToneWords(const QString& hanzi)
*/
void FileUtils::getDocxTextContent(QString &path,QString &textcontent)
{
//fix me :optimized by xpath??
QFileInfo info = QFileInfo(path);
if(!info.exists()||info.isDir())
return;
@ -521,6 +508,7 @@ void FileUtils::getDocxTextContent(QString &path,QString &textcontent)
QDomDocument doc;
doc.setContent(fileR.readAll());
fileR.close();
QDomElement first = doc.firstChildElement("w:document");
QDomElement body = first.firstChildElement("w:body");
while(!body.isNull())
@ -533,6 +521,11 @@ void FileUtils::getDocxTextContent(QString &path,QString &textcontent)
{
QDomElement wt = wr.firstChildElement("w:t");
textcontent.append(wt.text().replace("\n",""));
if(textcontent.length() >= MAX_CONTENT_LENGTH/3)
{
file.close();
return;
}
wr = wr.nextSiblingElement();
}
wp = wp.nextSiblingElement();
@ -543,13 +536,176 @@ void FileUtils::getDocxTextContent(QString &path,QString &textcontent)
return;
}
void FileUtils::getPptxTextContent(QString &path, QString &textcontent)
{
QFileInfo info = QFileInfo(path);
if(!info.exists()||info.isDir())
return;
QuaZip file(path);
if(!file.open(QuaZip::mdUnzip))
return;
QString prefix("ppt/slides/slide");
QStringList fileList;
for(QString i : file.getFileNameList())
{
if(i.startsWith(prefix))
fileList<<i;
}
if(fileList.isEmpty())
return;
QDomElement sptree;
QDomElement sp;
QDomElement txbody;
QDomElement ap;
QDomElement ar;
QDomDocument doc;
QDomElement at;
// QDomNodeList atList;
for(int i =0;i<fileList.size();++i)
{
QString name = prefix + QString::number(i+1) + ".xml";
if(!file.setCurrentFile(name))
{
continue;
}
QuaZipFile fileR(&file);
fileR.open(QIODevice::ReadOnly);
doc.clear();
doc.setContent(fileR.readAll());
fileR.close();
//fix me :optimized by xpath??
//This method looks better but slower,
//If xml file is very large with many useless node,this method will take a lot of time.
// atList = doc.elementsByTagName("a:t");
// for(int i = 0; i<atList.size(); ++i)
// {
// at = atList.at(i).toElement();
// if(!at.isNull())
// {
// textcontent.append(at.text().replace("\r","")).replace("\t"," ");
// if(textcontent.length() >= MAX_CONTENT_LENGTH/3)
// {
// file.close();
// return;
// }
// }
// }
//This is ugly but seems more efficient when handel a large file.
sptree = doc.firstChildElement("p:sld").firstChildElement("p:cSld").firstChildElement("p:spTree");
while(!sptree.isNull())
{
sp= sptree.firstChildElement("p:sp");
while(!sp.isNull())
{
txbody= sp.firstChildElement("p:txBody");
while(!txbody.isNull())
{
ap = txbody.firstChildElement("a:p");
while(!ap.isNull())
{
ar = ap.firstChildElement("a:r");
while(!ar.isNull())
{
at = ar.firstChildElement("a:t");
textcontent.append(at.text().replace("\r","")).replace("\t","");
if(textcontent.length() >= MAX_CONTENT_LENGTH/3)
{
file.close();
return;
}
ar = ar.nextSiblingElement();
}
ap = ap.nextSiblingElement();
}
txbody = txbody.nextSiblingElement();
}
sp = sp.nextSiblingElement();
}
sptree = sptree.nextSiblingElement();
}
}
file.close();
return;
}
void FileUtils::getXlsxTextContent(QString &path, QString &textcontent)
{
QFileInfo info = QFileInfo(path);
if(!info.exists()||info.isDir())
return;
QuaZip file(path);
if(!file.open(QuaZip::mdUnzip))
return;
if(!file.setCurrentFile("xl/sharedStrings.xml",QuaZip::csSensitive))
return;
QuaZipFile fileR(&file);
fileR.open(QIODevice::ReadOnly); //读取方式打开
QDomDocument doc;
doc.setContent(fileR.readAll());
fileR.close();
QDomElement sst = doc.firstChildElement("sst");
QDomElement si;
QDomElement r;
QDomElement t;
while(!sst.isNull())
{
si= sst.firstChildElement("si");
while(!si.isNull())
{
r= si.firstChildElement("r");
if(r.isNull())
{
t= si.firstChildElement("t");
}
else
{
t = r.firstChildElement("t");
}
if(t.isNull())
continue;
textcontent.append(t.text().replace("\r","").replace("\n",""));
if(textcontent.length() >= MAX_CONTENT_LENGTH/3)
{
file.close();
return;
}
si = si.nextSiblingElement();
}
sst = sst.nextSiblingElement();
}
file.close();
return;
}
void FileUtils::getPdfTextContent(QString &path, QString &textcontent)
{
Poppler::Document *doc = Poppler::Document::load(path);
if(doc->isLocked())
return;
const QRectF qf;
int pageNum = doc->numPages();
for(int i = 0; i<pageNum; ++i)
{
textcontent.append(doc->page(i)->text(qf).replace("\n",""));
if(textcontent.length() >= MAX_CONTENT_LENGTH/3)
break;
}
delete doc;
return;
}
void FileUtils::getTxtContent(QString &path, QString &textcontent)
{
QFile file(path);
if(!file.open(QIODevice::ReadOnly|QIODevice::Text))
return;
QByteArray encodedString = file.readAll();
QByteArray encodedString = file.read(MAX_CONTENT_LENGTH);
uchardet_t chardet = uchardet_new();
if(uchardet_handle_data(chardet,encodedString.constData(),encodedString.size()) !=0)
@ -559,7 +715,7 @@ void FileUtils::getTxtContent(QString &path, QString &textcontent)
const char *codec = uchardet_get_charset(chardet);
if(QTextCodec::codecForName(codec) == 0)
qWarning()<<"Unsupported Text encoding format"<<path<<QString::fromLocal8Bit(codec)<<"zpf666";
qWarning()<<"Unsupported Text encoding format"<<path<<QString::fromLocal8Bit(codec);
QTextStream stream(encodedString,QIODevice::ReadOnly);
stream.setCodec(codec);

View File

@ -21,23 +21,42 @@
*/
#ifndef FILEUTILS_H
#define FILEUTILS_H
#include "gobject-template.h"
#include <QString>
#include <QCryptographicHash>
#include <QIcon>
#include <QMap>
#include <QMimeDatabase>
#include <QMimeType>
#include <QDir>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QUrl>
#include <QMap>
#include <QDomDocument>
#include <QQueue>
#include <quazip/quazipfile.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <QString>
#include <QCryptographicHash>
#include <QIcon>
#include <QMap>
#include <quazip/quazip.h>
#include <uchardet/uchardet.h>
//#include <poppler-qt5.h>
#include <poppler/qt5/poppler-qt5.h>
#include "libsearch_global.h"
#include "gobject-template.h"
//#define INITIAL_STATE 0
//#define CREATING_INDEX 1
//#define FINISH_CREATING_INDEX 2
#define MAX_CONTENT_LENGTH 20480000
#define UKUI_SEARCH_PIPE_PATH "/tmp/ukuisearch"
#define UKUI_SEARCH_PIPE_PATH (QDir::homePath()+"/.config/org.ukui/ukui-search/ukuisearch").toLocal8Bit().constData()
class LIBSEARCH_EXPORT FileUtils
@ -59,13 +78,19 @@ public:
static void loadHanziTable(const QString&);
//parse text,docx.....
static QString getMimetype(QString &path, bool getsuffix = false);
static QMimeType getMimetype(QString &path);
static void getDocxTextContent(QString &path, QString &textcontent);
static void getPptxTextContent(QString &path, QString &textcontent);
static void getXlsxTextContent(QString &path, QString &textcontent);
static void getPdfTextContent(QString &path, QString &textcontent);
static void getTxtContent(QString &path, QString &textcontent);
static size_t _max_index_count;
static size_t _current_index_count; //this one has been Abandoned,do not use it.
static unsigned short _index_status;
// enum class SearchMethod{ DIRECTSEARCH = 0, INDEXSEARCH = 1};
// static SearchMethod searchMethod = FileUtils::SearchMethod::DIRECTSEARCH;
private:
FileUtils();
};

View File

@ -35,30 +35,61 @@ GlobalSettings *GlobalSettings::getInstance()
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
{
m_settings = new QSettings("org.ukui", "ukui-search", this);
m_block_dirs_settings = new QSettings("org.ukui","ukui-search-block-dirs",this);
m_settings = new QSettings(MAIN_SETTINGS, QSettings::IniFormat, this);
// m_settings->setAtomicSyncRequired(false);
m_block_dirs_settings = new QSettings(BLOCK_DIRS,QSettings::IniFormat, this);
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
m_search_record_settings = new QSettings(SEARCH_HISTORY, QSettings::IniFormat , this);
m_search_record_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
for(QString i:m_search_record_settings->allKeys())
{
m_history.append(QUrl::fromPercentEncoding(i.toLocal8Bit()));
}
if(!QDBusConnection::sessionBus().connect("org.kylinssoclient.dbus",
"/org/kylinssoclient/path",
"org.freedesktop.kylinssoclient.interface",
"keyChanged",
this, SLOT(updateSearchHistory(QString))))
qWarning()<<"Kylinssoclient Dbus connect fail!";
this->forceSync();
//the default number of transparency in mainwindow is 0.7
//if someone changes the num in mainwindow, here should be modified too
m_cache.insert(TRANSPARENCY_KEY, 0.7);
if (QGSettings::isSchemaInstalled(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID)) {
m_gsettings = new QGSettings(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID, QByteArray(), this);
connect(m_gsettings, &QGSettings::changed, this, [=](const QString& key) {
m_trans_gsettings = new QGSettings(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID, QByteArray(), this);
connect(m_trans_gsettings, &QGSettings::changed, this, [=](const QString& key) {
if (key == TRANSPARENCY_KEY) {
m_cache.remove(TRANSPARENCY_KEY);
m_cache.insert(TRANSPARENCY_KEY, m_gsettings->get(TRANSPARENCY_KEY).toDouble());
m_cache.insert(TRANSPARENCY_KEY, m_trans_gsettings->get(TRANSPARENCY_KEY).toDouble());
qApp->paletteChanged(qApp->palette());
}
});
m_cache.remove(TRANSPARENCY_KEY);
m_cache.insert(TRANSPARENCY_KEY, m_gsettings->get(TRANSPARENCY_KEY).toDouble());
m_cache.insert(TRANSPARENCY_KEY, m_trans_gsettings->get(TRANSPARENCY_KEY).toDouble());
}
}
GlobalSettings::~GlobalSettings()
{
if (QGSettings::isSchemaInstalled(THEME_GSETTINGS_ID)) {
m_theme_gsettings = new QGSettings(THEME_GSETTINGS_ID, QByteArray(), this);
connect(m_theme_gsettings, &QGSettings::changed, this, [=](const QString& key) {
if (key == STYLE_NAME_KEY) {
//当前主题改变时也发出paletteChanged信号通知主界面刷新
qApp->paletteChanged(qApp->palette());
m_cache.remove(STYLE_NAME_KEY);
m_cache.insert(STYLE_NAME_KEY, m_theme_gsettings->get(STYLE_NAME_KEY).toString());
} else if (key == FONT_SIZE_KEY) {
qApp->paletteChanged(qApp->palette());
m_cache.remove(FONT_SIZE_KEY);
m_cache.insert(FONT_SIZE_KEY, m_theme_gsettings->get(FONT_SIZE_KEY).toDouble());
}
});
m_cache.remove(STYLE_NAME_KEY);
m_cache.insert(STYLE_NAME_KEY, m_theme_gsettings->get(STYLE_NAME_KEY).toString());
m_cache.remove(FONT_SIZE_KEY);
m_cache.insert(FONT_SIZE_KEY, m_theme_gsettings->get(FONT_SIZE_KEY).toDouble());
}
}
const QVariant GlobalSettings::getValue(const QString &key)
@ -75,11 +106,11 @@ void GlobalSettings::reset(const QString &key)
{
m_cache.remove(key);
QtConcurrent::run([=]() {
if (m_mutex.tryLock(1000)) {
// if (m_mutex.tryLock(1000)) {
m_settings->remove(key);
m_settings->sync();
m_mutex.unlock();
}
// m_mutex.unlock();
// }
});
Q_EMIT this->valueChanged(key);
}
@ -145,18 +176,106 @@ QStringList GlobalSettings::getBlockDirs()
return m_block_dirs_settings->allKeys();
}
//void GlobalSettings::appendCloudData(const QString &key, const QString &value)
//{
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
// m_qSettings->beginGroup(key);
// QStringList values = m_qSettings->value(key).toStringList();
// m_qSettings->endGroup();
// if (values.contains(value)) {
// values.removeOne(value);
// }
// values.insert(0,value);
// m_qSettings->beginGroup(key);
// m_qSettings->setValue(key, values);
// m_qSettings->endGroup();
// if (m_qSettings) {
// delete m_qSettings;
// m_qSettings = NULL;
// }
//}
void GlobalSettings::setSearchRecord(const QString &word, const QDateTime &time)
{
QStringList keys = m_search_record_settings->allKeys();
if(keys.contains(QString(QUrl::toPercentEncoding(word))))
m_history.removeOne(word);
m_search_record_settings->setValue(QString(QUrl::toPercentEncoding(word)), time.toString("yyyy-MM-dd hh:mm:ss"));
if(keys.size() >= 20)
m_search_record_settings->remove(QString(QUrl::toPercentEncoding(m_history.takeFirst())));
m_history.append(word);
}
QStringList GlobalSettings::getSearchRecord()
{
return m_history;
}
//bool GlobalSettings::removeOneCloudData(const QString &key, const QString &value)
//{
// if (!QFileInfo(CLOUD_FILE).isFile()) return false;
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
// m_qSettings->beginGroup(key);
// QStringList values = m_qSettings->value(key).toStringList();
// m_qSettings->endGroup();
// if (values.contains(value)) {
// values.removeOne(value);
// } else return false;
// m_qSettings->beginGroup(key);
// m_qSettings->setValue(key, values);
// m_qSettings->endGroup();
// if (m_qSettings) {
// delete m_qSettings;
// m_qSettings = NULL;
// }
// return true;
//}
//bool GlobalSettings::removeAllCloudData(const QString &key)
//{
// if (!QFileInfo(CLOUD_FILE).isFile()) return false;
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
// m_qSettings->beginGroup(key);
// m_qSettings->beginGroup(key);
// m_qSettings->setValue(key, QStringList());
// m_qSettings->endGroup();
// if (m_qSettings) {
// delete m_qSettings;
// m_qSettings = NULL;
// }
// return true;
//}
//QStringList GlobalSettings::getCloudData(const QString &key)
//{
// if (!QFileInfo(CLOUD_FILE).isFile()) return QStringList();
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
// m_qSettings->beginGroup(key);
// QStringList values = m_qSettings->value(key).toStringList();
// m_qSettings->endGroup();
// if(m_qSettings)
// delete m_qSettings;
// return values;
//}
//here should be override
//MouseZhangZh
void GlobalSettings::setValue(const QString &key, const QVariant &value)
{
// qDebug()<<"setvalue========"<<key<<":"<<value;
m_cache.insert(key, value);
// m_settings->sync();
QtConcurrent::run([=]() {
// if (m_mutex.tryLock(1000)) {
m_mutex.lock();
m_settings->setValue(key, value);
m_settings->sync();
m_mutex.unlock();
// }
// qDebug()<<m_settings->status();
// if (m_mutex.tryLock(1000)) {
// m_mutex.lock();
m_settings->setValue(key, value);
// qDebug()<<"setvalue========finish!!!"<<key<<":"<<value;
m_settings->sync();
// qDebug()<<"setvalue========sync!!!"<<key<<":"<<value;
// m_mutex.unlock();
// }
});
}
@ -173,3 +292,16 @@ void GlobalSettings::forceSync(const QString &key)
m_cache.insert(key, m_settings->value(key));
}
}
void GlobalSettings::updateSearchHistory(QString key)
{
if(key == "search")
{
m_search_record_settings->sync();
m_history.clear();
for(QString i:m_search_record_settings->allKeys())
{
m_history.append(QUrl::fromPercentEncoding(i.toLocal8Bit()));
}
}
}

View File

@ -25,23 +25,36 @@
#include <QSettings>
#include <QMutex>
#include <QVector>
#include <QDir>
//#include <QGSettings>
//If use pkg_config, it wont build succes,why?????????
//My demo can build access yet.
//MouseZhangZh
#include <QGSettings/QGSettings>
#include <QDBusConnection>
#include <QDBusInterface>
#include "libsearch_global.h"
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
#define TRANSPARENCY_KEY "transparency"
#define THEME_GSETTINGS_ID "org.ukui.style"
#define STYLE_NAME_KEY "styleName"
#define FONT_SIZE_KEY "systemFontSize"
#define INDEX_DATABASE_STATE "index_database_state"
#define CONTENT_INDEX_DATABASE_STATE "content_index_database_state"
#define INDEX_GENERATOR_NORMAL_EXIT "index_generator_normal_exit"
#define INOTIFY_NORMAL_EXIT "inotify_normal_exit"
#define WEB_ENGINE "web_engine"
#define PATH_EMPTY 1;
#define PATH_NOT_IN_HOME 2;
#define PATH_PARENT_BLOCKED 3;
#define MAIN_SETTINGS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search.conf"
#define BLOCK_DIRS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf"
#define SEARCH_HISTORY QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-history.conf"
//#define CLOUD_HISTORY "history"
//#define CLOUD_APPLICATIONS "applications"
class LIBSEARCH_EXPORT GlobalSettings : public QObject
{
Q_OBJECT
@ -68,17 +81,27 @@ public Q_SLOTS:
*/
bool setBlockDirs(const QString& path, int &returnCode,bool remove = false);
QStringList getBlockDirs();
// void appendCloudData(const QString& key, const QString& value);
void setSearchRecord(const QString &word, const QDateTime &time);
QStringList getSearchRecord();
// bool removeOneCloudData(const QString& key, const QString& value);
// bool removeAllCloudData(const QString& key);
// QStringList getCloudData(const QString& key);
void forceSync(const QString& = nullptr);
void updateSearchHistory(QString key);
private:
explicit GlobalSettings(QObject *parent = nullptr);
~GlobalSettings();
~GlobalSettings() = default;
QSettings* m_settings;
QGSettings* m_gsettings;
QGSettings* m_trans_gsettings;
QGSettings* m_theme_gsettings;
QSettings *m_block_dirs_settings;
QSettings *m_search_record_settings;
QMap<QString, QVariant> m_cache;
QStringList m_history;
QMutex m_mutex;

View File

@ -27,23 +27,19 @@
//extern QList<Document> *_doc_list_path;
//extern QMutex _mutex_doc_list_path;
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> list, IndexGenerator *parent)
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> list)
{
this->setAutoDelete(true);
m_list = std::move(list);
}
ConstructDocumentForPath::~ConstructDocumentForPath()
{
}
void ConstructDocumentForPath::run()
{
// qDebug()<<"ConstructDocumentForPath";
if (!_doc_list_path)
_doc_list_path = new QList<Document>;
// qDebug()<<_doc_list_path->size();
QString index_text = m_list.at(0);
QString index_text = m_list.at(0).toLower();
QString sourcePath = m_list.at(1);
Document doc;
@ -103,17 +99,12 @@ void ConstructDocumentForPath::run()
return;
}
ConstructDocumentForContent::ConstructDocumentForContent(QString path,QObject *parent)
ConstructDocumentForContent::ConstructDocumentForContent(QString path)
{
this->setAutoDelete(true);
m_path = std::move(path);
}
ConstructDocumentForContent::~ConstructDocumentForContent()
{
}
void ConstructDocumentForContent::run()
{
// qDebug() << "ConstructDocumentForContent currentThreadId()" << QThread::currentThreadId();
@ -122,10 +113,12 @@ void ConstructDocumentForContent::run()
_doc_list_content = new QList<Document>;
QString content;
FileReader::getTextContent(m_path,content);
if(content.isEmpty())
return;
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(m_path));
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(m_path.section("/",0,-2,QString::SectionIncludeLeadingSep)));
QVector<SKeyWord> term = ChineseSegmentation::getInstance()->callSegement(content);
QVector<SKeyWord> term = ChineseSegmentation::getInstance()->callSegement(content.left(20480000));
Document doc;
doc.setData(content);
@ -142,6 +135,7 @@ void ConstructDocumentForContent::run()
_doc_list_content->append(doc);
_mutex_doc_list_content.unlock();
content.clear();
content.squeeze();
term.clear();
return;
}

View File

@ -31,28 +31,23 @@ class IndexGenerator;
class ConstructDocumentForPath : public QRunnable
{
public:
explicit ConstructDocumentForPath(QVector<QString> list,IndexGenerator *parent = nullptr);
~ConstructDocumentForPath();
explicit ConstructDocumentForPath(QVector<QString> list);
~ConstructDocumentForPath() = default;
protected:
void run();
private:
QVector<QString> m_list;
};
class ConstructDocumentForContent : public QObject, public QRunnable
class ConstructDocumentForContent : public QRunnable
{
Q_OBJECT
public:
explicit ConstructDocumentForContent(QString path,QObject *parent = nullptr);
~ConstructDocumentForContent();
explicit ConstructDocumentForContent(QString path);
~ConstructDocumentForContent() = default;
protected:
void run();
private:
QString m_path;
};
#endif // CONSTRUCTDOCUMENT_H

View File

@ -19,6 +19,7 @@
*/
#include "file-reader.h"
#include "file-utils.h"
#include "binary-parser.h"
FileReader::FileReader(QObject *parent) : QObject(parent)
{
@ -27,13 +28,42 @@ FileReader::FileReader(QObject *parent) : QObject(parent)
void FileReader::getTextContent(QString path, QString &textContent)
{
//获取所有文件内容
//先分类
QString type =FileUtils::getMimetype(path,true);
if(type == "application/zip")
FileUtils::getDocxTextContent(path,textContent);
else if(type == "text/plain")
FileUtils::getTxtContent(path,textContent);
QMimeType type = FileUtils::getMimetype(path);
QString name = type.name();
QFileInfo file(path);
QString strsfx = file.suffix();
if(name== "application/zip")
{
if(strsfx.endsWith( "docx"))
FileUtils::getDocxTextContent(path,textContent);
if(strsfx.endsWith( "pptx"))
FileUtils::getPptxTextContent(path,textContent);
if(strsfx.endsWith( "xlsx"))
FileUtils::getXlsxTextContent(path,textContent);
}
else if(name == "text/plain")
{
if(strsfx.endsWith( "txt"))
FileUtils::getTxtContent(path,textContent);
}
else if(type.inherits("application/msword") || type.name() == "application/x-ole-storage")
{
if (strsfx.endsWith("doc") || strsfx.endsWith("dot") || strsfx.endsWith("wps") || strsfx.endsWith("ppt") ||
strsfx.endsWith("pps") ||strsfx.endsWith("dps") || strsfx.endsWith("et") || strsfx.endsWith("xls"))
{
KBinaryParser searchdata;
searchdata.RunParser(path,textContent);
}
}
else if(name == "application/pdf")
{
if(strsfx.endsWith( "pdf"))
FileUtils::getPdfTextContent(path,textContent);
}
else
{
qWarning()<<"Unsupport format:["<<path<<"]["<<type.name()<<"]";
}
return;
}

View File

@ -21,12 +21,14 @@
#define FILEREADER_H
#include <QObject>
#include <QFileInfo>
class FileReader : public QObject
{
Q_OBJECT
public:
explicit FileReader(QObject *parent = nullptr);
~FileReader()=default;
static void getTextContent(QString path, QString &textContent);
};

View File

@ -226,11 +226,12 @@ int FileSearcher::keywordSearchContent(size_t uniqueSymbol, QString keyword, int
}
Xapian::Query FileSearcher::creatQueryForFileSearch(QString keyword, Xapian::Database &db)
{
// Xapian::QueryParser qp;
// qp.set_default_op(Xapian::Query::OP_PHRASE);
// qp.set_database(db);
auto userInput = keyword;
// userInput = userInput.replace(".","").simplified();
// Xapian::QueryParser qp;
// qp.set_default_op(Xapian::Query::OP_PHRASE);
// qp.set_database(db);
auto userInput = keyword.toLower();
// userInput = userInput.replace(".","").simplified();
// userInput = QString(QUrl::toPercentEncoding(userInput)).replace(""," ").simplified();
// std::string queryStr = keyword.replace(".","").replace(" ","").replace(""," ").simplified().toStdString();
// std::string s =db.get_spelling_suggestion(queryStr,10);
@ -238,7 +239,7 @@ Xapian::Query FileSearcher::creatQueryForFileSearch(QString keyword, Xapian::Dat
// qDebug()<<"queryStr!"<<QString::fromStdString(queryStr);
//Creat a query
// Xapian::Query queryPhrase = qp.parse_query(queryStr,Xapian::QueryParser::FLAG_PHRASE);
// Xapian::Query queryPhrase = qp.parse_query(userInput.toStdString(),Xapian::QueryParser::FLAG_PHRASE|Xapian::QueryParser::FLAG_SYNONYM);
std::vector<Xapian::Query> v;
for(int i=0;i<userInput.size();i++)
{

View File

@ -28,8 +28,8 @@
#include <QQueue>
#include <QPair>
#include <QMutex>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString()
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
class FileSearcher : public QObject

View File

@ -35,8 +35,8 @@ FirstIndex::FirstIndex(const QString& path) : Traverse_BFS(path)
qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus;
qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus;
if (indexDataBaseStatus == "" || contentIndexDataBaseStatus == ""){
/* || contentIndexDataBaseStatus == ""*/
if (indexDataBaseStatus == ""){
this->bool_dataBaseExist = false;
}
else{
@ -74,15 +74,14 @@ FirstIndex::~FirstIndex()
void FirstIndex::DoSomething(const QFileInfo& fileInfo){
// qDebug() << "there are some shit here"<<fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0");
this->q_index->enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0"));
for (auto i : this->targetFileTypeVec){
if (fileInfo.fileName().endsWith(i)){
this->q_content_index->enqueue(fileInfo.absoluteFilePath());
}
this->q_index->enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0"));
if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
this->q_content_index->enqueue(fileInfo.absoluteFilePath());
}
}
void FirstIndex::run(){
QTime t1 = QTime::currentTime();
int fifo_fd;
char buffer[2];
@ -120,7 +119,9 @@ void FirstIndex::run(){
}
}
else{
p_indexGenerator = IndexGenerator::getInstance(false,this);
// p_indexGenerator = IndexGenerator::getInstance(false,this);
p_indexGenerator = IndexGenerator::getInstance(true,this);
}
QSemaphore sem(5);
QMutex mutex1, mutex2, mutex3;
@ -134,21 +135,40 @@ void FirstIndex::run(){
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
this->Traverse();
FileUtils::_max_index_count = this->q_index->length();
qDebug()<<"max_index_count:"<<FileUtils::_max_index_count;
sem.release(5);
});
QtConcurrent::run([&](){
sem.acquire(2);
mutex2.unlock();
qDebug() << "index start;";
this->p_indexGenerator->creatAllIndex(this->q_index);
QQueue<QVector<QString>>* tmp = new QQueue<QVector<QString>>();
while (!this->q_index->empty()) {
for (size_t i = 0; (i < 8192) && (!this->q_index->empty()); ++i){
tmp->enqueue(this->q_index->dequeue());
}
this->p_indexGenerator->creatAllIndex(tmp);
tmp->clear();
}
// this->p_indexGenerator->setSynonym();
delete tmp;
qDebug() << "index end;";
sem.release(2);
});
QtConcurrent::run([&](){
sem.acquire(2);
mutex3.unlock();
qDebug() << "content index start;";
this->p_indexGenerator->creatAllIndex(this->q_content_index);
QQueue<QString>* tmp = new QQueue<QString>();
qDebug()<<"q_content_index:"<<q_content_index->size();
while (!this->q_content_index->empty()) {
// for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){
for (size_t i = 0; (i < 30) && (!this->q_content_index->empty()); ++i){
tmp->enqueue(this->q_content_index->dequeue());
}
this->p_indexGenerator->creatAllIndex(tmp);
tmp->clear();
}
delete tmp;
qDebug() << "content index end;";
sem.release(2);
});
@ -169,6 +189,7 @@ void FirstIndex::run(){
if (p_indexGenerator)
delete p_indexGenerator;
p_indexGenerator = nullptr;
GlobalSettings::getInstance()->forceSync();
::_exit(0);
}
else if(pid < 0)
@ -182,12 +203,17 @@ void FirstIndex::run(){
}
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "2");
int retval = write(fifo_fd, buffer, strlen(buffer));
if(retval == -1)
{
qWarning("write error\n");
}
qDebug("write data ok!\n");
QTime t2 = QTime::currentTime();
qWarning() << t1;
qWarning() << t2;
return;
}

View File

@ -62,14 +62,25 @@ private:
//test
QQueue<QVector<QString>>* q_index;
QQueue<QString>* q_content_index;
const QVector<QString> targetFileTypeVec ={
// QString(".doc"),
QString(".docx"),
// QString(".ppt"),
// QString(".pptx"),
// QString(".xls"),
// QString(".xlsx"),
QString(".txt")};
const QMap<QString, bool> targetFileTypeMap = {
std::map<QString, bool>::value_type("doc", true),
std::map<QString, bool>::value_type("docx", true),
std::map<QString, bool>::value_type("ppt", true),
std::map<QString, bool>::value_type("pptx", true),
std::map<QString, bool>::value_type("xls", true),
std::map<QString, bool>::value_type("xlsx", true),
std::map<QString, bool>::value_type("txt", true),
std::map<QString, bool>::value_type("dot", true),
std::map<QString, bool>::value_type("wps", true),
std::map<QString, bool>::value_type("pps", true),
std::map<QString, bool>::value_type("dps", true),
std::map<QString, bool>::value_type("et", true),
std::map<QString, bool>::value_type("pdf", true)
};
//xapian will auto commit per 10,000 changes, donnot change it!!!
const size_t u_send_length = 8192;
};
#endif // FIRSTINDEX_H

View File

@ -33,8 +33,8 @@
#include <QStandardPaths>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString()
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
static IndexGenerator *global_instance = nullptr;
QMutex IndexGenerator::m_mutex;
@ -63,9 +63,13 @@ bool IndexGenerator::setIndexdataPath()
bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
{
// FileUtils::_index_status |= 0x1;
// qDebug() << messageList->size();
HandlePathList(messageList);
if (_doc_list_path == NULL){
return false;
}
qDebug()<<"begin creatAllIndex";
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1");
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
try
{
// m_indexer = new Xapian::TermGenerator();
@ -74,14 +78,15 @@ bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
// m_indexer->set_flags(Xapian::TermGenerator::FLAG_SPELLING);
// m_indexer.set_stemming_strategy(Xapian::TermGenerator::STEM_SOME);
int count =0;
// int count =0;
for (auto i : *_doc_list_path){
insertIntoDatabase(i);
if(++count > 8999){
count = 0;
m_database_path->commit();
}
// if(++count > 8999){
// count = 0;
// m_database_path->commit();
// }
}
m_database_path->commit();
}
@ -107,7 +112,11 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
// FileUtils::_index_status |= 0x2;
HandlePathList(messageList);
qDebug()<<"begin creatAllIndex for content";
if (_doc_list_content == NULL){
return false;
}
int size = _doc_list_content->size();
qDebug()<<"begin creatAllIndex for content"<<size;
if(!size == 0)
{
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"0");
@ -144,15 +153,28 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent)
{
if(rebuild)
QDir database(QString::fromStdString(INDEX_PATH));
if(database.exists())
{
QDir database(QString::fromStdString(INDEX_PATH));
if(database.exists())
database.removeRecursively();
database.setPath(QString::fromStdString(CONTENT_INDEX_PATH));
if(database.exists())
database.removeRecursively();
if(rebuild)
qDebug()<<"remove"<<database.removeRecursively();
}
else
{
qDebug()<<"create index path"<<database.mkpath(QString::fromStdString(INDEX_PATH));
}
database.setPath(QString::fromStdString(CONTENT_INDEX_PATH));
if(database.exists())
{
if(rebuild)
qDebug()<<"remove"<<database.removeRecursively();
}
else
{
qDebug()<<"create content index path"<<database.mkpath(QString::fromStdString(CONTENT_INDEX_PATH));
}
m_database_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
}
@ -247,8 +269,8 @@ void IndexGenerator::HandlePathList(QQueue<QVector<QString>> *messageList)
// delete constructer;
// constructer = nullptr;
qDebug()<<_doc_list_path->size();
// qDebug()<<_doc_list_path->size();
// qWarning() << _doc_list_path;
// QList<Document> docList = future.results();
// m_doc_list_path = new QList<Document>(docList);
// m_doc_list_path = std::move(future.results());
@ -266,7 +288,8 @@ void IndexGenerator::HandlePathList(QQueue<QString> *messageList)
ChineseSegmentation::getInstance();
ConstructDocumentForContent *constructer;
QThreadPool pool;
pool.setMaxThreadCount(((QThread::idealThreadCount() - 1) / 2) + 1);
// pool.setMaxThreadCount(((QThread::idealThreadCount() - 1) / 2) + 1);
pool.setMaxThreadCount(1);
pool.setExpiryTimeout(100);
while(!messageList->isEmpty())
{
@ -285,7 +308,9 @@ void IndexGenerator::HandlePathList(QQueue<QString> *messageList)
// QList<Document> docList = future.results();
// m_doc_list_content = new QList<Document>(docList);
qDebug()<<_doc_list_content->size();
// qDebug()<<_doc_list_content->size();
// QList<Document> docList = future.results();
// m_doc_list_content = new QList<Document>(docList);
// m_doc_list_content = std::move(future.results());
@ -465,6 +490,71 @@ QStringList IndexGenerator::IndexSearch(QString indexText)
return searchResult;
}
//void IndexGenerator::setSynonym()
//{
// try
// {
// m_database_path->add_synonym("a","A");
// m_database_path->add_synonym("b","B");
// m_database_path->add_synonym("c","C");
// m_database_path->add_synonym("d","D");
// m_database_path->add_synonym("e","A");
// m_database_path->add_synonym("f","F");
// m_database_path->add_synonym("g","G");
// m_database_path->add_synonym("h","H");
// m_database_path->add_synonym("i","I");
// m_database_path->add_synonym("j","J");
// m_database_path->add_synonym("k","K");
// m_database_path->add_synonym("l","L");
// m_database_path->add_synonym("m","M");
// m_database_path->add_synonym("n","N");
// m_database_path->add_synonym("o","O");
// m_database_path->add_synonym("p","P");
// m_database_path->add_synonym("q","Q");
// m_database_path->add_synonym("r","R");
// m_database_path->add_synonym("s","S");
// m_database_path->add_synonym("t","T");
// m_database_path->add_synonym("u","U");
// m_database_path->add_synonym("v","V");
// m_database_path->add_synonym("w","W");
// m_database_path->add_synonym("x","X");
// m_database_path->add_synonym("y","Y");
// m_database_path->add_synonym("z","Z");
// m_database_path->add_synonym("A","a");
// m_database_path->add_synonym("B","b");
// m_database_path->add_synonym("C","c");
// m_database_path->add_synonym("D","d");
// m_database_path->add_synonym("E","e");
// m_database_path->add_synonym("F","f");
// m_database_path->add_synonym("G","g");
// m_database_path->add_synonym("H","h");
// m_database_path->add_synonym("I","i");
// m_database_path->add_synonym("J","j");
// m_database_path->add_synonym("K","k");
// m_database_path->add_synonym("L","a");
// m_database_path->add_synonym("M","m");
// m_database_path->add_synonym("N","n");
// m_database_path->add_synonym("O","o");
// m_database_path->add_synonym("P","p");
// m_database_path->add_synonym("Q","q");
// m_database_path->add_synonym("R","r");
// m_database_path->add_synonym("S","s");
// m_database_path->add_synonym("T","t");
// m_database_path->add_synonym("U","u");
// m_database_path->add_synonym("V","v");
// m_database_path->add_synonym("W","w");
// m_database_path->add_synonym("X","x");
// m_database_path->add_synonym("Y","y");
// m_database_path->add_synonym("Z","z");
// m_database_path->commit();
// }
// catch(const Xapian::Error &e)
// {
// qWarning() <<QString::fromStdString(e.get_description());
// }
//}
bool IndexGenerator::deleteAllIndex(QStringList *pathlist)
{
QStringList *list = pathlist;

View File

@ -48,6 +48,7 @@ public:
// Q_INVOKABLE void appendDocListPath(Document doc);
//for search test
static QStringList IndexSearch(QString indexText);
void setSynonym();
Q_SIGNALS:
void transactionFinished();
void searchFinish();

View File

@ -7,8 +7,8 @@ HEADERS += \
$$PWD/first-index.h \
$$PWD/index-generator.h \
$$PWD/inotify-index.h \
$$PWD/search-manager.h \
$$PWD/traverse_bfs.h \
$$PWD/file-searcher.h \
$$PWD/ukui-search-qdbus.h
SOURCES += \
@ -18,7 +18,7 @@ SOURCES += \
$$PWD/first-index.cpp \
$$PWD/index-generator.cpp \
$$PWD/inotify-index.cpp \
$$PWD/search-manager.cpp \
$$PWD/traverse_bfs.cpp \
$$PWD/file-searcher.cpp \
$$PWD/ukui-search-qdbus.cpp

View File

@ -19,30 +19,50 @@
*/
#include "inotify-index.h"
#define CREATE_FILE_NAME_INDEX \
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0")); \
IndexGenerator::getInstance()->creatAllIndex(indexQueue); \
indexQueue->clear();
#define CREATE_FILE_CONTENT_INDEX \
if ((!QString(event->name).split(".").isEmpty()) && (true == this->targetFileTypeMap[QString(event->name).split(".").last()])) { \
contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name)); \
IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue); \
contentIndexQueue->clear(); \
break; \
}
#define TRAVERSE_DIR \
QString tmp = currentPath[event->wd] + '/' + event->name; \
QFileInfo fi(tmp); \
if(!fi.isSymLink()){ \
AddWatch(tmp); \
setPath(tmp); \
Traverse(); \
}
#define CREATE_FILE \
CREATE_FILE_NAME_INDEX \
CREATE_FILE_CONTENT_INDEX
InotifyIndex::InotifyIndex(const QString& path) : Traverse_BFS(path)
{
/*-------------ukuisearchdbus Test start-----------------*/
qDebug() << "setInotifyMaxUserWatches start";
UkuiSearchQDBus usQDBus;
usQDBus.setInotifyMaxUserWatches();
qDebug() << "setInotifyMaxUserWatches end";
/*-------------ukuisearchdbus Test End-----------------*/
m_fd = inotify_init();
qDebug() << "m_fd----------->" <<m_fd;
this->AddWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
// this->Traverse();
this->firstTraverse();
}
InotifyIndex::~InotifyIndex()
{
// GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "2");
IndexGenerator::getInstance()->~IndexGenerator();
}
@ -57,7 +77,7 @@ void InotifyIndex::firstTraverse(){
dir.setPath(bfs.dequeue());
list = dir.entryInfoList();
for (auto i : list){
if (i.isDir()){
if (i.isDir() && (!(i.isSymLink()))){
this->AddWatch(i.absoluteFilePath());
bfs.enqueue(i.absoluteFilePath());
}
@ -67,22 +87,16 @@ void InotifyIndex::firstTraverse(){
void InotifyIndex::DoSomething(const QFileInfo& fileInfo){
qDebug() << fileInfo.fileName() << "-------" << fileInfo.absoluteFilePath();
if(fileInfo.isDir()){
if(fileInfo.isDir() && (!fileInfo.isSymLink())){
this->AddWatch(fileInfo.absoluteFilePath());
}
QQueue<QVector<QString> >* tempFile = new QQueue<QVector<QString> >;
tempFile->enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(tempFile);
if (tempFile)
delete tempFile;
for (auto i : this->targetFileTypeVec){
if (fileInfo.fileName().endsWith(i)){
QQueue<QString>* tempContent = new QQueue<QString>;
tempContent->enqueue(fileInfo.absoluteFilePath());
IndexGenerator::getInstance()->creatAllIndex(tempContent);
if (tempContent)
delete tempContent;
}
QQueue<QVector<QString> > tempFile;
tempFile.enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(&tempFile);
if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
QQueue<QString> tmp;
tmp.enqueue(fileInfo.absoluteFilePath());
IndexGenerator::getInstance()->creatAllIndex(&tmp);
}
}
@ -120,7 +134,6 @@ bool InotifyIndex::RemoveWatch(const QString &path){
qDebug() << "remove path error";
// return false;
}
// Q_ASSERT(ret == 0);
// assert(ret == 0);
/*--------------------------------*/
//在此调用删除索引
@ -163,29 +176,13 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
//Create top dir first, traverse it last.
qDebug() << "IN_CREATE";
/*--------------------------------*/
// IndexGenerator::getInstance()->creatAllIndex(QQueue<QVector<QString>>(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0")));
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
indexQueue->clear();
for (auto i : this->targetFileTypeVec){
if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
contentIndexQueue->clear();
break;
}
}
CREATE_FILE
if (event->mask & IN_ISDIR){
AddWatch(currentPath[event->wd] + '/' + event->name);
setPath(currentPath[event->wd] + '/' + event->name);
Traverse();
TRAVERSE_DIR
}
goto next;
}
if ((event->mask & IN_DELETE) | (event->mask & IN_MOVED_FROM)){
qDebug() << "IN_DELETE or IN_MOVED_FROM";
if (event->mask & IN_ISDIR){
@ -196,117 +193,29 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
goto next;
}
if (event->mask & IN_MODIFY){
qDebug() << "IN_MODIFY";
if (!(event->mask & IN_ISDIR)){
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
indexQueue->clear();
for (auto i : this->targetFileTypeVec){
if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
contentIndexQueue->clear();
break;
}
}
CREATE_FILE
}
goto next;
}
if (event->mask & IN_MOVED_TO){
qDebug() << "IN_MOVED_TO";
if (event->mask & IN_ISDIR){
RemoveWatch(currentPath[event->wd] + '/' + event->name);
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
indexQueue->clear();
for (auto i : this->targetFileTypeVec){
if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
contentIndexQueue->clear();
break;
}
}
AddWatch(currentPath[event->wd] + '/' + event->name);
setPath(currentPath[event->wd] + '/' + event->name);
Traverse();
CREATE_FILE
TRAVERSE_DIR
}
else {
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
indexQueue->clear();
for (auto i : this->targetFileTypeVec){
if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
contentIndexQueue->clear();
break;
}
}
CREATE_FILE
}
goto next;
}
// }
// //传创建或移动过来的文件路径
// if((event->mask & IN_CREATE)){
// //添加监视要先序遍历先添加top节点
// if (event->mask & IN_ISDIR){
// AddWatch(currentPath[event->wd] + '/' + event->name);
// this->setPath(currentPath[event->wd] + '/' + event->name);
// Traverse();
// }
// /*--------------------------------*/
//// IndexGenerator::getInstance()->creatAllIndex(QQueue<QVector<QString>>(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0")));
// indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
// IndexGenerator::getInstance()->creatAllIndex(indexQueue);
// indexQueue->clear();
// for (auto i : this->targetFileTypeVec){
// if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
// contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
// IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
// contentIndexQueue->clear();
// break;
// }
// }
// /*--------------------------------*/
// }
// else if((event->mask & IN_DELETE) | (event->mask & IN_MOVED_FROM)){
// if (event->mask & IN_ISDIR){
// RemoveWatch(currentPath[event->wd] + '/' + event->name);
// }
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
// }
// else if((event->mask & IN_MODIFY) | (event->mask & IN_MOVED_TO)){
// if (!(event->mask & IN_ISDIR)){
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
// indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
// IndexGenerator::getInstance()->creatAllIndex(indexQueue);
// indexQueue->clear();
// for (auto i : this->targetFileTypeVec){
// if (QString(currentPath[event->wd] + '/' + event->name).endsWith(i)){
// contentIndexQueue->enqueue(QString(currentPath[event->wd] + '/' + event->name));
// IndexGenerator::getInstance()->creatAllIndex(contentIndexQueue);
// contentIndexQueue->clear();
// break;
// }
// }
// }
// }
/*--------------------------------*/
}
next:
p += sizeof(struct inotify_event) + event->len;
@ -318,12 +227,6 @@ next:
contentIndexQueue = nullptr;
}
/*
* Symbolic Link!!!!!!!!!!!!!!!!!!
* Sysmbolic link to database dir will make a Infinite loop !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* MouseZhangZh
*/
void InotifyIndex::run(){
int fifo_fd;
char buffer[2];
@ -355,6 +258,7 @@ void InotifyIndex::run(){
for (;;) { /* Read events forever */
read:
memset(buf, 0x00, BUF_LEN);
numRead = read(m_fd, buf, BUF_LEN);
if (numRead == -1){
@ -401,7 +305,7 @@ fork:
int rc;
timeval* read_timeout = (timeval*)malloc(sizeof(timeval));
read_timeout->tv_sec = 60;
read_timeout->tv_sec = 40;
read_timeout->tv_usec = 0;
for(;;)
{
@ -419,9 +323,11 @@ fork:
qDebug() << "select timeout!";
::free(read_timeout);
IndexGenerator::getInstance()->~IndexGenerator();
GlobalSettings::getInstance()->forceSync();
::_exit(0);
}else{
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0");
memset(buf, 0x00, BUF_LEN);
numRead = read(m_fd, buf, BUF_LEN);
if (numRead == -1){
printf("\033[1;31;40mread event error\033[0m\n");
@ -433,30 +339,6 @@ fork:
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "2");
}
}
// QTimer* liveTime = new QTimer();
// //restart inotify-index proccess per minute
// liveTime->setInterval(60000);
// liveTime->start();
//I don't know how to use QTimer, wish someone can fix it!
//MouseZhangZh
// connect(liveTime, &QTimer::timeout, [ = ](){
//// ::_exit(0);
// *b_timeout = 1;
// });
// for (;;){
// qDebug() << "liveTime->remainingTime():" << liveTime->remainingTime();
// numRead = read(m_fd, buf, BUF_LEN);
// this->eventProcess(buf, numRead);
// if (liveTime->remainingTime() < 1){
// qDebug() << "liveTime->remainingTime():" << liveTime->remainingTime();
// ::_exit(0);
// }
// }
}
else if (pid > 0){
memset(buf, 0x00, BUF_LEN);

View File

@ -60,14 +60,23 @@ private:
int m_fd;
QMap<int, QString> currentPath;
const QVector<QString> targetFileTypeVec ={
// QString(".doc"),
QString(".docx"),
// QString(".ppt"),
// QString(".pptx"),
// QString(".xls"),
// QString(".xlsx"),
QString(".txt")};
const QMap<QString, bool> targetFileTypeMap = {
std::map<QString, bool>::value_type("doc", true),
std::map<QString, bool>::value_type("docx", true),
std::map<QString, bool>::value_type("ppt", true),
std::map<QString, bool>::value_type("pptx", true),
std::map<QString, bool>::value_type("xls", true),
std::map<QString, bool>::value_type("xlsx", true),
std::map<QString, bool>::value_type("txt", true),
std::map<QString, bool>::value_type("dot", true),
std::map<QString, bool>::value_type("wps", true),
std::map<QString, bool>::value_type("pps", true),
std::map<QString, bool>::value_type("dps", true),
std::map<QString, bool>::value_type("et", true),
std::map<QString, bool>::value_type("pdf", true)
};
};
#endif // INOTIFYINDEX_H

View File

@ -6009,7 +6009,7 @@ zhòng 仲
pǐ,pí,bì 仳
wò 仴
wǔ 仵
jiàn,móu
jiàn 件
jià,jiè,jie 价
yǎo,fó 仸
fēng 仹
@ -11099,7 +11099,7 @@ tuō,chǐ 拖
jū,gōu,jǔ,jú 拘
zhuō 拙
pàn,biàn,fèn,fān,pīn 拚
zhāo,qiáo,sháo
zhāo 招
bài 拜
bài 拝
dǐ 拞
@ -12449,7 +12449,7 @@ guā,tiǎn,kuò 栝
kān 栞
bēn,bīng 栟
rěn 栠
xiào,jiào,jiǎo,qiāo
xiào,jiào,jiǎo 校
bǎi 栢
rěn 栣
bìng 栤

View File

@ -6009,14 +6009,14 @@ zhong 仲
pi,bi 仳
wo 仴
wu 仵
mou,jian 件
jian 件
jie,jia 价
fo,yao 仸
feng 仹
cang 仺
ren,lin 任
wang 仼
bin,fen 份
fen 份
di 仾
fang,pang 仿
zhong 伀
@ -6221,7 +6221,7 @@ xu,shu 俆
guang 俇
ku 俈
wu 俉
dun,jun,shun 俊
jun 俊
yi 俋
fu 俌
liang,lang 俍
@ -11099,7 +11099,7 @@ niu,yu,ao 拗
ju,gou 拘
zhuo 拙
pin,fan,pan,fen,bian 拚
shao,qiao,zhao 招
zhao 招
bai 拜
bai 拝
di 拞
@ -11420,7 +11420,7 @@ zhi 搘
nuo,nou,nu 搙
la,xie,xian 搚
lian,jian 搛
shao,xiao,sou 搜
sou 搜
qiu 搝
qiao,gao,kao 搞
xian 搟
@ -12449,7 +12449,7 @@ kuo,tian,gua 栝
kan 栞
bing,ben 栟
ren 栠
jiao,qiao,xiao 校
jiao,xiao 校
bai 栢
ren 栣
bing 栤

View File

@ -0,0 +1,440 @@
/*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: zhangpengfei <zhangpengfei@kylinos.cn>
*
*/
#include "search-manager.h"
size_t SearchManager::uniqueSymbol1 = 0;
size_t SearchManager::uniqueSymbol2 = 0;
size_t SearchManager::uniqueSymbol3 = 0;
QMutex SearchManager::m_mutex1;
QMutex SearchManager::m_mutex2;
QMutex SearchManager::m_mutex3;
SearchManager::SearchManager(QObject *parent) : QObject(parent)
{
m_pool.setMaxThreadCount(2);
m_pool.setExpiryTimeout(1000);
}
SearchManager::~SearchManager()
{
}
int SearchManager::getCurrentIndexCount()
{
try
{
Xapian::Database db(INDEX_PATH);
return db.get_doccount();
}
catch(const Xapian::Error &e)
{
qWarning() <<QString::fromStdString(e.get_description());
return 0;
}
}
void SearchManager::onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,
QQueue<QPair<QString,QStringList>> *searchResultContent)
{
m_mutex1.lock();
++uniqueSymbol1;
m_mutex1.unlock();
m_mutex2.lock();
++uniqueSymbol2;
m_mutex2.unlock();
m_mutex3.lock();
++uniqueSymbol3;
m_mutex3.unlock();
FileSearch *filesearch;
filesearch = new FileSearch(searchResultFile,uniqueSymbol1,keyword,"0",1,0,5);
m_pool.start(filesearch);
FileSearch *dirsearch;
dirsearch = new FileSearch(searchResultDir,uniqueSymbol2,keyword,"1",1,0,5);
m_pool.start(dirsearch);
FileContentSearch *contentSearch;
contentSearch = new FileContentSearch(searchResultContent,uniqueSymbol3,keyword,0,5);
m_pool.start(contentSearch);
return;
}
bool SearchManager::isBlocked(QString &path)
{
QStringList blockList = GlobalSettings::getInstance()->getBlockDirs();
for(QString i : blockList)
{
if(path.startsWith(i.prepend("/")))
return true;
}
return false;
}
FileSearch::FileSearch(QQueue<QString> *searchResult,size_t uniqueSymbol, QString keyword, QString value, unsigned slot, int begin, int num)
{
this->setAutoDelete(true);
m_search_result = searchResult;
m_uniqueSymbol = uniqueSymbol;
m_keyword = keyword;
m_value = value;
m_slot = slot;
m_begin = begin;
m_num = num;
}
FileSearch::~FileSearch()
{
m_search_result = nullptr;
}
void FileSearch::run()
{
if(!m_search_result->isEmpty())
m_search_result->clear();
int resultCount = 0;
int total = 0;
while(total < 100)
{
resultCount = keywordSearchfile();
if(resultCount == 0 || resultCount == -1)
break;
total += resultCount;
m_begin += m_num;
}
return;
}
int FileSearch::keywordSearchfile()
{
try
{
qDebug() << "--keywordSearchfile start--";
Xapian::Database db(INDEX_PATH);
Xapian::Query query = creatQueryForFileSearch(db);
Xapian::Enquire enquire(db);
Xapian::Query queryFile;
if(!m_value.isEmpty())
{
std::string slotValue = m_value.toStdString();
Xapian::Query queryValue = Xapian::Query(Xapian::Query::OP_VALUE_RANGE,m_slot,slotValue,slotValue);
queryFile = Xapian::Query(Xapian::Query::OP_AND,query,queryValue);
}
else
{
queryFile = query;
}
qDebug() << "keywordSearchfile:"<<QString::fromStdString(queryFile.get_description());
enquire.set_query(queryFile);
Xapian::MSet result = enquire.get_mset(m_begin, m_num);
int resultCount = result.size();
qDebug()<< "keywordSearchfile results count=" <<resultCount;
if(resultCount == 0)
return 0;
if(getResult(result) == -1)
return -1;
qDebug()<< "--keywordSearchfile finish--";
return resultCount;
}
catch(const Xapian::Error &e)
{
qWarning() <<QString::fromStdString(e.get_description());
qDebug()<< "--keywordSearchfile finish--";
return -1;
}
}
Xapian::Query FileSearch::creatQueryForFileSearch(Xapian::Database &db)
{
auto userInput = m_keyword.toLower();
std::vector<Xapian::Query> v;
for(int i=0;i<userInput.size();i++)
{
v.push_back(Xapian::Query(QUrl::toPercentEncoding(userInput.at(i)).toStdString()));
// qDebug()<<QString::fromStdString(Xapian::Query(QString(userInput.at(i)).toStdString()).get_description());
}
Xapian::Query queryPhrase =Xapian::Query(Xapian::Query::OP_PHRASE, v.begin(), v.end());
return queryPhrase;
}
int FileSearch::getResult(Xapian::MSet &result)
{
for (auto it = result.begin(); it != result.end(); ++it)
{
Xapian::Document doc = it.get_document();
std::string data = doc.get_data();
Xapian::weight docScoreWeight = it.get_weight();
Xapian::percent docScorePercent = it.get_percent();
QString path = QString::fromStdString(data);
std::string().swap(data);
if(SearchManager::isBlocked(path))
continue;
QFileInfo info(path);
if(!info.exists())
{
// pathTobeDelete->append(QString::fromStdString(data));
qDebug()<<path<<"is not exist!!";
}
else
{
switch (m_value.toInt())
{
case 1:
SearchManager::m_mutex1.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbol2)
{
m_search_result->enqueue(path);
SearchManager::m_mutex1.unlock();
}
else
{
SearchManager::m_mutex1.unlock();
return -1;
}
break;
case 0:
SearchManager::m_mutex2.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbol1)
{
m_search_result->enqueue(path);
SearchManager::m_mutex2.unlock();
}
else
{
SearchManager::m_mutex2.unlock();
return -1;
}
break;
default:
break;
}
// searchResult.append(path);
}
qDebug()<< "doc="<< path << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent;
}
// if(!pathTobeDelete->isEmpty())
// deleteAllIndex(pathTobeDelete)
return 0;
}
FileContentSearch::FileContentSearch(QQueue<QPair<QString,QStringList>> *searchResult, size_t uniqueSymbol, QString keyword, int begin, int num)
{
this->setAutoDelete(true);
m_search_result = searchResult;
m_uniqueSymbol = uniqueSymbol;
m_keyword = keyword;
m_begin = begin;
m_num = num;
}
FileContentSearch::~FileContentSearch()
{
m_search_result = nullptr;
}
void FileContentSearch::run()
{
if(!m_search_result->isEmpty())
m_search_result->clear();
int resultCount = 0;
int total = 0;
while(total<50)
{
resultCount = keywordSearchContent();
if(resultCount == 0 || resultCount == -1)
break;
total += resultCount;
m_begin += m_num;
}
return;
}
int FileContentSearch::keywordSearchContent()
{
try
{
qDebug()<<"--keywordSearchContent search start--";
Xapian::Database db(CONTENT_INDEX_PATH);
Xapian::Enquire enquire(db);
Xapian::QueryParser qp;
qp.set_default_op(Xapian::Query::OP_AND);
qp.set_database(db);
/*
::friso::ResultMap ret;
::friso::FrisoSegmentation::getInstance()->callSegement(ret, keyword.toLocal8Bit().data());
for (::friso::ResultMap::iterator it_map = ret.begin(); it_map != ret.end(); ++it_map){
target_str += it_map->first;
target_str += " ";
it_map->second.first.clear();
::std::vector<size_t>().swap(it_map->second.first);
}
ret.clear();
ret.erase(ret.begin(), ret.end());
::friso::ResultMap().swap(ret);
*/
QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword);
//Creat a query
std::string words;
for(int i=0;i<sKeyWord.size();i++)
{
words.append(sKeyWord.at(i).word).append(" ");
}
Xapian::Query query = qp.parse_query(words);
// Xapian::Query query = qp.parse_query(keyword.toStdString());
// QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(keyword);
// //Creat a query
// std::string words;
// for(int i=0;i<sKeyWord.size();i++)
// {
// words.append(sKeyWord.at(i).word).append(" ");
// }
// Xapian::Query query = qp.parse_query(words);
// std::vector<Xapian::Query> v;
// for(int i=0;i<sKeyWord.size();i++)
// {
// v.push_back(Xapian::Query(sKeyWord.at(i).word));
// qDebug()<<QString::fromStdString(sKeyWord.at(i).word);
// }
// Xapian::Query queryPhrase =Xapian::Query(Xapian::Query::OP_AND, v.begin(), v.end());
qDebug()<<"keywordSearchContent:"<<QString::fromStdString(query.get_description());
enquire.set_query(query);
Xapian::MSet result = enquire.get_mset(m_begin, m_num);
int resultCount = result.size();
if(result.size() == 0)
return 0;
qDebug()<< "keywordSearchContent results count=" <<resultCount;
if(getResult(result,words) == -1)
return -1;
qDebug()<< "--keywordSearchContent search finish--";
return resultCount;
}
catch(const Xapian::Error &e)
{
qWarning() <<QString::fromStdString(e.get_description());
qDebug()<< "--keywordSearchContent search finish--";
return -1;
}
}
int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord)
{
for (auto it = result.begin(); it != result.end(); ++it)
{
Xapian::Document doc = it.get_document();
std::string data = doc.get_data();
double docScoreWeight = it.get_weight();
Xapian::percent docScorePercent = it.get_percent();
QString path = QString::fromStdString(doc.get_value(1));
if(SearchManager::isBlocked(path))
continue;
QFileInfo info(path);
if(!info.exists())
{
// pathTobeDelete->append(QString::fromStdString(data));
qDebug()<<path<<"is not exist!!";
continue;
}
// Construct snippets containing keyword.
QStringList snippets;
// snippets.append(QString::fromStdString( result.snippet(doc.get_data(),400)));
// qWarning()<<QString::fromStdString(s);
auto term = doc.termlist_begin();
std::string wordTobeFound = QString::fromStdString(keyWord).section(" ",0,0).toStdString();
int size = wordTobeFound.length();
term.skip_to(wordTobeFound);
int count =0;
for(auto pos = term.positionlist_begin();pos != term.positionlist_end()&&count < 6;++pos)
{
std::string s = data.substr((*pos < 60)? 0: (*pos - 60) , size + 120);
QString snippet = QString::fromStdString(s);
if(snippet.size() > 6 + QString::fromStdString(keyWord).size())
snippet.replace(0,3,"...").replace(snippet.size()-3,3,"...");
else
snippet.append("...").prepend("...");
snippets.append(snippet);
QString().swap(snippet);
std::string().swap(s);
++count;
}
std::string().swap(data);
// for(QString i : QString::fromStdString(keyWord).split(" ",QString::SkipEmptyParts))
// {
// std::string word = i.toStdString();
// term.skip_to(word);
// int size = word.size();
// auto pos = term.positionlist_begin();
// std::string s = data.substr((*pos < 60)? 0: (*pos - 60) , size + 120);
// QString snippet = QString::fromStdString(s);
// snippet.replace(0,3,"...").replace(snippet.size()-3,3,"...");
// snippets.append(snippet);
// std::string().swap(word);
// std::string().swap(s);
// QString().swap(snippet);
// }
SearchManager::m_mutex3.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbol3)
{
m_search_result->enqueue(qMakePair(path,snippets));
SearchManager::m_mutex3.unlock();
snippets.clear();
QStringList().swap(snippets);
}
else
{
SearchManager::m_mutex3.unlock();
return -1;
}
// searchResult.insert(path,snippets);
qDebug()<< "path="<< path << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent;
}
// // if(!pathTobeDelete->isEmpty())
// // deleteAllIndex(pathTobeDelete)
return 0;
}

View File

@ -0,0 +1,136 @@
/*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: zhangpengfei <zhangpengfei@kylinos.cn>
*
*/
#ifndef SEARCHMANAGER_H
#define SEARCHMANAGER_H
#include <QObject>
#include <xapian.h>
#include <QStandardPaths>
#include <QVector>
#include <QMap>
#include <QQueue>
#include <QPair>
#include <QMutex>
#include <thread>
#include <QRunnable>
#include <QThreadPool>
#include <QFileInfo>
#include <QDebug>
#include <QtConcurrent/QtConcurrent>
#include <QThread>
#include <QUrl>
#include "file-utils.h"
#include "global-settings.h"
#include "chinese-segmentation.h"
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
class SearchManager : public QObject
{
friend class FileSearch;
friend class FileContentSearch;
Q_OBJECT
public:
explicit SearchManager(QObject *parent = nullptr);
~SearchManager();
static int getCurrentIndexCount();
static size_t uniqueSymbol1;
static size_t uniqueSymbol2;
static size_t uniqueSymbol3;
static QMutex m_mutex1;
static QMutex m_mutex2;
static QMutex m_mutex3;
public Q_SLOTS:
void onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent);
Q_SIGNALS:
void resultFile(QQueue<QString> *);
void resultDir(QQueue<QString> *);
void resultContent(QQueue<QPair<QString,QStringList>> *);
private:
// int keywordSearchfile(size_t uniqueSymbol, QString keyword, QString value,unsigned slot = 1,int begin = 0, int num = 20);
// int keywordSearchContent(size_t uniqueSymbol, QString keyword, int begin = 0, int num = 20);
/**
* @brief SearchManager::creatQueryForFileSearch
* This part shall be optimized frequently to provide a more stable search function.
* @param keyword
* @param db
* @return Xapian::Query
*/
// Xapian::Query creatQueryForFileSearch(QString keyword, Xapian::Database &db);
// Xapian::Query creatQueryForContentSearch(QString keyword, Xapian::Database &db);
// int getResult(size_t uniqueSymbol, Xapian::MSet &result, QString value);
// int getContentResult(size_t uniqueSymbol, Xapian::MSet &result,std::string &keyWord);
static bool isBlocked(QString &path);
// QQueue<QString> *m_search_result_file = nullptr;
// QQueue<QString> *m_search_result_dir = nullptr;
// QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr;
QThreadPool m_pool;
};
class FileSearch : public QRunnable
{
public:
explicit FileSearch(QQueue<QString> *searchResult,size_t uniqueSymbol, QString keyword, QString value,unsigned slot = 1,int begin = 0, int num = 20);
~FileSearch();
protected:
void run();
private:
int keywordSearchfile();
Xapian::Query creatQueryForFileSearch(Xapian::Database &db);
int getResult(Xapian::MSet &result);
QQueue<QString> *m_search_result = nullptr;
QString m_value;
unsigned m_slot = 1;
size_t m_uniqueSymbol;
QString m_keyword;
int m_begin = 0;
int m_num = 20;
};
class FileContentSearch : public QRunnable
{
public:
explicit FileContentSearch(QQueue<QPair<QString,QStringList>> *searchResult,size_t uniqueSymbol, QString keyword, int begin = 0, int num = 20);
~FileContentSearch();
protected:
void run();
private:
int keywordSearchContent();
int getResult(Xapian::MSet &result,std::string &keyWord);
QQueue<QPair<QString,QStringList>> *m_search_result = nullptr;
size_t m_uniqueSymbol;
QString m_keyword;
int m_begin = 0;
int m_num = 20;
};
#endif // SEARCHMANAGER_H

View File

@ -30,13 +30,14 @@ void Traverse_BFS::Traverse(){
bfs.enqueue(this->path);
QFileInfoList list;
QDir dir;
// QDir::Hidden
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
dir.setSorting(QDir::DirsFirst);
while (!bfs.empty()) {
dir.setPath(bfs.dequeue());
list = dir.entryInfoList();
for (auto i : list){
if (i.isDir()){
if (i.isDir() && (!(i.isSymLink()))){
bfs.enqueue(i.absoluteFilePath());
}
DoSomething(i);

View File

@ -44,5 +44,5 @@ void UkuiSearchQDBus::setInotifyMaxUserWatches()
// sysctl
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2");
// /etc/sysctl.conf
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3");
// this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3");
}

View File

@ -21,7 +21,7 @@
#define LIBSEARCH_H
#include "libsearch_global.h"
#include "index/file-searcher.h"
#include "index/search-manager.h"
#include "appsearch/app-match.h"
#include "settingsearch/setting-match.h"
#include "file-utils.h"

View File

@ -5,7 +5,7 @@ TARGET = ukui-search
TEMPLATE = lib
DEFINES += LIBSEARCH_LIBRARY
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 gsettings-qt
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 gsettings-qt poppler-qt5
CONFIG += c++11 link_pkgconfig no_keywords lrelease
@ -22,6 +22,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
include(index/index.pri)
include(parser/parser.pri))
include(appsearch/appsearch.pri)
include(settingsearch/settingsearch.pri))
@ -68,8 +69,5 @@ unix {
INCLUDEPATH += $$PWD/../libchinese-segmentation
DEPENDPATH += $$PWD/../libchinese-segmentation
#INCLUDEPATH += $$PWD/../libfriso
#DEPENDPATH += $$PWD/../libfriso
#DISTFILES += \
# ../translations/libsearch/libukui-search_zh_CN.ts

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
#ifndef SEARCHHELPER_H
#define SEARCHHELPER_H
#include <QtCore>
#include <QtConcurrent/QtConcurrent>
#define ULONG unsigned long
#define UCHAR unsigned char
#define USHORT unsigned short
typedef enum
{
Word = 0,
Excel,
Ppt
}TYPE;
/* Property Set Storage */
typedef struct pps_tag
{
ULONG ulSB;
ULONG ulSize;
} ppsTag;
typedef struct pps_info_tag
{
ppsTag tWordDocument; /* Text stream */
ppsTag tWorkBook;
ppsTag tPPTDocument;
ppsTag tData; /* Data stream */
ppsTag tTable; /* Table stream */
ppsTag tSummaryInfo; /* Summary Information */
ppsTag tDocSummaryInfo;/* Document Summary Information */
ppsTag t0Table; /* Table 0 stream */
ppsTag t1Table; /* Table 1 stream */
ppsTag tCurrentUser;
TYPE type;
} ppsInfoType;
/* Private type for Property Set Storage entries */
typedef struct pps_entry_tag
{
ULONG ulNext;
ULONG ulPrevious;
ULONG ulDir;
ULONG ulSB;
ULONG ulSize;
int iLevel;
char szName[32];
UCHAR ucType;
} ppsEntryType;
/* Excel Record Struct*/
typedef struct excelRecord
{
excelRecord()
{
usLen = 0;
usRichLen = 0;
ulWLen = 0;
bUni = false;
}
ushort usLen;
ushort usRichLen;
ulong ulWLen;
bool bUni;
} excelRecord;
typedef struct readDataParam
{
readDataParam()
{
ulStBlk = 0;
pFile = NULL;
ulBBd = NULL;
tBBdLen = 0;
usBlkSize = 0;
}
ulong ulStBlk;
FILE *pFile;
ulong *ulBBd;
size_t tBBdLen;
ushort usBlkSize;
}rdPara;
class KBinaryParser :public QObject
{
Q_OBJECT
public:
KBinaryParser(QObject *parent=0);
~KBinaryParser();
public:
bool RunParser(QString strFile,QString &content);
private:
bool bGetPPS(FILE *pFile,
const ULONG *aulRootList, size_t tRootListLen, ppsInfoType *pPPS);
int readData(rdPara &readParam, uchar *aucBuffer, ulong ulOffset, size_t tToRead);
int InitDocOle(FILE *pFile,long lFilesize,QString &content);
bool read8DocText(FILE *pFile, const ppsInfoType *pPPS,
const ULONG *aulBBD, size_t tBBDLen,
const ULONG *aulSBD, size_t tSBDLen,
const UCHAR *aucHeader,QString &content);
int readSSTRecord(readDataParam &rdParam, ppsInfoType, ulong &ulOff, ushort usPartLen,QString &content);
int read8BiffRecord(uchar uFlag, ulong ulOff, ulong &ulNext, readDataParam &rdParam, excelRecord &eR);
ULONG readPPtRecord(FILE* pFile, ppsInfoType* PPS_info, ULONG* aulBBD,
size_t tBBDLen, ULONG ulPos,QString &content);
QString m_strFileName;
};
#endif // SEARCHHELPER_H

25
libsearch/parser/common.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef COMMON_H
#define COMMON_H
#include <QtCore>
#include <QtConcurrent/QtConcurrent>
#define SERVER "Everything"
#define LOG(a) \
//qWarning() << a;
#define REHASH(a) \
if (sl_minus_1 < (int)sizeof(int) * CHAR_BIT) \
hashHaystack -= (a) << sl_minus_1; \
hashHaystack <<= 1
void* xmalloc(size_t tSize);
void* xcalloc(size_t tNmemb, size_t tSize);
void* xrealloc(void *pvArg, size_t tSize);
void* xfree(void *pvArg);
#endif // COMMON_H

View File

@ -0,0 +1,9 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/common.h \
$$PWD/binary-parser.h
SOURCES += \
$$PWD/binary-parser.cpp

View File

@ -33,7 +33,6 @@ SettingsMatch::SettingsMatch(QObject *parent) : QObject(parent)
*/
QStringList SettingsMatch::startMatchApp(const QString &source){
m_sourceText=source;
// qDebug()<<m_sourceText;
QStringList settingList=matching();
return settingList;
}
@ -43,9 +42,8 @@ QStringList SettingsMatch::startMatchApp(const QString &source){
* xml文件内容读到内存
*/
void SettingsMatch::xmlElement(){
QString pinyinIndex;
QString ChineseIndex;
QString EnglishIndex;
QFile file(QString::fromLocal8Bit("/usr/share/ukui-control-center/shell/res/search.xml"));
if (!file.open(QIODevice::ReadOnly)){
return;
@ -60,36 +58,27 @@ void SettingsMatch::xmlElement(){
QDomElement element=node.toElement();
QString key=element.attribute("name");;
m_chine_searchResult=m_chine_searchList.value(key);
m_pinyin_searchResult=m_pinyin_searchList.value(key);
m_English_searchResult=m_English_searchList.value(key);
QDomNodeList list=element.childNodes();
for(int i=0;i<list.count();++i){
QDomNode n=list.at(i);
if(n.nodeName()==QString::fromLocal8Bit("pinyinPlugin")){
pinyinIndex=n.toElement().text();
}
if(n.nodeName()==QString::fromLocal8Bit("pinyinfunc")){
pinyinIndex+=QString::fromLocal8Bit("/")+n.toElement().text();
m_pinyin_searchResult.append(pinyinIndex);
}
if(n.nodeName()==QString::fromLocal8Bit("ChinesePlugin")){
ChineseIndex=n.toElement().text();
}
if(n.nodeName()==QString::fromLocal8Bit("ChineseFunc")){
ChineseIndex+=QString::fromLocal8Bit("/")+n.toElement().text();
m_chine_searchResult.append(ChineseIndex);
m_chine_searchResult.append(ChineseIndex);
}
if(n.nodeName()==QString::fromLocal8Bit("EnglishFunc")){
EnglishIndex=QString::fromLocal8Bit("/")+n.toElement().text();
m_English_searchResult.append(EnglishIndex);
}
}
m_pinyin_searchList.insert(key,m_pinyin_searchResult);
m_chine_searchList.insert(key,m_chine_searchResult);
m_English_searchList.insert(key,m_English_searchResult);
node=node.nextSibling();
}
file.close();
// qDebug()<<pinyin_searchlist;
// qDebug()<<chine_searchlist;
}
/**
@ -101,35 +90,61 @@ QStringList SettingsMatch::matching(){
QStringList returnresult;
QStringList regmatch;
QString key;
QStringList pinyinlist;
QMap<QString, QStringList>::const_iterator i;
for(i=m_chine_searchList.constBegin();i!=m_chine_searchList.constEnd();++i){
regmatch=*i;
key=i.key();
// qDebug()<<key;
for(int t=0; t<regmatch.size();t++)
{
if(m_sourceText=="/")
continue;
QString str =regmatch.at(t);
if(str.contains(m_sourceText))
QLocale ql;
if(ql.language()==QLocale::Chinese){
for(i=m_chine_searchList.constBegin();i!=m_chine_searchList.constEnd();++i){
regmatch=*i;
key=i.key();
for(int t=0; t<regmatch.size();t++)
{
str=key+"/"+str;
returnresult.append(str);//中文名
continue;
if(m_sourceText=="/")
continue;
QString str =regmatch.at(t);
pinyinlist=FileUtils::findMultiToneWords(str);
if(str.contains(m_sourceText))
{
str=key+"/"+str;
returnresult.append(str);//中文名
continue;
}
for(int i = 0;i<pinyinlist.size()/2;i++){
str =regmatch.at(t);
QString shouzimu=pinyinlist.at(2*i+1); // 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str;
returnresult.append(str);
break;
}
if(m_sourceText.size()<2)
break;
QString pinyin=pinyinlist.at(2*i);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str;
returnresult.append(str);
break;
}
}
}
}
}
if(ql.language()==QLocale::English){
for(i=m_English_searchList.constBegin();i!=m_English_searchList.constEnd();++i){
regmatch=*i;
key=i.key();
for(int t=0; t<regmatch.size();t++)
{
if(m_sourceText=="/")
continue;
QString str =regmatch.at(t);
if(str.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str;
returnresult.append(str);
}
}
QString shouzimu=FileUtils::findMultiToneWords(str).at(1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str;
returnresult.append(str);
continue;
}
QString pinyin=FileUtils::findMultiToneWords(str).at(0);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str;
returnresult.append(str);
}
}
}
// qDebug()<<returnresult;
return returnresult;
}

View File

@ -42,10 +42,10 @@ private:
QStringList matching();
private:
QMap<QString,QStringList> m_pinyin_searchList;
QMap<QString,QStringList> m_chine_searchList;
QStringList m_pinyin_searchResult;
QMap<QString,QStringList> m_English_searchList;
QStringList m_chine_searchResult;
QStringList m_English_searchResult;
QString m_sourceText;
};

View File

@ -28,8 +28,13 @@ ContentWidget::ContentWidget(QWidget * parent):QStackedWidget(parent)
{
initUI();
initListView();
// m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"Background/背景/更改壁纸";
m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/ksc-defender.desktop";
//快速入口应用列表
// m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/ksc-defender.desktop";
m_quicklyOpenList << "/usr/share/applications/ksc-defender.desktop"
<< "/usr/share/applications/ukui-notebook.desktop"
<< "/usr/share/applications/eom.desktop"
<< "/usr/share/applications/pluma.desktop"
<< "/usr/share/applications/claws-mail.desktop" ;
}
ContentWidget::~ContentWidget()
@ -48,12 +53,13 @@ ContentWidget::~ContentWidget()
* @brief initUI homepage和resultpage
*/
void ContentWidget::initUI() {
m_homePage = new QWidget;
m_homePage = new QWidget(this);
m_homePageLyt = new QVBoxLayout(m_homePage);
m_homePageLyt->setSpacing(0);
m_homePageLyt->setContentsMargins(0,0,0,0);
m_homePage->setLayout(m_homePageLyt);
m_resultPage = new QWidget;
m_resultPage = new QWidget(this);
m_resultPageLyt = new QHBoxLayout(m_resultPage);
m_resultPageLyt->setSpacing(0);
m_resultPageLyt->setContentsMargins(0, 0, 0, 0);
@ -68,14 +74,14 @@ void ContentWidget::initUI() {
m_resultPageLyt->addWidget(m_resultDetailArea);
m_resultPage->setLayout(m_resultPageLyt);
m_resultList = new QWidget(m_resultDetailArea);
m_resultList = new QWidget(m_resultListArea);
m_resultDetail = new QWidget(m_resultDetailArea);
m_listLyt = new QVBoxLayout(m_resultList);
m_detailLyt = new QVBoxLayout(m_resultDetail);
m_resultList->setFixedWidth(240);
m_resultList->setFixedWidth(236);
m_resultList->setFixedHeight(0);
m_resultList->setStyleSheet("QWidget{background:transparent;}");
m_listLyt->setContentsMargins(0, 0, 15, 0);
m_listLyt->setContentsMargins(0, 0, 12, 0);
m_listLyt->setSpacing(0);
m_resultListArea->setWidget(m_resultList);
m_resultListArea->setWidgetResizable(true);
@ -105,12 +111,15 @@ void ContentWidget::initListView()
m_settingListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Settings);
m_appListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Apps);
m_bestListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Best);
m_webListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Web);
setupConnect(m_fileListView);
setupConnect(m_dirListView);
setupConnect(m_contentListView);
setupConnect(m_settingListView);
setupConnect(m_appListView);
setupConnect(m_bestListView);
setupConnect(m_webListView);
m_fileTitleLabel = new TitleLabel(m_resultList);
m_fileTitleLabel->setText(getTitleName(SearchItem::SearchType::Files));
@ -124,6 +133,8 @@ void ContentWidget::initListView()
m_settingTitleLabel->setText(getTitleName(SearchItem::SearchType::Settings));
m_bestTitleLabel = new TitleLabel(m_resultList);
m_bestTitleLabel->setText(getTitleName(SearchItem::SearchType::Best));
m_webTitleLabel = new TitleLabel(m_resultList);
m_webTitleLabel->setText(getTitleName(SearchItem::SearchType::Web));
m_appShowMoreLabel = new ShowMoreLabel(m_resultList);
m_settingShowMoreLabel = new ShowMoreLabel(m_resultList);
@ -148,14 +159,20 @@ void ContentWidget::initListView()
m_listLyt->addWidget(m_contentTitleLabel);
m_listLyt->addWidget(m_contentListView);
m_listLyt->addWidget(m_contentShowMoreLabel);
m_listLyt->addWidget(m_webTitleLabel);
m_listLyt->addWidget(m_webListView);
this->hideListView();
m_resultList->setFixedHeight(0);
m_resultListArea->setFocusProxy(m_bestListView);
m_bestListView->setFocus();
connect(m_appShowMoreLabel, &ShowMoreLabel::showMoreClicked, this, [ = ]() {
m_appListView->setList(m_appList);
m_appShowMoreLabel->stopLoading();
this->resetListHeight();
m_resultListArea->setFocusProxy(m_appListView);
m_appListView->setFocus();
});
connect(m_appShowMoreLabel, &ShowMoreLabel::retractClicked, this, [ = ]() {
m_appListView->setList(m_appList.mid(0, 5));
@ -166,6 +183,8 @@ void ContentWidget::initListView()
m_settingListView->setList(m_settingList);
m_settingShowMoreLabel->stopLoading();
this->resetListHeight();
m_resultListArea->setFocusProxy(m_settingListView);
m_settingListView->setFocus();
});
connect(m_settingShowMoreLabel, &ShowMoreLabel::retractClicked, this, [ = ]() {
m_settingListView->setList(m_settingList.mid(0, 5));
@ -176,6 +195,8 @@ void ContentWidget::initListView()
m_dirListView->setList(m_dirList);
m_dirShowMoreLabel->stopLoading();
this->resetListHeight();
m_resultListArea->setFocusProxy(m_dirListView);
m_dirListView->setFocus();
});
connect(m_dirShowMoreLabel, &ShowMoreLabel::retractClicked, this, [ = ]() {
m_dirListView->setList(m_dirList.mid(0, 5));
@ -186,6 +207,8 @@ void ContentWidget::initListView()
m_fileListView->setList(m_fileList);
m_fileShowMoreLabel->stopLoading();
this->resetListHeight();
m_resultListArea->setFocusProxy(m_fileListView);
m_fileListView->setFocus();
});
connect(m_fileShowMoreLabel, &ShowMoreLabel::retractClicked, this, [ = ]() {
m_fileListView->setList(m_fileList.mid(0, 5));
@ -196,6 +219,8 @@ void ContentWidget::initListView()
m_contentListView->setList(m_contentList);
m_contentShowMoreLabel->stopLoading();
this->resetListHeight();
m_resultListArea->setFocusProxy(m_contentListView);
m_contentListView->setFocus();
});
connect(m_contentShowMoreLabel, &ShowMoreLabel::retractClicked, this, [ = ]() {
m_contentListView->setList(m_contentList.mid(0, 5));
@ -226,6 +251,8 @@ void ContentWidget::hideListView()
m_contentTitleLabel->hide();
m_contentListView->hide();
m_contentShowMoreLabel->hide();
m_webTitleLabel->hide();
m_webListView->hide();
}
/**
@ -233,34 +260,20 @@ void ContentWidget::hideListView()
* @param listview
*/
void ContentWidget::setupConnect(SearchListView * listview) {
connect(listview, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) {
if(type == SearchItem::SearchType::Contents && !m_contentDetailList.isEmpty()) {
m_detailView->isContent = true;
m_detailView->setContent(m_contentDetailList.at(listview->currentIndex().row()), m_keyword);
} else if (type == SearchItem::SearchType::Best && !m_bestContent.isEmpty() && listview->currentIndex().row() == listview->getLength() - 1) {
m_detailView->setContent(m_bestContent, m_keyword);
m_detailView->isContent = true;
m_detailView->setupWidget(type == SearchItem::SearchType::Contents, path);
listview->is_current_list = true;
Q_EMIT this->currentItemChanged();
listview->is_current_list = false;
return;
} else {
m_detailView->isContent = false;
}
m_detailView->setupWidget(type, path);
// m_detailView->setWebWidget(this->m_keyword);
listview->is_current_list = true;
Q_EMIT this->currentItemChanged();
listview->is_current_list = false;
});
connect(this, &ContentWidget::currentItemChanged, listview, [ = ]() {
if (! listview->is_current_list) {
listview->blockSignals(true);
listview->clearSelection();
listview->blockSignals(false);
}
});
connect(listview,&SearchListView::currentSelectPos,[=](QPoint pos){
m_resultListArea->ensureVisible(pos.x(),pos.y());
});
connect(listview,&SearchListView::mousePressed,this,&ContentWidget::mousePressed);
connect(listview, &SearchListView::currentRowChanged, this, &ContentWidget::onListViewRowChanged);
connect(listview, &SearchListView::onRowDoubleClicked, this, &ContentWidget::onListViewRowDoubleClicked);
}
/**
@ -308,9 +321,20 @@ void ContentWidget::resetListHeight()
height += m_contentShowMoreLabel->height();
}
}
if (! m_webListView->isHidden) {
height += m_webTitleLabel->height();
height += m_webListView->height();
}
m_resultList->setFixedHeight(height);
}
void ContentWidget::appendBestItem(const int &type, const QString &path)
{
m_bestList.append(QPair<int, QString>(type, path));
m_bestListView->appendBestItem(QPair<int, QString>(type, path));
appendSearchItem(SearchItem::SearchType::Best, path);
}
/**
* @brief ContentWidget::initHomePage homepage填充内容
* @param lists
@ -322,9 +346,10 @@ void ContentWidget::initHomePage() {
commonlyList = map.value("Commonly");
QStringList recentlyList;
recentlyList = map.value("Recently");
lists.append(commonlyList);
lists.append(recentlyList);
lists.append(m_quicklyOpenList);
lists.append(recentlyList);
lists.append(commonlyList);
for (int i = 0; i < lists.count(); i++) {
if (lists.at(i).isEmpty())
@ -335,7 +360,7 @@ void ContentWidget::initHomePage() {
QWidget * itemWidget = new QWidget(listWidget);
if (i == 1) {
if (lists.at(i).length() <= 2) itemWidget->setFixedHeight(48);
else itemWidget->setFixedHeight(112);
else itemWidget->setFixedHeight(104);
titleLabel->setText(tr("Recently Opened"));
QGridLayout * layout = new QGridLayout(itemWidget);
layout->setSpacing(8);
@ -343,36 +368,36 @@ void ContentWidget::initHomePage() {
itemWidget->setLayout(layout);
for (int j = 0; j < lists.at(i).count(); j++) {
HomePageItem * item = new HomePageItem(itemWidget, i, lists.at(i).at(j));
item->setFixedSize(265, 48);
item->setFixedSize(300, 48);
layout->addWidget(item, j / 2, j % 2);
}
if (lists.at(i).length() == 1) {
QWidget * emptyItem = new QWidget(itemWidget);
emptyItem->setFixedSize(265, 48); //占位用widget,只有一项时在右方补全
emptyItem->setFixedSize(300, 48); //占位用widget,只有一项时在右方补全
layout->addWidget(emptyItem, 1, 2);
}
} else {
itemWidget->setFixedHeight(136);
itemWidget->setFixedHeight(116);
QHBoxLayout * layout = new QHBoxLayout(itemWidget);
layout->setSpacing(8);
layout->setContentsMargins(0, 0, 0, 0);
itemWidget->setLayout(layout);
int shownItem = lists.at(i).length();
Q_FOREACH(QString path, lists.at(i)){
if (i && QString::compare(FileUtils::getAppName(path),"Unknown App") == 0) {
if (i == 0 && QString::compare(FileUtils::getAppName(path),"Unknown App") == 0) {
shownItem --;
continue;
}
HomePageItem * item = new HomePageItem(itemWidget, i, path);
item->setFixedSize(100, 100);
item->setFixedSize(116, 116);
layout->addWidget(item);
}
for (int j = 0; j < 5 - shownItem; j++) {
QWidget * emptyItem = new QWidget(itemWidget);
emptyItem->setFixedSize(100, 100); //占位用widget,少于5项会补全后方占位
emptyItem->setFixedSize(116, 116); //占位用widget,少于5项会补全后方占位
layout->addWidget(emptyItem);
}
if (i && shownItem) titleLabel->setText(tr("Open Quickly"));
if (i == 0 && shownItem) titleLabel->setText(tr("Open Quickly"));
else titleLabel->setText(tr("Commonly Used"));
}
itemWidgetLyt->setSpacing(6);
@ -401,11 +426,11 @@ int ContentWidget::currentPage() {
}
/**
* @brief ContentWidget::refreshSearchList /
* @param lists list.at(0) list.at(1)
* @brief ContentWidget::resetSearchList
*/
void ContentWidget::refreshSearchList(const QVector<QStringList>& lists) {
this->hideListView();
void ContentWidget::resetSearchList()
{
// this->hideListView();
if (m_fileListView) {
m_fileListView->hide();
m_fileTitleLabel->hide();
@ -447,7 +472,15 @@ void ContentWidget::refreshSearchList(const QVector<QStringList>& lists) {
m_bestListView->isHidden = true;
m_bestListView->clear();
}
m_resultList->setFixedHeight(0);
if (m_webListView) {
m_webListView->clear();
m_webListView->appendItem(m_keyword);
m_webTitleLabel->show();
m_webListView->show();
m_webListView->isHidden = false;
}
resetListHeight();
m_detailView->clearLayout();
m_contentDetailList.clear();
m_bestContent.clear();
@ -458,6 +491,7 @@ void ContentWidget::refreshSearchList(const QVector<QStringList>& lists) {
m_fileShowMoreLabel->resetLabel();
m_contentShowMoreLabel->resetLabel();
m_bestList.clear();
if (! m_appList.isEmpty())
m_appList.clear();
if (! m_settingList.isEmpty())
@ -468,34 +502,65 @@ void ContentWidget::refreshSearchList(const QVector<QStringList>& lists) {
m_fileList.clear();
if (! m_contentList.isEmpty())
m_contentList.clear();
if (! m_appPathList.isEmpty())
m_appPathList.clear();
if (! m_appIconList.isEmpty())
m_appIconList.clear();
if (!m_appDescList.isEmpty())
m_appDescList.clear();
}
if (!lists.at(0).isEmpty()) {
m_appList = lists.at(0);
qDebug()<<"Append a best item into list: "<<lists.at(0).at(0);
appendSearchItem(SearchItem::SearchType::Best, lists.at(0).at(0));
m_appListView->show();
m_appTitleLabel->show();
m_appListView->isHidden = false;
if (m_appList.length() <= 5) {
m_appListView->setList(m_appList);
} else {
m_appShowMoreLabel->show();
m_appListView->setList(m_appList.mid(0, 5));
}
/**
* @brief ContentWidget::setSettingList
* @param settingList
*/
void ContentWidget::setSettingList(const QStringList & settingList)
{
if (settingList.isEmpty())
return;
m_settingList = settingList;
qDebug()<<"Append a best item into list: "<<settingList.at(0);
this->appendBestItem(SearchItem::SearchType::Settings, settingList.at(0));
m_settingListView->show();
m_settingTitleLabel->show();
m_settingListView->isHidden = false;
if (m_settingList.length() <= 5) {
m_settingListView->setList(m_settingList);
} else {
m_settingShowMoreLabel->show();
m_settingListView->setList(m_settingList.mid(0, 5));
}
if (!lists.at(1).isEmpty()) {
m_settingList = lists.at(1);
qDebug()<<"Append a best item into list: "<<lists.at(1).at(0);
appendSearchItem(SearchItem::SearchType::Best, lists.at(1).at(0));
m_settingListView->show();
m_settingTitleLabel->show();
m_settingListView->isHidden = false;
if (m_settingList.length() <= 5) {
m_settingListView->setList(m_settingList);
} else {
m_settingShowMoreLabel->show();
m_settingListView->setList(m_settingList.mid(0, 5));
}
this->resetListHeight();
}
/**
* @brief ContentWidget::setAppList
* @param appList QVector<namelist,pathlist,iconlist>
*/
void ContentWidget::setAppList(const QVector<QStringList>& appList) {
if (appList.at(0).isEmpty())
return;
m_appList = appList.at(0);
m_appPathList = appList.at(1);
m_appIconList = appList.at(2);
m_appDescList = appList.at(3);
m_appListView->setAppList(m_appPathList, m_appIconList);
qDebug()<<"Append a best item into list: "<<appList.at(0).at(0);
SearchItemModel * model = qobject_cast<SearchItemModel *>(m_bestListView->model());
if (appList.at(1).at(0).isEmpty() || appList.at(1).at(0) == "") {
model->setBestAppIcon(appList.at(2).at(0), false);
} else {
model->setBestAppIcon(appList.at(2).at(0), true);
}
this->appendBestItem(SearchItem::SearchType::Apps, appList.at(0).at(0));
m_appListView->show();
m_appTitleLabel->show();
m_appListView->isHidden = false;
if (m_appList.length() <= 5) {
m_appListView->setList(m_appList);
} else {
m_appShowMoreLabel->show();
m_appListView->setList(m_appList.mid(0, 5));
}
this->resetListHeight();
}
@ -520,40 +585,12 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
}
break;
}
// case SearchItem::SearchType::Apps: {
// if (m_appListView->isHidden) {
// m_appListView->show();
// m_appTitleLabel->show();
// m_appListView->isHidden = false;
// if (!m_detailView->isEmpty() && m_detailView->getType() > type) {
// m_appListView->setCurrentIndex(m_appListView->model()->index(0, 0, QModelIndex()));
// }
// }
// m_appListView->appendItem(path);
// currentList = m_appListView;
// this->resetListHeight();
// break;
// }
// case SearchItem::SearchType::Settings: {
// if (m_settingListView->isHidden) {
// m_settingListView->show();
// m_settingTitleLabel->show();
// m_settingListView->isHidden = false;
// if (!m_detailView->isEmpty() && m_detailView->getType() > type) {
// m_settingListView->setCurrentIndex(m_settingListView->model()->index(0, 0, QModelIndex()));
// }
// }
// m_settingListView->appendItem(path);
// currentList = m_settingListView;
// break;
// }
case SearchItem::SearchType::Files: {
if (m_fileListView->isHidden) {
m_fileListView->show();
m_fileTitleLabel->show();
m_fileListView->isHidden = false;
appendSearchItem(SearchItem::SearchType::Best, path);
this->appendBestItem(SearchItem::SearchType::Files, path);
}
if (m_fileListView->getLength() < 5) { //当已搜索结果列表少于5项直接将搜索结果添加到列表中
m_fileListView->appendItem(path);
@ -570,7 +607,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
m_dirListView->show();
m_dirTitleLabel->show();
m_dirListView->isHidden = false;
appendSearchItem(SearchItem::SearchType::Best, path);
this->appendBestItem(SearchItem::SearchType::Dirs, path);
}
if (m_dirListView->getLength() < 5) {
m_dirListView->appendItem(path);
@ -593,7 +630,7 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
m_bestContent.append("\n");
}
}
appendSearchItem(SearchItem::SearchType::Best, path);
this->appendBestItem(SearchItem::SearchType::Contents, path);
}
if (m_contentListView->getLength() < 5) {
m_contentListView->appendItem(path);
@ -639,6 +676,8 @@ QString ContentWidget::getTitleName(const int& type) {
return tr("File Contents");
case SearchItem::SearchType::Best :
return tr("Best Matches");
case SearchItem::SearchType::Web :
return tr("Web Pages");
default :
return tr("Unknown");
}
@ -661,6 +700,74 @@ void ContentWidget::clearLayout(QLayout * layout) {
child = NULL;
}
/**
* @brief ContentWidget::onListViewRowChanged
* @param type
* @param path
*/
void ContentWidget::onListViewRowChanged(SearchListView * listview, const int &type, const QString &path)
{
if(type == SearchItem::SearchType::Contents && !m_contentDetailList.isEmpty()) {
m_detailView->isContent = true;
m_detailView->setContent(m_contentDetailList.at(listview->currentIndex().row()), m_keyword);
} else if (type == SearchItem::SearchType::Best && !m_bestContent.isEmpty() && listview->currentIndex().row() == listview->getLength() - 1) {
m_detailView->setContent(m_bestContent, m_keyword);
m_detailView->isContent = true;
m_detailView->setupWidget(SearchItem::SearchType::Contents, path);
listview->is_current_list = true;
Q_EMIT this->currentItemChanged();
listview->is_current_list = false;
return;
} else {
m_detailView->isContent = false;
}
if (type == SearchItem::SearchType::Web) {
m_detailView->setWebWidget(this->m_keyword);
} else if (type == SearchItem::SearchType::Apps) {
int index = listview->currentIndex().row();
m_detailView->setAppWidget(m_appList.at(index), m_appPathList.at(index), m_appIconList.at(index), m_appDescList.at(index));
} else if (type == SearchItem::SearchType::Best) {
if (m_bestList.at(listview->currentIndex().row()).first == SearchItem::SearchType::Apps) {
m_detailView->setAppWidget(m_appList.at(0), m_appPathList.at(0), m_appIconList.at(0), m_appDescList.at(0));
} else {
m_detailView->setupWidget(m_bestList.at(listview->currentIndex().row()).first, m_bestList.at(listview->currentIndex().row()).second);
}
} else {
m_detailView->setupWidget(type, path);
}
listview->is_current_list = true;
Q_EMIT this->currentItemChanged();
listview->is_current_list = false;
}
/**
* @brief ContentWidget::onListViewRowDoubleClicked
* @param type
* @param path
*/
void ContentWidget::onListViewRowDoubleClicked(SearchListView * listview, const int &type, const QString &path)
{
qDebug()<<"A row has been double clicked.Type = "<<type<<"; Name = "<<path;
if (type == SearchItem::SearchType::Best && m_bestList.at(listview->currentIndex().row()).first != SearchItem::SearchType::Apps) {
m_detailView->doubleClickAction(m_bestList.at(listview->currentIndex().row()).first, path);
} else if (type == SearchItem::SearchType::Best && m_bestList.at(listview->currentIndex().row()).first == SearchItem::SearchType::Apps) {
if (m_appPathList.at(0) == "" || m_appPathList.at(0).isEmpty()){
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appList.at(0));
} else {
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appPathList.at(0));
}
} else if (type == SearchItem::SearchType::Apps) {
int index = listview->currentIndex().row();
if (m_appPathList.at(index) == "" || m_appPathList.at(index).isEmpty()){
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appList.at(index));
} else {
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appPathList.at(index));
}
} else {
m_detailView->doubleClickAction(type, path);
}
}
/**
* @brief ContentWidget::setContentList
@ -684,6 +791,7 @@ void ContentWidget::setKeyword(QString keyword)
m_settingListView->setKeyword(keyword);
m_appListView->setKeyword(keyword);
m_bestListView->setKeyword(keyword);
m_webListView->setKeyword(keyword);
}
/**
@ -694,3 +802,11 @@ void ContentWidget::setQuicklyOpenList(const QStringList & list)
{
m_quicklyOpenList = list;
}
/**
* @brief ContentWidget::closeWebView webview未关闭
*/
void ContentWidget::closeWebView()
{
m_detailView->closeWebWidget();
}

View File

@ -39,12 +39,15 @@ public:
void setPage(const int&);
int currentPage();
void refreshSearchList(const QVector<QStringList>&);
void resetSearchList();
void setSettingList(const QStringList&);
void setAppList(const QVector<QStringList>&);
void appendSearchItem(const int& type, const QString& path, QStringList contents = QStringList());
void initHomePage();
void setContentList(const QStringList&);
void setKeyword(QString);
void setQuicklyOpenList(const QStringList &);
void closeWebView();
private:
void initUI();
void initListView();
@ -52,6 +55,7 @@ private:
void setupConnect(SearchListView *);
void clearHomepage();
void resetListHeight();
void appendBestItem(const int&, const QString&);
QString m_keyword;
QStringList m_contentDetailList;
QWidget * m_homePage = nullptr;
@ -72,12 +76,14 @@ private:
SearchListView * m_settingListView = nullptr;
SearchListView * m_appListView = nullptr;
SearchListView * m_bestListView = nullptr;
SearchListView * m_webListView = nullptr;
TitleLabel * m_fileTitleLabel = nullptr;
TitleLabel * m_dirTitleLabel = nullptr;
TitleLabel * m_contentTitleLabel = nullptr;
TitleLabel * m_appTitleLabel = nullptr;
TitleLabel * m_settingTitleLabel = nullptr;
TitleLabel * m_bestTitleLabel = nullptr;
TitleLabel * m_webTitleLabel = nullptr;
ShowMoreLabel * m_appShowMoreLabel = nullptr;
ShowMoreLabel * m_settingShowMoreLabel = nullptr;
ShowMoreLabel * m_dirShowMoreLabel = nullptr;
@ -90,6 +96,10 @@ private:
QStringList m_fileList;
QStringList m_contentList;
QStringList m_quicklyOpenList;
QStringList m_appPathList;
QStringList m_appIconList;
QStringList m_appDescList;
QList<QPair<int, QString>> m_bestList;
QString m_bestContent; //最佳匹配有文件内容搜索结果的时候,以此变量传递
@ -99,9 +109,12 @@ private:
Q_SIGNALS:
void currentItemChanged();
void mousePressed();
private Q_SLOTS:
void clearLayout(QLayout *);
void onListViewRowChanged(SearchListView * listview, const int& type, const QString& path);
void onListViewRowDoubleClicked(SearchListView * listview, const int& type, const QString& path);
};
#endif // CONTENTWIDGET_H

View File

@ -20,7 +20,7 @@
#include "config-file.h"
bool ConfigFile::writeCommonly(QString message){
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
QStringList messagelist=message.split("/");
QString appname=messagelist.last();
if(!appname.contains("desktop"))
@ -39,7 +39,7 @@ bool ConfigFile::writeCommonly(QString message){
}
QStringList ConfigFile::readCommonly(){
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
QStringList returnlist;
QMap<QString,int> quicklycount;
m_qSettings->beginGroup("Commonly");
@ -66,7 +66,7 @@ QStringList ConfigFile::readCommonly(){
}
bool ConfigFile::writeRecently(QString message){
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
m_qSettings->beginGroup("Recently");
QStringList recently=m_qSettings->value("Recently").toStringList();
@ -89,7 +89,7 @@ bool ConfigFile::writeRecently(QString message){
}
QStringList ConfigFile::readRecently(){
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
m_qSettings->beginGroup("Recently");
QStringList recently=m_qSettings->value("Recently").toStringList();
@ -113,7 +113,7 @@ QMap<QString,QStringList> ConfigFile::readConfig(){
}
void ConfigFile::receiveMessage(QString message){
QFile file(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf");
QFile file(HOMEPAGE_SETTINGS);
if(!file.exists()){
file.open( QIODevice::ReadWrite | QIODevice::Text );
file.close();

View File

@ -25,6 +25,7 @@
#include <QDebug>
#include <QFileInfo>
#include <QDir>
#define HOMEPAGE_SETTINGS QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search-homepage.conf"
class ConfigFile : public QObject
{
Q_OBJECT

View File

@ -45,7 +45,7 @@ void FolderListItem::initUi() {
this->setFixedHeight(32);
m_layout->addWidget(m_widget);
m_widgetlayout = new QHBoxLayout(m_widget);
m_widgetlayout->setContentsMargins(4, 4, 4, 4);
m_widgetlayout->setContentsMargins(8, 4, 8, 4);
m_widget->setLayout(m_widgetlayout);
m_iconLabel = new QLabel(m_widget);

View File

@ -25,8 +25,9 @@
#include <QDebug>
#include <QTextDocument>
#include <QAbstractTextDocumentLayout>
#include "global-settings.h"
HighlightItemDelegate::HighlightItemDelegate()
HighlightItemDelegate::HighlightItemDelegate(QObject *parent) : QStyledItemDelegate (parent)
{
}
@ -83,8 +84,11 @@ QString HighlightItemDelegate::getHtmlText(QPainter *painter, const QStyleOption
{
int indexFindLeft = 0;
QString indexString = index.model()->data(index,Qt::DisplayRole).toString();
QFontMetrics m_QFontMetrics = painter->fontMetrics();
QString indexColString = m_QFontMetrics.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号
QFont ft(painter->font().family(), GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toInt());
QFontMetrics fm(ft);
QString indexColString = fm.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号
// QFontMetrics m_QFontMetrics = painter->fontMetrics();
// QString indexColString = m_QFontMetrics.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号
QString htmlString;
if ((indexColString.toUpper()).contains((m_regFindKeyWords.toUpper()))) {
indexFindLeft = indexColString.toUpper().indexOf(m_regFindKeyWords.toUpper()); //得到查找字体在当前整个Item字体中的位置

View File

@ -27,7 +27,7 @@ class HighlightItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit HighlightItemDelegate();
explicit HighlightItemDelegate(QObject *parent = nullptr);
void setSearchKeyword(const QString &);
private:
QString m_regFindKeyWords = 0;

View File

@ -24,11 +24,24 @@
#include <QDebug>
#include <gio/gdesktopappinfo.h>
#include <QPainter>
#include <QDesktopServices>
#include <QUrl>
#include <QApplication>
HomePageItem::HomePageItem(QWidget *parent, const int& type, const QString& path) : QWidget(parent)
{
setupUi(type, path);
m_transparency = 0.06;
connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
if (m_namelabel) {
QString name = this->toolTip();
if (m_type == ItemType::Recent) {
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 250));
} else {
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 108));
}
}
});
}
HomePageItem::~HomePageItem()
@ -41,42 +54,16 @@ HomePageItem::~HomePageItem()
* @param path
*/
void HomePageItem::setupUi(const int& type, const QString& path) {
m_path = path;
m_type = type;
m_widget = new QWidget(this);
m_widget->setObjectName("MainWidget");
// m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.05); border-radius: 4px;}");
m_widget->installEventFilter(this);
connect(this, &HomePageItem::onItemClicked, this, [ = ]() {
switch (SearchListView::getResType(path)) {
case SearchListView::ResType::App: {
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data());
g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr);
g_object_unref(desktopAppInfo);
break;
}
case SearchListView::ResType::Best:
case SearchListView::ResType::Content:
case SearchListView::ResType::Dir:
case SearchListView::ResType::File: {
QProcess process;
process.startDetached(QString("xdg-open %1").arg(path));
process.waitForFinished();
break;
}
case SearchListView::ResType::Setting: {
//打开控制面板对应页面
QProcess process;
process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
break;
}
default:
break;
}
});
m_iconlabel = new QLabel(m_widget);
m_namelabel = new QLabel(m_widget);
m_namelabel->setStyleSheet("QLabel{color: palette(text);}");
if (type == ItemType::Recent) {
m_widget->setFixedSize(265, 48);
m_widget->setFixedSize(300, 48);
QIcon icon;
switch (SearchListView::getResType(path)) { //可能出现文件应用等,需要根据路径判断类型
case SearchListView::ResType::App : {
@ -84,7 +71,7 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
m_namelabel->setText(FileUtils::getAppName(path));
QFontMetrics fontMetrics = m_namelabel->fontMetrics();
QString name = FileUtils::getAppName(path);
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 220));
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 250));
this->setToolTip(name);
break;
}
@ -96,7 +83,7 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
// m_namelabel->setText(FileUtils::getFileName(path));
QFontMetrics fontMetrics = m_namelabel->fontMetrics();
QString name = FileUtils::getFileName(path);
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 220));
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 250));
this->setToolTip(name);
break;
}
@ -105,7 +92,7 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
// m_namelabel->setText(FileUtils::getSettingName(path));
QFontMetrics fontMetrics = m_namelabel->fontMetrics();
QString name = FileUtils::getSettingName(path);
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 220));
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 250));
this->setToolTip(name);
break;
}
@ -121,27 +108,21 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
m_hlayout->addStretch();
return;
} else if (type == ItemType::Quick) {
if (SearchListView::getResType(path) == SearchListView::ResType::Setting) {
QIcon icon = FileUtils::getSettingIcon(path, true);
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));
m_namelabel->setText(FileUtils::getSettingName(path));
this->setToolTip(FileUtils::getSettingName(path));
} else {
QIcon icon = FileUtils::getAppIcon(path);
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));
m_namelabel->setText(FileUtils::getAppName(path));
this->setToolTip(FileUtils::getAppName(path));
}
QString name = FileUtils::getAppName(path);
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 108));
this->setToolTip(name);
} else {
QIcon icon = FileUtils::getAppIcon(path);
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));
// m_namelabel->setText(FileUtils::getAppName(path));
QFontMetrics fontMetrics = m_namelabel->fontMetrics();
QString name = FileUtils::getAppName(path);
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 96));
m_namelabel->setText(fontMetrics.elidedText(name, Qt::ElideRight, 108));
this->setToolTip(name);
}
m_widget->setFixedSize(100, 100);
m_widget->setFixedSize(116, 116);
m_vlayout = new QVBoxLayout(m_widget);
m_vlayout->setContentsMargins(0,16,0,12);
m_iconlabel->setAlignment(Qt::AlignCenter);
@ -150,24 +131,51 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
m_vlayout->addWidget(m_namelabel);
}
void HomePageItem::onItemClicked()
{
switch (SearchListView::getResType(m_path)) {
case SearchListView::ResType::App: {
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(m_path.toLocal8Bit().data());
g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr);
g_object_unref(desktopAppInfo);
break;
}
case SearchListView::ResType::Best:
case SearchListView::ResType::Content:
case SearchListView::ResType::Dir:
case SearchListView::ResType::File: {
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
break;
}
case SearchListView::ResType::Setting: {
//打开控制面板对应页面
QProcess process;
process.startDetached(QString("ukui-control-center --%1").arg(m_path.left(m_path.indexOf("/")).toLower()));
break;
}
default:
break;
}
}
bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
if (watched == m_widget){
if (event->type() == QEvent::MouseButtonPress) {
m_transparency = 0.06;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::MouseButtonRelease) {
Q_EMIT this->onItemClicked();
this->onItemClicked();
m_transparency = 0.06;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::Enter) {
m_transparency = 0.15;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::Leave) {
m_transparency = 0.06;
this->repaint();
this->update();
return true;
}
}
@ -177,12 +185,10 @@ bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
void HomePageItem::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Text));

View File

@ -36,9 +36,9 @@ public:
~HomePageItem();
enum ItemType { //homepage中item的类型包括常用应用、最近打开、快捷打开
Common,
Quick,
Recent,
Quick
Common
};
protected:
@ -47,6 +47,7 @@ protected:
private:
void setupUi(const int&, const QString&);
void onItemClicked();
QWidget * m_widget = nullptr;
QHBoxLayout * m_hlayout = nullptr;
@ -54,9 +55,8 @@ private:
QLabel * m_iconlabel = nullptr;
QLabel * m_namelabel = nullptr;
double m_transparency = 0;
Q_SIGNALS:
void onItemClicked();
QString m_path;
int m_type = 0;
};
#endif // HOMEPAGEITEM_H

View File

@ -53,17 +53,22 @@ OptionView::~OptionView()
delete m_copyPathLabel;
m_copyPathLabel = NULL;
}
if (m_installLabel) {
delete m_installLabel;
m_installLabel = NULL;
}
}
/**
* @brief OptionView::initComponent
* @param type
* @param is_appInstalled
*/
void OptionView::setupOptions(const int& type) {
void OptionView::setupOptions(const int& type, bool is_appInstalled) {
this->hideOptions();
switch (type) {
case SearchListView::ResType::App : {
setupAppOptions();
setupAppOptions(is_appInstalled);
break;
}
case SearchListView::ResType::Content:
@ -127,6 +132,13 @@ void OptionView::initUI()
m_copyPathLabel->installEventFilter(this);
m_optionLyt->addWidget(m_copyPathLabel);
m_installLabel = new QLabel(m_optionFrame);
m_installLabel->setText(tr("Install")); //复制所在路径
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_installLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_installLabel->installEventFilter(this);
m_optionLyt->addWidget(m_installLabel);
m_optionLyt->addStretch();
m_optionFrame->setLayout(m_optionLyt);
m_mainLyt->addWidget(m_optionFrame);
@ -159,6 +171,10 @@ void OptionView::setupOptionLabel(const int& opt) {
m_copyPathLabel->show();
break;
}
case Options::Install: {
m_installLabel->show();
break;
}
default:
break;
}
@ -171,15 +187,21 @@ void OptionView::hideOptions()
m_panelLabel->hide();
m_openPathLabel->hide();
m_copyPathLabel->hide();
m_installLabel->hide();
}
/**
* @brief OptionView::setupAppOptions
* @param is_installed
*/
void OptionView::setupAppOptions() {
setupOptionLabel(Options::Open);
setupOptionLabel(Options::Shortcut);
setupOptionLabel(Options::Panel);
void OptionView::setupAppOptions(bool is_installed) {
if (is_installed) {
setupOptionLabel(Options::Open);
setupOptionLabel(Options::Shortcut);
setupOptionLabel(Options::Panel);
} else {
setupOptionLabel(Options::Install);
}
}
/**
@ -289,6 +311,21 @@ bool OptionView::eventFilter(QObject *watched, QEvent *event){
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
return true;
}
} else if (m_installLabel && watched == m_installLabel) {
if (event->type() == QEvent::MouseButtonPress) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
return true;
} else if (event->type() == QEvent::MouseButtonRelease) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
Q_EMIT this->onOptionClicked(Options::Install);
return true;
} else if (event->type() == QEvent::Enter) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
return true;
} else if (event->type() == QEvent::Leave) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
return true;
}
}
return QObject::eventFilter(watched, event);
}

View File

@ -34,14 +34,15 @@ class OptionView : public QWidget
public:
explicit OptionView(QWidget *);
~OptionView();
void setupOptions(const int&);
void setupOptions(const int&, bool is_appInstalled = true);
enum Options {
Open,
Shortcut,
Panel,
OpenPath,
CopyPath
CopyPath,
Install
};
protected:
@ -49,7 +50,7 @@ protected:
private:
void initUI();
void setupAppOptions();
void setupAppOptions(bool);
void setupFileOptions();
void setupDirOptions();
void setupSettingOptions();
@ -66,6 +67,7 @@ private:
QLabel * m_panelLabel = nullptr;
QLabel * m_openPathLabel = nullptr;
QLabel * m_copyPathLabel = nullptr;
QLabel * m_installLabel = nullptr;
Q_SIGNALS:
void onOptionClicked(const int&);

View File

@ -33,6 +33,8 @@
#include <QApplication>
#include <QFileInfo>
#include <QDateTime>
#include <QDBusMetaType>
//#include <QWebEngineCookieStore>
#include "config-file.h"
SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent)
@ -61,6 +63,7 @@ void SearchDetailView::clearLayout() {
// delete child;
// }
// child = NULL;
m_noNetFrame->hide();
m_iconLabel->hide();
m_nameFrame->hide();
m_nameLabel->hide();
@ -77,6 +80,11 @@ void SearchDetailView::clearLayout() {
m_hLine_2->hide();
m_optionView->hide();
m_isEmpty = true;
// closeWebWidget();
// if (m_webView) {
// m_webView->hide();
// }
// m_reload = false;
}
/**
@ -111,18 +119,148 @@ int SearchDetailView::getType()
* @brief SearchDetailView::setWebWidget
* @param keyword
*/
//void SearchDetailView::setWebWidget(const QString& keyword)
//{
// QWebEngineView * m_webView = new QWebEngineView(this);
// m_webView->move(0, 0);
// m_webView->setFixedSize(360, 522);
// m_isEmpty = false;
// clearLayout();
void SearchDetailView::setWebWidget(const QString& keyword)
{
clearLayout();
m_isEmpty = false;
m_reload = false;
// if (m_webView) {
// if (QString::compare(keyword, m_currentKeyword) == 0 && m_net_enable) { //关键词没有发生变化只把原来的网页show出来
// m_webView->show();
// return;
// }
// } else {
// m_webView = new QWebEngineView(this);
// m_engineProfile = m_webView->page()->profile();
// m_webView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
// m_webView->setAttribute(Qt::WA_DeleteOnClose);
// m_webView->move(0, 0);
// m_webView->setFixedSize(378, 522);
// QString str = "http://m.baidu.com/s?word=" + keyword;
// m_webView->load(str);
// connect(m_webView,&QWebEngineView::loadFinished, this, [ = ](bool is_successful){
// m_reload = true;
// if (m_engineProfile){
// m_engineProfile->clearHttpCache(); // 清理缓存
// m_engineProfile->clearAllVisitedLinks(); // 清理浏览记录
// m_engineProfile->cookieStore()->deleteAllCookies(); // 清理cookie
// m_engineProfile->cookieStore()->deleteSessionCookies(); // 清理会话cookie
// }
// if (is_successful) {
// m_webView->show();
// m_net_enable = true;
// } else {
// m_noNetFrame->show();
// m_net_enable = false;
// }
// });
// connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
// if (m_reload) {
// QDesktopServices::openUrl(url);
// closeWebWidget();
// }
// });
// }
//如果使用非手机版百度跳转请使用RequestInterceptor类
// RequestInterceptor * interceptor = new RequestInterceptor(m_webView);
// QWebEngineProfile * profile = new QWebEngineProfile(m_webView);
// profile->setRequestInterceptor(interceptor);
// QWebEnginePage * page = new QWebEnginePage(profile, m_webView);
// m_webView->setPage(page);
//新打开网页搜索或关键词发生变化重新load
m_currentKeyword = keyword;//目前网页搜索的关键词,记录此词来判断网页是否需要刷新
QString address;
QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString();
if (!engine.isEmpty()) {
if (engine == "360") {
address = "https://so.com/s?q=" + keyword; //360
} else if (engine == "sougou") {
address = "https://www.sogou.com/web?query=" + keyword; //搜狗
} else {
address = "http://baidu.com/s?word=" + keyword; //百度
}
} else { //默认值
address = "http://baidu.com/s?word=" + keyword; //百度
}
QDesktopServices::openUrl(address);
// QString str = "http://m.baidu.com/s?word=" + keyword; //百度
// QString str = "https://m.so.com/s?q=" + keyword; //360
// QString str = "https://wap.sogou.com/web/searchList.jsp?&keyword=" + keyword; //搜狗
// m_webView->load(address);
// m_webView->show();
//}
}
void SearchDetailView::setAppWidget(const QString &appname, const QString &path, const QString &iconpath, const QString &description)
{
m_type = SearchListView::ResType::App;
m_path = path;
m_name = appname.contains("/") ? appname.left(appname.indexOf("/")) : appname;
m_pkgname = appname.contains("/") ? appname.mid(appname.indexOf("/") + 1) : appname;
m_isEmpty = false;
clearLayout();
m_iconLabel->show();
m_nameFrame->show();
m_nameLabel->show();
m_typeLabel->show();
m_hLine->show();
QIcon icon;
if (path.isEmpty() || path == "") {
icon = QIcon(iconpath);
m_optionView->setupOptions(m_type, false);
//未安装应用有一个label显示软件描述
if (description != "" && !description.isEmpty()) {
m_detailFrame->show();
m_contentLabel->show();
m_contentLabel->setText(QString(tr("Introduction: %1")).arg(description));
}
} else {
m_optionView->setupOptions(m_type, true);
if (QIcon::fromTheme(iconpath).isNull()) {
icon = QIcon(":/res/icons/desktop.png");
} else {
icon = QIcon::fromTheme(iconpath);
}
}
m_optionView->show();
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString showname = fontMetrics.elidedText(m_name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号
m_nameLabel->setText(showname);
if (QString::compare(showname, m_name)) {
m_nameLabel->setToolTip(m_name);
}
m_typeLabel->setText(tr("Application"));
}
void SearchDetailView::closeWebWidget()
{
// if (m_webView) {
// m_webView->close();
// m_webView = NULL;
// }
}
/**
* @brief SearchDetailView::doubleClickAction
* @param type
* @param path
* @return
*/
bool SearchDetailView::doubleClickAction(const int &type, const QString &path)
{
if (type == SearchListView::ResType::App && !path.contains(".desktop")) {
return installAppAction(path.mid(path.indexOf("/") + 1));
} else {
if (openAction(type, path)) {
writeConfigFile(path);
return true;
}
return false;
}
}
QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) {
QString htmlString;
@ -177,7 +315,7 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
m_hLine->show();
//文件和文件夹有一个额外的详情区域
if (type == SearchListView::ResType::Dir || type == SearchListView::ResType::File || type == SearchListView::ResType::Content || type == SearchListView::ResType::Best) {
if (type == SearchListView::ResType::Dir || type == SearchListView::ResType::File || type == SearchListView::ResType::Content) {
m_detailFrame->show();
if (isContent) { //文件内容区域
m_contentLabel->show();
@ -219,28 +357,14 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
//根据不同类型的搜索结果切换加载图片和名称的方式
switch (type) {
case SearchListView::ResType::App : {
QIcon icon = FileUtils::getAppIcon(path);
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString wholeName = FileUtils::getAppName(path);
QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号
m_nameLabel->setText(name);
if (QString::compare(name, wholeName)) {
m_nameLabel->setToolTip(wholeName);
}
m_typeLabel->setText(tr("Application"));
break;
}
case SearchListView::ResType::Content:
case SearchListView::ResType::Best:
case SearchListView::ResType::Dir :
case SearchListView::ResType::File : {
QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString wholeName = FileUtils::getFileName(path);
QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 215);
QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 274);
m_nameLabel->setText(name);
if (QString::compare(name, wholeName)) {
m_nameLabel->setToolTip(wholeName);
@ -290,6 +414,9 @@ void SearchDetailView::execActions(const int& type, const int& option, const QSt
copyPathAction(path);
break;
}
case OptionView::Options::Install: {
installAppAction(m_pkgname); //未安装应用点击此选项,不使用路径作为参数,而是使用软件名
}
default:
break;
}
@ -303,27 +430,26 @@ bool SearchDetailView::openAction(const int& type, const QString& path) {
switch (type) {
case SearchListView::ResType::App: {
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data());
g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr);
bool res = static_cast<bool>(g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr));
g_object_unref(desktopAppInfo);
return true;
return res;
break;
}
case SearchListView::ResType::Best:
case SearchListView::ResType::Content:
case SearchListView::ResType::Dir:
case SearchListView::ResType::File: {
QProcess process;
process.startDetached(QString("xdg-open %1").arg(path));
return true;
// QProcess process;
// process.startDetached(QString("xdg-open %1").arg(path));
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
break;
}
case SearchListView::ResType::Setting: {
//打开控制面板对应页面
QProcess process;
if (path.left(path.indexOf("/")).toLower() == "wallpaper")
process.startDetached(QString("ukui-control-center --background"));
else process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
return true;
return process.startDetached(QString("ukui-control-center --background"));
else return process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
break;
}
default:
@ -355,7 +481,24 @@ void SearchDetailView::initUI()
m_layout->setContentsMargins(16, 60, 16, 24);
this->setObjectName("detailView");
this->setStyleSheet("QWidget#detailView{background:transparent;}");
this->setFixedWidth(360);
this->setFixedWidth(378);
//没有网络的时候的提示信息
m_noNetFrame = new QFrame(this);
m_noNetFrame->setFixedSize(378, 140);
m_noNetLyt = new QVBoxLayout(m_noNetFrame);
m_noNetIconLabel = new QLabel(m_noNetFrame);
m_noNetIconLabel->setFixedHeight(98);
m_noNetIconLabel->setPixmap(QIcon(":/res/icons/net-disconnected.svg").pixmap(QSize(98, 86)));
m_noNetIconLabel->setAlignment(Qt::AlignCenter);
m_noNetTipsLabel = new QLabel(m_noNetFrame);
m_noNetTipsLabel->setText(tr("Preview is not avaliable"));
m_noNetTipsLabel->setAlignment(Qt::AlignCenter);
m_noNetFrame->setLayout(m_noNetLyt);
m_noNetLyt->addWidget(m_noNetIconLabel);
m_noNetLyt->addWidget(m_noNetTipsLabel);
m_noNetLyt->setSpacing(12);
m_noNetFrame->move((this->width() - m_noNetFrame->width()) / 2, 160);
//图标和名称、分割线区域
m_iconLabel = new QLabel(this);
@ -368,7 +511,7 @@ void SearchDetailView::initUI()
m_nameLabel->setStyleSheet("QLabel{font-size: 18px;}");
m_typeLabel->setStyleSheet("QLabel{font-size: 14px; color: palette(mid);}");
m_nameFrame->setFixedHeight(48);
m_nameLabel->setMaximumWidth(240);
m_nameLabel->setMaximumWidth(280);
m_nameLayout->addWidget(m_nameLabel);
m_nameLayout->addStretch();
m_nameLayout->addWidget(m_typeLabel);
@ -430,8 +573,6 @@ void SearchDetailView::initUI()
m_layout->addStretch();
this->clearLayout(); //初始化时隐藏所有控件
}
@ -482,9 +623,7 @@ bool SearchDetailView::addPanelShortcut(const QString& path) {
* @return
*/
bool SearchDetailView::openPathAction(const QString& path) {
QProcess process;
process.startDetached(QString("xdg-open %1").arg(path.left(path.lastIndexOf("/"))));
return true;
return QDesktopServices::openUrl(QUrl::fromLocalFile(path.left(path.lastIndexOf("/"))));
}
/**
@ -497,6 +636,31 @@ bool SearchDetailView::copyPathAction(const QString& path) {
return true;
}
/**
* @brief SearchDetailView::installAppAction
* @param name
* @return
*/
bool SearchDetailView::installAppAction(const QString & name)
{
QDBusInterface * interface = new QDBusInterface( "com.kylin.softwarecenter",
"/com/kylin/softwarecenter",
"com.kylin.utiliface",
QDBusConnection::sessionBus() );
if (interface->isValid()) {
//软件商店已打开,直接跳转
interface->call("show_search_result",name);
bool reply = QDBusReply<bool>(interface->call(QString("show_search_result"), name));
return reply;
} else {
//软件商店未打开,打开软件商店下载此软件
qDebug()<<"软件商店未打开,打开软件商店下载此软件"<<name;
QProcess process;
return process.startDetached(QString("kylin-software-center -find %1").arg(name));
}
}
void SearchDetailView::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
@ -513,3 +677,14 @@ void SearchDetailView::paintEvent(QPaintEvent *event) {
p.drawRoundedRect(rect, 4, 4);
return QWidget::paintEvent(event);
}
/**
* @brief RequestInterceptor::interceptRequest qwebengineview的Url请求
* @param info
*/
//void RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
//{
//当使用PC版搜索引擎时可以使用此方法获取用户点击的链接的url
// QUrl url = info.requestUrl();
// qDebug() <<"Request URL:" <<url;
//}

View File

@ -23,7 +23,12 @@
#include <QWidget>
//#include <QWebEngineView>
//#include <QWebEngineSettings>
//#include <QWebEngineProfile>
//#include <QWebEngineUrlRequestInterceptor>
#include <QDesktopServices>
#include "option-view.h"
#include "global-settings.h"
class SearchDetailView : public QWidget
{
@ -38,7 +43,10 @@ public:
bool isEmpty();
int getType();
bool isContent = false;
// void setWebWidget(const QString&);
void setWebWidget(const QString&);
void setAppWidget(const QString &name, const QString &path, const QString &icon, const QString &description);
void closeWebWidget();
bool doubleClickAction(const int&, const QString&);
protected:
void paintEvent(QPaintEvent *);
@ -52,12 +60,15 @@ private:
bool addPanelShortcut(const QString&);
bool openPathAction(const QString&);
bool copyPathAction(const QString&);
bool installAppAction(const QString&);
QString getHtmlText(const QString&, const QString&);
QString escapeHtml(const QString&);
bool writeConfigFile(const QString&);
bool m_isEmpty = true;
int m_type = 0;
QString m_path = 0;
QString m_name = 0; //目前只有未安装应用在打开软件商店时需要此参数
QString m_pkgname = 0; //目前只有未安装应用在打开软件商店时需要此参数
void initUI();
QLabel * m_iconLabel = nullptr;
@ -79,6 +90,16 @@ private:
QLabel * m_timeLabel_2 = nullptr;
QFrame * m_hLine_2 = nullptr;
OptionView * m_optionView = nullptr;
QFrame * m_noNetFrame = nullptr;
QVBoxLayout * m_noNetLyt = nullptr;
QLabel * m_noNetIconLabel = nullptr;
QLabel * m_noNetTipsLabel = nullptr;
// QWebEngineView * m_webView = nullptr;
// QWebEngineProfile * m_engineProfile = nullptr;
bool m_reload = false;
bool m_net_enable = true;
QString m_currentKeyword;
Q_SIGNALS:
void configFileChanged();
@ -86,4 +107,12 @@ private Q_SLOTS:
void execActions(const int&, const int&, const QString&);
};
//此类用于url拦截
//class RequestInterceptor : public QWebEngineUrlRequestInterceptor
//{
//public:
// explicit RequestInterceptor(QObject * parent = nullptr) : QWebEngineUrlRequestInterceptor(parent) {}
// virtual void interceptRequest(QWebEngineUrlRequestInfo & info) Q_DECL_OVERRIDE;
//};
#endif // SEARCHDETAILVIEW_H

View File

@ -21,13 +21,17 @@
#include "search-list-view.h"
#include <QDebug>
#include <QFileInfo>
#include "custom-style.h"
SearchListView::SearchListView(QWidget * parent, const QStringList& list, const int& type) : QTreeView(parent)
{
CustomStyle * style = new CustomStyle(GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString());
this->setStyle(style);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::SingleSelection);
m_model = new SearchItemModel;
m_model = new SearchItemModel(this);
m_item = new SearchItem;
m_item->setSearchList(type, list);
m_model->setItem(m_item);
@ -40,13 +44,24 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAutoFillBackground(false);
this->setStyleSheet("QWidget{background:transparent;}");
m_styleDelegate = new HighlightItemDelegate();
m_styleDelegate = new HighlightItemDelegate(this);
// m_styleDelegate->setSearchKeyword(keyword);
this->setItemDelegate(m_styleDelegate);
m_type = type;
connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ]() {
Q_EMIT this->currentRowChanged(getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row()));
connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ](const QItemSelection &selected, const QItemSelection &deselected) {
Q_EMIT this->currentRowChanged(this, getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row()));
m_isSelected = true;
if(!selected.isEmpty())
{
QRegion region = visualRegionForSelection(selected);
QRect rect = region.boundingRect();
Q_EMIT this->currentSelectPos(mapToParent(rect.topLeft()));
}
});
connect(this, &SearchListView::activated, this, [ = ](const QModelIndex& index) {
Q_EMIT this->onRowDoubleClicked(this, getCurrentType(), m_item->m_pathlist.at(index.row()));
});
}
@ -78,7 +93,7 @@ void SearchListView::setList(QStringList list)
{
QModelIndex index = this->currentIndex();
m_model->setList(list);
if (index.row() >= 0 && index.row() < list.length()) {
if (index.row() >= 0 && index.row() < list.length() && m_isSelected) {
this->blockSignals(true);
this->setCurrentIndex(index);
this->blockSignals(false);
@ -87,6 +102,16 @@ void SearchListView::setList(QStringList list)
this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4);
}
void SearchListView::setAppList(const QStringList &pathlist, const QStringList &iconlist)
{
m_model->setAppList(pathlist, iconlist);
}
void SearchListView::appendBestItem(const QPair<int, QString> &pair)
{
m_model->appendBestItem(pair);
}
/**
* @brief SearchListView::removeItem
*/
@ -131,6 +156,15 @@ int SearchListView::getLength()
return m_item->getCurrentSize();
}
void SearchListView::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
Q_EMIT mousePressed();
}
QTreeView::mousePressEvent(event);
}
//获取当前选项所属搜索类型
int SearchListView::getCurrentType() {
switch (m_type) {
@ -149,8 +183,11 @@ int SearchListView::getCurrentType() {
case SearchItem::SearchType::Contents:
// qDebug()<<"qDebug: One row selected, its type is content.";
return ResType::Content;
case SearchItem::SearchType::Web:
return ResType::Web;
default: //All或者Best的情况需要自己判断文件类型
return getResType(m_item->m_pathlist.at(this->currentIndex().row()));
// return getResType(m_item->m_pathlist.at(this->currentIndex().row()));
return ResType::Best;
break;
}
}
@ -162,17 +199,12 @@ int SearchListView::getCurrentType() {
*/
int SearchListView::getResType(const QString& path) {
if (path.endsWith(".desktop")) {
// qDebug()<<"qDebug: One row selected, its path is "<<path<<". Its type is application.";
return SearchListView::ResType::App;
} else if (QFileInfo(path).isFile()) {
// qDebug()<<"qDebug: One row selected, its path is "<<path<<". Its type is file.";
// return SearchListView::ResType::File;
return SearchListView::ResType::Best;
} else if (QFileInfo(path).isDir()) {
// qDebug()<<"qDebug: One row selected, its path is "<<path<<". Its type is dir.";
return SearchListView::ResType::Dir;
} else {
// qDebug()<<"qDebug: One row selected, its path is "<<path<<". Its type is setting.";
return SearchListView::ResType::Setting;
}
}
@ -182,4 +214,5 @@ int SearchListView::getResType(const QString& path) {
*/
void SearchListView::clearSelection() {
this->selectionModel()->clearSelection();
m_isSelected = false;
}

View File

@ -23,6 +23,7 @@
#include <QObject>
#include <QTreeView>
#include <QMouseEvent>
#include "model/search-item-model.h"
#include "model/search-item.h"
#include "highlight-item-delegate.h"
@ -40,7 +41,8 @@ public:
Setting,
Dir,
File,
Content
Content,
Web
};
int getCurrentType();
@ -51,22 +53,30 @@ public:
void appendItem(QString);
void setList(QStringList);
void setAppList(const QStringList&, const QStringList&);
void appendBestItem(const QPair<int, QString>&);
void removeItem(QString);
void clear();
void setKeyword(QString);
int getType();
int getLength();
bool isHidden = false;
protected:
void mousePressEvent(QMouseEvent *event) override;
private:
SearchItemModel * m_model = nullptr;
SearchItem * m_item = nullptr;
bool m_isSelected = false;
HighlightItemDelegate * m_styleDelegate = nullptr;
int m_type;
Q_SIGNALS:
void currentRowChanged(const int&, const QString&);
void currentRowChanged(SearchListView *,const int&, const QString&);
void onRowDoubleClicked(SearchListView *, const int&, const QString&);
void currentSelectPos(QPoint pos);
void mousePressed();
public Q_SLOTS:
void clearSelection();

18
src/custom-style.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "custom-style.h"
CustomStyle::CustomStyle(const QString &proxyStyleName, QObject *parent) : QProxyStyle(proxyStyleName)
{
}
QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
{
switch (type) {
case CT_ItemViewItem: {
QSize size(0, GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toDouble() * 2);
return size;
} break;
default: break;
}
return QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
}

14
src/custom-style.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef CUSTOMSTYLE_H
#define CUSTOMSTYLE_H
#include <QProxyStyle>
#include "global-settings.h"
class CustomStyle : public QProxyStyle
{
Q_OBJECT
public:
explicit CustomStyle(const QString &proxyStyleName = "windows",QObject *parent = nullptr);
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const;
};
#endif // CUSTOMSTYLE_H

View File

@ -23,7 +23,7 @@
/**
* @brief ukui-search顶部搜索界面
*/
SeachBarWidget::SeachBarWidget()
SeachBarWidget::SeachBarWidget(QWidget *parent):QWidget(parent)
{
}
@ -54,7 +54,7 @@ SeachBar::~SeachBar()
/**
* @brief
*/
SearchBarHLayout::SearchBarHLayout()
SearchBarHLayout::SearchBarHLayout(QWidget *parent):QHBoxLayout(parent)
{
initUI();
@ -86,6 +86,11 @@ SearchBarHLayout::~SearchBarHLayout()
delete m_timer;
m_timer = NULL;
}
if(m_queryLineEdit)
{
delete m_queryLineEdit;
m_queryLineEdit = nullptr;
}
}
/**
@ -93,12 +98,13 @@ SearchBarHLayout::~SearchBarHLayout()
*/
void SearchBarHLayout::initUI()
{
m_queryLineEdit = new SearchLineEdit;
m_queryLineEdit = new SearchLineEdit();
m_queryLineEdit->installEventFilter(this);
m_queryLineEdit->setTextMargins(30,1,0,1);
this->setContentsMargins(0,0,0,0);
this->setAlignment(m_queryLineEdit,Qt::AlignCenter);
this->addWidget(m_queryLineEdit);
m_queryWidget = new QWidget(m_queryLineEdit);
m_queryWidget->setFocusPolicy(Qt::NoFocus);
m_queryWidget->setStyleSheet("border:0px;background:transparent");
@ -139,6 +145,11 @@ void SearchBarHLayout::initUI()
});
}
void SearchBarHLayout::effectiveSearchRecord()
{
m_queryLineEdit->record();
}
void SearchBarHLayout::focusIn() {
m_queryLineEdit->setFocus();
}
@ -201,6 +212,14 @@ SearchLineEdit::SearchLineEdit()
// this->setContextMenuPolicy(Qt::NoContextMenu);
this->setMaxLength(100);
m_completer = new QCompleter(this);
m_model = new QStringListModel(this);
m_model->setStringList(GlobalSettings::getInstance()->getSearchRecord());
m_completer->setModel(m_model);
m_completer->setCompletionMode(QCompleter::InlineCompletion);
m_completer->setMaxVisibleItems(14);
setCompleter(m_completer);
//这是搜索框图标,要改
// QAction *searchAction = new QAction(this);
@ -213,6 +232,18 @@ SearchLineEdit::SearchLineEdit()
QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this,QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged);
connect(this, &QLineEdit::textChanged, this, [=](){
m_isRecorded = false;
});
}
void SearchLineEdit::record()
{
if(m_isRecorded == true||text().size() <= 1||text().isEmpty())
return;
GlobalSettings::getInstance()->setSearchRecord(text(),QDateTime::currentDateTime());
m_isRecorded = true;
m_model->setStringList(GlobalSettings::getInstance()->getSearchRecord());
}
SearchLineEdit::~SearchLineEdit()

View File

@ -26,13 +26,18 @@
#include <QPainter>
#include <QAction>
#include <QTimer>
#include <QStringListModel>
#include <QCompleter>
#include <QAbstractItemView>
#include <QVector4D>
#include "global-settings.h"
class SearchLineEdit;
class SeachBarWidget:public QWidget
{
public:
SeachBarWidget();
SeachBarWidget(QWidget *parent = nullptr);
~SeachBarWidget();
};
@ -50,7 +55,7 @@ class SearchBarHLayout : public QHBoxLayout
{
Q_OBJECT
public:
SearchBarHLayout();
SearchBarHLayout(QWidget *parent = nullptr);
~SearchBarHLayout();
void clearText();
QString text();
@ -74,6 +79,8 @@ private:
Q_SIGNALS:
void textChanged(QString text);
public Q_SLOTS:
void effectiveSearchRecord();
};
class SearchBarWidgetLayout : public QHBoxLayout
@ -97,8 +104,13 @@ class SearchLineEdit : public QLineEdit
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
public:
SearchLineEdit();
void record();
~SearchLineEdit();
private Q_SLOTS:
void lineEditTextChanged(QString arg);
private:
QStringListModel *m_model = nullptr;
QCompleter *m_completer= nullptr;
bool m_isRecorded = false;
};

View File

@ -29,20 +29,18 @@
#include <QLocale>
#include <X11/Xlib.h>
#include <syslog.h>
#include <ukui-log4qt.h>
#include <QObject>
#include "qt-single-application.h"
#include "qt-local-peer.h"
//#include "inotify-manager.h"
#include "libsearch.h"
#include "global-settings.h"
#include "xatom-helper.h"
//void handler(int){
// qDebug() << "Recieved SIGTERM!";
// GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE, "2");
// GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE, "2");
// GlobalSettings::getInstance()->setValue(INDEX_GENERATOR_NORMAL_EXIT, "2");
@ -52,16 +50,15 @@
// GlobalSettings::getInstance()->forceSync(INDEX_GENERATOR_NORMAL_EXIT);
// GlobalSettings::getInstance()->forceSync(INOTIFY_NORMAL_EXIT);
// qDebug() << "indexDataBaseStatus: " << GlobalSettings::getInstance()->getValue(INDEX_DATABASE_STATE).toString();
// qDebug() << "contentIndexDataBaseStatus: " << GlobalSettings::getInstance()->getValue(CONTENT_INDEX_DATABASE_STATE).toString();
// ::exit(0);
//// InotifyIndex::getInstance("/home")->~InotifyIndex();
// InotifyIndex::getInstance("/home")->~InotifyIndex();
// //wait linux kill this thread forcedly
//// while (true);
// while (true);
//}
@ -72,6 +69,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
bool showDebug = true;
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search/ukui-search.log";
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search.log";
if (!QFile::exists(logFilePath)) {
showDebug = false;
@ -123,23 +121,52 @@ void centerToScreen(QWidget* widget) {
int main(int argc, char *argv[])
{
unlink(UKUI_SEARCH_PIPE_PATH);
int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777);
if(retval == -1)
//Init log module
initUkuiLog4qt("ukui-search");
// Determine whether the home directory has been created, and if not, keep waiting.
char *p_home = NULL;
unsigned int i = 0;
while(p_home == NULL)
{
perror("creat fifo error\n");
assert(false);
return -1;
::sleep(1);
++i;
p_home = getenv("HOME");
if(i%5==0)
{
qWarning()<<"I can't find home! I'm done here!!";
printf("I can't find home! I'm done here!!");
syslog(LOG_ERR,"I can't find home! I'm done here!!\n");
}
}
p_home = NULL;
while(!QDir(QDir::homePath()).exists())
{
qWarning()<<"Home is not exits!!";
printf("Home is not exits!!");
syslog(LOG_ERR,"Home is not exits!!\n");
::sleep(1);
}
printf("create fifo success\n");
// Output log to file
// qInstallMessageHandler(messageOutput);
qInstallMessageHandler(messageOutput);
// Register meta type
qDebug() << "ukui-search main start";
qRegisterMetaType<QPair<QString,QStringList>>("QPair<QString,QStringList>");
qRegisterMetaType<Document>("Document");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
// If qt version bigger than 5.12, enable high dpi scaling and use high dpi pixmaps?
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
// Make sure only one ukui-search is running.
QtSingleApplication app("ukui-search", argc, argv);
app.setQuitOnLastWindowClosed(false);
@ -156,15 +183,27 @@ int main(int argc, char *argv[])
parser.process(app);
}*/
// Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running.
QDir fifoDir = QDir(QDir::homePath()+"/.config/org.ukui/ukui-search");
if(!fifoDir.exists())
qDebug()<<"create fifo path"<<fifoDir.mkpath(fifoDir.absolutePath());
//here need to be modified
/*-------------ukuisearchdbus Test start-----------------*/
unlink(UKUI_SEARCH_PIPE_PATH);
int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777);
if(retval == -1)
{
qCritical()<<"creat fifo error!!";
syslog(LOG_ERR,"creat fifo error!!\n");
assert(false);
return -1;
}
qDebug()<<"create fifo success\n";
// Set max_user_watches to a number which is enough big.
UkuiSearchQDBus usQDBus;
usQDBus.setInotifyMaxUserWatches();
/*-------------ukuisearchdbus Test End-----------------*/
//load chinese character and pinyin file to a Map
// load chinese character and pinyin file to a Map
FileUtils::loadHanziTable("://index/pinyinWithoutTone.txt");
/*-------------InotyifyRefact Test Start---------------*/
// QTime t1 = QTime::currentTime();
@ -191,7 +230,7 @@ int main(int argc, char *argv[])
// search->onKeywordSearchContent("g,e,x");
/*-------------文本搜索 Test End-----------------*/
// 加载国际化文件
// Load translations
QTranslator translator;
try {
if (! translator.load("/usr/share/ukui-search/translations/" + QLocale::system().name())) throw -1;
@ -208,56 +247,48 @@ int main(int argc, char *argv[])
qDebug() << "Load translations file" << QLocale() << "failed!";
}
//set main window to the center of screen
MainWindow *w = new MainWindow;
QStringList arguments = QCoreApplication::arguments();
// centerToScreen(w);
w->moveToPanel();
// w->moveToPanel();
centerToScreen(w);
//使用窗管的无边框策略
w->setProperty("useStyleWindowManager", false); //禁用拖动
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), hints);
// w->setProperty("useStyleWindowManager", false); //禁用拖动
// MotifWmHints hints;
// hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
// hints.functions = MWM_FUNC_ALL;
// hints.decorations = MWM_DECOR_BORDER;
// XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), hints);
app.setActivationWindow(w);
// Processing startup parameters
if (QString::compare(QString("-s"), QString(QLatin1String(argv[1]))) == 0) {
w->moveToPanel();
// w->moveToPanel();
centerToScreen(w);
XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), w->m_hints);
w->show();
}
// if(arguments.size()>1)
// w->searchContent(arguments.at(1));
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),w, SLOT(bootOptionsFilter(const QString&)));
// qDebug() << "main start";
// FirstIndex* fi = new FirstIndex("/home");
// fi->start();
qDebug() << "main start";
QObject::connect(&app, &QtSingleApplication::messageReceived, w, &MainWindow::bootOptionsFilter);
// Start app search thread
AppMatch::getAppMatch()->start();
// TODO
// Set threads which in global thread pool expiry time in 5ms, some prolems here
QThreadPool::globalInstance()->setExpiryTimeout(5);
// QThreadPool::globalInstance()->clear();
// setAutoDelete(true);
// FirstIndex fi("/home/zhangzihao/Desktop/qwerty");
// FirstIndex* fi = new FirstIndex("/home/zhangzihao/Desktop/qwerty");
// TODO
// First insdex start, the parameter us useless, should remove the parameter
FirstIndex fi("/home/zhangzihao/Desktop");
fi.start();
// fi.wait();
// fi->wait();
// fi->exit();
// delete fi;
// assert(false);
// TODO
// Inotify index start, the parameter us useless, should remove the parameter
InotifyIndex* ii = InotifyIndex::getInstance("/home");
// InotifyIndex ii("/home");
ii->start();
// qDebug() << "sigset start!";
// sigset( SIGTERM, handler);
// qDebug() << "sigset end!";
return app.exec();
}

View File

@ -53,17 +53,8 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
m_searcher = new FileSearcher();
// FileUtils::findMultiToneWords("仇仇仇仇仇仇仇仇仇仇仇翟康宁test");
/*-------------Inotify Test Start---------------*/
// QTime t1 = QTime::currentTime();
// InotifyManagerRefact* im = new InotifyManagerRefact("/home");
// im->Traverse();
// QTime t2 = QTime::currentTime();
// qDebug() << t1;
// qDebug() << t2;
// im->start();
/*-------------Inotify Test End-----------------*/
m_searcher = new SearchManager(this);
m_settingsMatch = new SettingsMatch(this);
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
@ -75,10 +66,17 @@ MainWindow::MainWindow(QWidget *parent) :
this->setWindowTitle(tr("ukui-search"));
initUi();
// setProperty("useStyleWindowManager", false); //禁止拖动
m_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
m_hints.functions = MWM_FUNC_ALL;
m_hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
// path.addRoundedRect(rect, 0, 0);
path.addRect(rect);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
@ -90,25 +88,36 @@ MainWindow::MainWindow(QWidget *parent) :
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) {
this->setPalette(pal);
this->update();
Q_FOREACH (QWidget *widget, this->findChildren<QWidget *>()) {
if (widget) {
widget->update();
}
}
});
m_search_result_file = new QQueue<QString>;
m_search_result_dir = new QQueue<QString>;
m_search_result_content = new QQueue<QPair<QString,QStringList>>;
m_search_result_thread = new SearchResult(this);
m_seach_app_thread = new SearchAppThread(this);
// m_search_result_thread->start();
connect(m_search_result_thread, &SearchResult::searchResultFile, this, [ = ](QString path) {
qDebug()<<"Append a file into list: "<<path;
// qDebug()<<"Append a file into list: "<<path;
m_contentFrame->appendSearchItem(SearchItem::SearchType::Files, path);
});
connect(m_search_result_thread, &SearchResult::searchResultDir, this, [ = ](QString path) {
qDebug()<<"Append a dir into list: "<<path;
// qDebug()<<"Append a dir into list: "<<path;
m_contentFrame->appendSearchItem(SearchItem::SearchType::Dirs, path);
});
connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair<QString, QStringList> pair) {
qDebug()<<"Append a file content into list: "<<pair.first;
// qDebug()<<"Append a file content into list: "<<pair.first;
m_contentFrame->appendSearchItem(SearchItem::SearchType::Contents, pair.first, pair.second);
});
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
connect(m_seach_app_thread, &SearchAppThread::searchResultApp, this, [ = ](const QVector<QStringList>& applist) {
qDebug()<<"Append applist: "<<applist;
m_contentFrame->setAppList(applist);
});
m_sys_tray_icon = new QSystemTrayIcon(this);
m_sys_tray_icon->setIcon(QIcon::fromTheme("system-search-symbolic"));
@ -117,11 +126,22 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_sys_tray_icon,&QSystemTrayIcon::activated,this,[=](QSystemTrayIcon::ActivationReason reason){
if(reason == QSystemTrayIcon::Trigger)
{
clearSearchResult();
this->moveToPanel();
this->show();
this->raise();
this->activateWindow();
if (!this->isVisible()) {
clearSearchResult();
// this->moveToPanel();
centerToScreen(this);
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
this->show();
this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入
this->raise();
this->activateWindow();
} else {
this->hide();
m_contentFrame->closeWebView();
m_search_result_thread->requestInterruption();
m_search_result_thread->quit();
// m_seach_app_thread->stop();
}
}
});
}
@ -148,18 +168,17 @@ MainWindow::~MainWindow()
*/
void MainWindow::initUi()
{
this->setFixedSize(640, 640);
this->setFixedSize(640, 590);
m_frame = new QFrame(this);
this->setCentralWidget(m_frame);
QVBoxLayout * mainlayout = new QVBoxLayout(m_frame);
mainlayout->setContentsMargins(16, 0, 16, 16);
mainlayout->setContentsMargins(8, 0, 8, 6);
m_frame->setLayout(mainlayout);
m_frame->setStyleSheet("QLabel{color: palette(text);}");
m_titleFrame = new QFrame(m_frame);//标题栏
m_titleFrame->setFixedHeight(48);
m_titleFrame->setFixedHeight(40);
m_titleLyt = new QHBoxLayout(m_titleFrame);
m_titleLyt->setContentsMargins(0, 0, 0, 0);
m_iconLabel = new QLabel(m_titleFrame);
@ -168,7 +187,7 @@ void MainWindow::initUi()
m_titleLabel = new QLabel(m_titleFrame);
m_titleLabel->setText(tr("Search"));
m_menuBtn = new QPushButton(m_titleFrame);
m_menuBtn->setFixedSize(24, 24);
m_menuBtn->setFixedSize(30, 30);
// m_menuBtn->setIcon(QIcon(":/res/icons/commonuse.svg"));
m_menuBtn->setIcon(QIcon::fromTheme("document-properties-symbolic"));
m_menuBtn->setProperty("useIconHighlightEffect", 0x2);
@ -176,15 +195,18 @@ void MainWindow::initUi()
m_menuBtn->setFlat(true);
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
if (m_settingsWidget) { //当此窗口已存在时,仅需置顶
if (!m_settingsWidget->isVisible()) {
centerToScreen(m_settingsWidget);
}
m_settingsWidget->showWidget();
return;
}
m_settingsWidget = new SettingsWidget();
centerToScreen(m_settingsWidget);
m_settingsWidget->show();
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
QTimer::singleShot(100, this, [ = ] {
clearSearchResult();
// m_search_result_thread->start();
// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
this->raise();
this->showNormal();
@ -199,15 +221,15 @@ void MainWindow::initUi()
m_contentFrame = new ContentWidget(m_frame);//内容栏
m_searchWidget = new SeachBarWidget;
m_searchLayout = new SearchBarHLayout;
m_searchWidget = new SeachBarWidget(this);
m_searchLayout = new SearchBarHLayout(this);
m_searchWidget->setLayout(m_searchLayout);
m_searchWidget->setFixedHeight(44);
mainlayout->addWidget(m_titleFrame);
mainlayout->addWidget(m_contentFrame);
mainlayout->addWidget(m_searchWidget);
mainlayout->setContentsMargins(16, 0, 16, 10);
connect(m_contentFrame,&ContentWidget::mousePressed,m_searchLayout,&SearchBarHLayout::effectiveSearchRecord);
connect(QApplication::primaryScreen(), &QScreen::geometryChanged,
this, &MainWindow::monitorResolutionChange);
@ -219,6 +241,7 @@ void MainWindow::initUi()
m_search_result_thread->requestInterruption();
m_search_result_thread->quit();
}
// m_seach_app_thread->stop();
m_contentFrame->setCurrentIndex(0);
} else {
m_contentFrame->setCurrentIndex(1);
@ -247,8 +270,11 @@ void MainWindow::bootOptionsFilter(QString opt)
{
if (opt == "-s" || opt == "--show") {
clearSearchResult();
this->moveToPanel();
// this->moveToPanel();
centerToScreen(this);
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
this->show();
this->m_searchLayout->focusIn();
this->raise();
this->activateWindow();
// m_search_result_thread->start();
@ -291,27 +317,21 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen)
* @brief searchContent
* @param searchcontent
*/
void MainWindow::searchContent(QString searchcontent){
m_app_setting_lists.clear();
m_contentFrame->setKeyword(searchcontent);
void MainWindow::searchContent(QString keyword){
m_contentFrame->setKeyword(keyword);
// m_search_result_file->clear();
// m_search_result_dir->clear();
// m_search_result_content->clear();
AppMatch * appMatchor = new AppMatch(this);
SettingsMatch * settingMatchor = new SettingsMatch(this);
//应用与设置搜索
QStringList appList;
appList = appMatchor->startMatchApp(searchcontent);
//设置搜索
QStringList settingList;
settingList = settingMatchor->startMatchApp(searchcontent);
m_app_setting_lists.append(appList);
m_app_setting_lists.append(settingList);
m_contentFrame->refreshSearchList(m_app_setting_lists);
settingList = m_settingsMatch->startMatchApp(keyword);
m_contentFrame->resetSearchList();
m_contentFrame->setSettingList(settingList);
//应用搜索
// m_seach_app_thread->stop();
m_seach_app_thread->startSearch(keyword);
//文件、文件夹、内容搜索
this->m_searcher->onKeywordSearch(searchcontent, m_search_result_file, m_search_result_dir, m_search_result_content);
this->m_searcher->onKeywordSearch(keyword, m_search_result_file, m_search_result_dir, m_search_result_content);
}
/**
@ -322,6 +342,25 @@ void MainWindow::moveToPanel()
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
QRect screenGeometry = qApp->primaryScreen()->geometry();
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/wayland",
"org.ukui.SettingsDaemon.wayland",
QDBusConnection::sessionBus());
if (QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
QDBusReply<int> x = primaryScreenInterface.call("x");
QDBusReply<int> y = primaryScreenInterface.call("y");
QDBusReply<int> width = primaryScreenInterface.call("width");
QDBusReply<int> height = primaryScreenInterface.call("height");
screenGeometry.setX(x);
screenGeometry.setY(y);
screenGeometry.setWidth(width);
screenGeometry.setHeight(height);
availableGeometry.setX(x);
availableGeometry.setY(y);
availableGeometry.setWidth(width);
availableGeometry.setHeight(height);
}
QDesktopWidget * desktopWidget = QApplication::desktop();
QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小
@ -331,32 +370,50 @@ void MainWindow::moveToPanel()
QDBusConnection::sessionBus() );
int position = QDBusReply<int>(interface.call("GetPanelPosition", "position"));
int height = QDBusReply<int>(interface.call("GetPanelPosition", "height"));
int d = 2; //窗口边沿到任务栏距离
int height = QDBusReply<int>(interface.call("GetPanelSize", "height"));
int d = 8; //窗口边沿到任务栏距离
if (position == 0) {
//任务栏在下侧
this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - height - d);
this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenGeometry.y() + screenGeometry.height() - this->height() - height - d);
} else if(position == 1) {
//任务栏在上侧
this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + height + d);
this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenGeometry.y() + height + d);
} else if (position == 2) {
//任务栏在左侧
if (screenGeometry.x() == 0) {//主屏在左侧
this->move(height + d, screenMainRect.y() + screenMainRect.height() - this->height());
} else {//主屏在右侧
this->move(screenMainRect.x() + height + d, screenMainRect.y() + screenMainRect.height() - this->height());
}
this->move(screenGeometry.x() + height + d, screenGeometry.y() + screenGeometry.height() - this->height() - d);
} else if (position == 3) {
//任务栏在右侧
if (screenGeometry.x() == 0) {//主屏在左侧
this->move(screenMainRect.width() - this->width() - height - d, screenMainRect.y() + screenMainRect.height() - this->height());
} else {//主屏在右侧
this->move(screenMainRect.x() + screenMainRect.width() - this->width() - height - d, screenMainRect.y() + screenMainRect.height() - this->height());
}
this->move(screenGeometry.x() + screenGeometry.width() - this->width() - height - d, screenGeometry.y() + screenGeometry.height() - this->height() - d);
}
}
/**
* @brief MainWindow::centerToScreen 使
* @param widget
*/
void MainWindow::centerToScreen(QWidget* widget) {
if (!widget)
return;
QDesktopWidget* m = QApplication::desktop();
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
int desk_x = desk_rect.width();
int desk_y = desk_rect.height();
int x = widget->width();
int y = widget->height();
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/wayland",
"org.ukui.SettingsDaemon.wayland",
QDBusConnection::sessionBus());
if (QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
QDBusReply<int> width = primaryScreenInterface.call("width");
QDBusReply<int> height = primaryScreenInterface.call("height");
desk_x = width;
desk_y = height;
}
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
}
//使用GSetting获取当前窗口应该使用的透明度
double MainWindow::getTransparentData()
{
@ -382,8 +439,12 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
switch (event->response_type & ~0x80) {
case XCB_FOCUS_OUT:
this->hide();
m_contentFrame->closeWebView();
m_search_result_thread->requestInterruption();
m_search_result_thread->quit();
// m_seach_app_thread->stop();
break;
default:
break;
}
@ -394,8 +455,10 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
this->hide();
m_contentFrame->closeWebView();
m_search_result_thread->requestInterruption();
m_search_result_thread->quit();
// m_seach_app_thread->stop();
}
return QWidget::keyPressEvent(event);
}
@ -414,7 +477,8 @@ void MainWindow::paintEvent(QPaintEvent *event) {
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
// p.drawRoundedRect(rect, 6, 6);
p.drawRect(rect);
return QWidget::paintEvent(event);
}

View File

@ -43,11 +43,14 @@
#include <QKeyEvent>
#include <QGSettings/QGSettings>
#include <QSystemTrayIcon>
#include "content-widget.h"
#include "input-box.h"
#include "index/index-generator.h"
#include "settings-widget.h"
#include "libsearch.h"
#include "search-app-thread.h"
#include "xatom-helper.h"
class SearchResult;
class MainWindow : public QMainWindow
@ -61,41 +64,47 @@ public:
/**
* @brief Load the main window
*/
void searchContent(QString searchcontent);
// The parameter:keyword is the word or sentence which users want to search.
void searchContent(QString keyword);
// The position which mainwindow shows follow the ukui-panel.
void moveToPanel();
// The position which mainwindow shows in the center of screen where the cursor in.
void centerToScreen(QWidget* widget);
MotifWmHints m_hints;
private:
bool nativeEvent(const QByteArray&, void *, long *);
QFrame * m_line = nullptr;//Vertical dividing line
QFrame * m_frame = nullptr;
// MainWindow quit when focus out.
bool nativeEvent(const QByteArray&, void*, long*);
QFrame * m_titleFrame = nullptr;//标题栏
QHBoxLayout * m_titleLyt = nullptr;
QLabel * m_iconLabel = nullptr;
QLabel * m_titleLabel = nullptr;
QPushButton * m_menuBtn = nullptr;
SettingsWidget * m_settingsWidget = nullptr;
ContentWidget * m_contentFrame = nullptr;//内容栏
SeachBarWidget * m_searchWidget = nullptr;//搜索栏
SearchBarHLayout * m_searchLayout = nullptr;
bool m_winFlag = false;
QFrame * m_frame = nullptr; // Main frame
QFrame * m_titleFrame = nullptr; // Title bar frame
QHBoxLayout * m_titleLyt = nullptr; // Title layout
QLabel * m_iconLabel = nullptr; // Icon lable
QLabel * m_titleLabel = nullptr; // Title lable
QPushButton * m_menuBtn = nullptr; // Menu button
SettingsWidget * m_settingsWidget = nullptr; // Settings Widget
ContentWidget * m_contentFrame = nullptr; // Content frame
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
SeachBarWidget * m_searchWidget = nullptr; // Search bar
QGSettings * m_transparency_gsettings = nullptr;
double getTransparentData();
QVector<QStringList> m_app_setting_lists;
QStringList m_dirList;
QQueue<QString> *m_search_result_file = nullptr;
QQueue<QString> *m_search_result_dir = nullptr;
QQueue<QPair<QString,QStringList>> *m_search_result_content = nullptr;
SearchResult * m_search_result_thread = nullptr;
SearchAppThread * m_seach_app_thread = nullptr;
FileSearcher* m_searcher = nullptr;
SearchManager* m_searcher = nullptr;
SettingsMatch *m_settingsMatch = nullptr;
QSystemTrayIcon *m_sys_tray_icon;
protected:

View File

@ -21,7 +21,7 @@
#include "search-item-model.h"
#include <QDebug>
SearchItemModel::SearchItemModel()
SearchItemModel::SearchItemModel(QObject *parent) : QAbstractItemModel (parent)
{
}
@ -97,28 +97,28 @@ QVariant SearchItemModel::data(const QModelIndex &index, int role) const
if(!index.isValid())
return QVariant();
switch (index.column()) {
case Icon: {
switch (role) {
case Qt::DecorationRole: {
return m_item->getIcon(index.row());
}
default:
return QVariant();
}
case Icon: {
switch (role) {
case Qt::DecorationRole: {
return m_item->getIcon(index.row());
}
case Name: {
switch (role) {
case Qt::DisplayRole: {
return QVariant(m_item->getName(index.row()));
}
// case Qt::ForegroundRole: {
// return QColor(50, 50, 50);
// }
default:
return QVariant();
}
default:
return QVariant();
}
}
case Name: {
switch (role) {
case Qt::DisplayRole: {
return QVariant(m_item->getName(index.row()));
}
// case Qt::ForegroundRole: {
// return QColor(50, 50, 50);
// }
default:
return QVariant();
}
}
}
return QVariant();
}
@ -145,7 +145,7 @@ void SearchItemModel::appendItem(QString path) {
this->beginResetModel();
m_item->m_pathlist << path;
this->endResetModel();
// this->insertRow(rowCount(QModelIndex()) - 1);
// this->insertRow(rowCount(QModelIndex()) - 1);
}
/**
@ -159,6 +159,23 @@ void SearchItemModel::setList(QStringList list)
this->endResetModel();
}
void SearchItemModel::setAppList(const QStringList &pathlist, const QStringList &iconlist)
{
this->beginResetModel();
m_item->m_app_pathlist = pathlist;
m_item->m_app_iconlist = iconlist;
this->endResetModel();
}
/**
* @brief SearchItemModel::insertBestItem
* @param pair <>
*/
void SearchItemModel::appendBestItem(const QPair<int, QString> & pair)
{
m_item->m_bestList.append(pair);
}
/**
* @brief SearchItemModel::removeItem
*/
@ -172,3 +189,17 @@ void SearchItemModel::clear()
m_item->clear();
this->endResetModel();
}
/**
* @brief SearchItemModel::setBestAppIcon
* @param str
* @param is_installed
*/
void SearchItemModel::setBestAppIcon(const QString &str, const bool & is_installed)
{
if (is_installed) {
m_item->m_bestAppIcon = QIcon::fromTheme(str);
} else {
m_item->m_bestAppIcon = QIcon(str);
}
}

View File

@ -32,7 +32,7 @@ class SearchItemModel : public QAbstractItemModel
friend class SearchItem;
Q_OBJECT
public:
explicit SearchItemModel();
explicit SearchItemModel(QObject *parent = nullptr);
~SearchItemModel();
enum SearchInfo {
@ -54,8 +54,11 @@ public:
void appendItem(QString);
void setList(QStringList);
void setAppList(const QStringList&, const QStringList&);
void appendBestItem(const QPair<int, QString>&);
void removeItem(QString);
void clear();
void setBestAppIcon(const QString &, const bool &);
private :
SearchItem * m_item = nullptr;

View File

@ -45,18 +45,23 @@ QIcon SearchItem::getIcon(int index) {
case Dirs :
case Files : //文件,返回文件图标
return FileUtils::getFileIcon(QString("file://%1").arg(m_pathlist.at(index)));
case Apps : //应用,返回应用图标
return FileUtils::getAppIcon(m_pathlist.at(index));
case Best : {//最佳匹配,含全部类型,需要自己判断,返回不同类型的图标
// return QIcon(":/res/icons/edit-find-symbolic.svg");
if (m_pathlist.at(index).endsWith(".desktop")) {
return FileUtils::getAppIcon(m_pathlist.at(index));
} else if (QFileInfo(m_pathlist.at(index)).isFile() || QFileInfo(m_pathlist.at(index)).isDir()) {
return FileUtils::getFileIcon(QString("file://%1").arg(m_pathlist.at(index)));
case Apps : {//应用,返回应用图标
// return FileUtils::getAppIcon(m_pathlist.at(index));
if (m_app_pathlist.length() > index && m_app_pathlist.at(index) == "") { //未安装,存储的是图标路径
return QIcon(m_app_iconlist.at(index));
} else if (m_app_pathlist.length() > index) { //已安装,存储的是图标名
if (QIcon::fromTheme(m_app_iconlist.at(index)).isNull()) {
return QIcon(":/res/icons/desktop.png");
} else {
return QIcon::fromTheme(m_app_iconlist.at(index));
}
} else {
return FileUtils::getSettingIcon(m_pathlist.at(index), false);
return QIcon(":/res/icons/desktop.png");
}
}
case Best : {//最佳匹配,含全部类型,需要自己判断,返回不同类型的图标
return getBestIcon(index);
}
default:
return QIcon(":/res/icons/edit-find-symbolic.svg");
}
@ -77,22 +82,70 @@ QString SearchItem::getName(int index) {
case Dirs :
case Files : //文件,返回文件名
return FileUtils::getFileName(m_pathlist.at(index));
case Apps : //应用,返回应用名
return FileUtils::getAppName(m_pathlist.at(index));
case Apps : {//应用,返回应用名
QString whole_name = m_pathlist.at(index);
QString app_name = whole_name.contains("/") ? whole_name.left(whole_name.indexOf("/")) : whole_name;
return app_name;
}
case Best : //最佳匹配,含全部类型,需要自己判断,返回不同类型的名称
// return m_pathlist.at(index);
if (m_pathlist.at(index).endsWith(".desktop")) {
return FileUtils::getAppName(m_pathlist.at(index));
} else if (QFileInfo(m_pathlist.at(index)).isFile() || QFileInfo(m_pathlist.at(index)).isDir()) {
return FileUtils::getFileName(m_pathlist.at(index));
} else {
return FileUtils::getSettingName(m_pathlist.at(index));
}
return getBestName(index);
default:
return m_pathlist.at(index);
}
}
/**
* @brief SearchItem::getBestIcon
* @param index
* @return
*/
QIcon SearchItem::getBestIcon(const int &index)
{
// if (m_pathlist.at(index).endsWith(".desktop")) {
// return FileUtils::getAppIcon(m_pathlist.at(index));
// } else if (QFileInfo(m_pathlist.at(index)).isFile() || QFileInfo(m_pathlist.at(index)).isDir()) {
// return FileUtils::getFileIcon(QString("file://%1").arg(m_pathlist.at(index)));
// } else {
// return FileUtils::getSettingIcon(m_pathlist.at(index), false);
// }
if (m_bestList.isEmpty() || !m_bestList.length() > index) return QIcon::fromTheme("unknown");
switch(m_bestList.at(index).first) {
case Apps: {
return this->m_bestAppIcon;
// return FileUtils::getAppIcon(m_pathlist.at(index));
}
case Settings: {
return FileUtils::getSettingIcon(m_pathlist.at(index), false);
}
default: {
return FileUtils::getFileIcon(QString("file://%1").arg(m_pathlist.at(index)));
}
}
}
/**
* @brief SearchItem::getBestName
* @param index
* @return
*/
QString SearchItem::getBestName(const int &index)
{
if (m_bestList.isEmpty() || !m_bestList.length() > index) return "";
switch(m_bestList.at(index).first) {
case Apps: {
QString whole_name = m_bestList.at(index).second;
QString app_name = whole_name.contains("/") ? whole_name.left(whole_name.indexOf("/")) : whole_name;
return app_name;
}
case Settings: {
return FileUtils::getSettingName(m_pathlist.at(index));
}
default: {
return FileUtils::getFileName(m_pathlist.at(index));
}
}
}
/**
* @brief SearchItem::setSearchList
* @param type
@ -117,4 +170,7 @@ int SearchItem::getCurrentSize() {
void SearchItem::clear()
{
m_pathlist.clear();
m_app_pathlist.clear();
m_app_iconlist.clear();
m_bestList.clear();
}

View File

@ -41,7 +41,8 @@ public:
Settings,
Dirs,
Files,
Contents
Contents,
Web
};
void setSearchList(const int&, const QStringList&);
@ -55,9 +56,16 @@ private:
int m_searchtype = 0;
QStringList m_pathlist;
QStringList m_app_pathlist;
QStringList m_app_iconlist;
QList<QPair<int, QString>> m_bestList;
QIcon m_bestAppIcon = QIcon::fromTheme("unknown"); //由于未安装应用与已安装应用获取图标方式不一致,故引入此变量直接存储最佳匹配应用图标
QIcon getIcon(int);
QString getName(int);
QIcon getBestIcon(const int &);
QString getBestName(const int &);
Q_SIGNALS:

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="98px" height="87px" viewBox="0 0 98 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 59 (86127) - https://sketch.com -->
<title>image-viewer-app-symbolic</title>
<desc>Created with Sketch.</desc>
<defs>
<filter x="-2.4%" y="-2.7%" width="104.7%" height="105.3%" filterUnits="objectBoundingBox" id="filter-1">
<feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
</defs>
<g id="综合搜索" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.200000003">
<g id="搜索结果——网页" transform="translate(-883.000000, -627.000000)">
<g id="编组-2" filter="url(#filter-1)" transform="translate(447.000000, 427.000000)">
<g id="image-viewer-app-symbolic" transform="translate(436.000000, 200.000000)">
<g id="图层_2" transform="translate(4.000000, 5.000000)">
<path d="M24,72 L12,72 C5.4,72 0,66.6 0,60 L0,12 C0,5.4 5.4,0 12,0 L78,0 C84.6,0 90,5.4 90,12 L90,60" id="路径" stroke="#1F2022" stroke-width="6" stroke-linecap="round"></path>
<path d="M51,15 C34.2,15 21,28.2 21,45 C21,61.8 34.2,75 51,75 C67.8,75 81,61.8 81,45 C81,28.2 67.8,15 51,15 Z M51,21 C64.2,21 75,31.8 75,45 C75,58.2 64.2,69 51,69 C37.8,69 27,58.2 27,45 C27,31.8 37.8,21 51,21 Z" id="circle2567-9" fill="#1F2022" fill-rule="nonzero"></path>
<path d="M71.4,60.6 L67.2,64.8 L80.1,77.7 C81.259798,78.859798 83.140202,78.859798 84.3,77.7 C85.459798,76.540202 85.459798,74.659798 84.3,73.5 L71.4,60.6 L71.4,60.6 Z" id="path2570-36" fill="#1F2022"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -4,5 +4,6 @@
<file>res/icons/desktop.png</file>
<file>res/icons/close.svg</file>
<file>res/qt-translations/qt_zh_CN.qm</file>
<file>res/icons/net-disconnected.svg</file>
</qresource>
</RCC>

85
src/search-app-thread.cpp Normal file
View File

@ -0,0 +1,85 @@
#include "search-app-thread.h"
size_t uniqueSymbol = 0;
QMutex m_mutex;
SearchAppThread::SearchAppThread(QObject *parent) : QObject(parent)
{
m_pool.setMaxThreadCount(1);
m_pool.setExpiryTimeout(1000);
}
void SearchAppThread::startSearch(const QString & keyword)
{
SearchApp *appsearch;
appsearch = new SearchApp(keyword);
// appsearch->setKeyword(keyword);
connect(appsearch, &SearchApp::searchResultApp, this, &SearchAppThread::searchResultApp);
m_pool.start(appsearch);
}
SearchApp::SearchApp(const QString& keyword, QObject * parent) : QObject(parent)
{
m_keyword = keyword;
}
SearchApp::~SearchApp()
{
}
///**
// * @brief SearchAppThread::startSearch 激活线程
// * @param keyword 关键词
// */
//void SearchApp::setKeyword(const QString & keyword)
//{
// m_keyword = keyword;
//}
void SearchApp::run()
{
m_mutex.lock();
uniqueSymbol++;
m_mutex.unlock();
//nameList:应用名pathList:已安装的是.desktop路径未安装为空iconList:已安装的是图标名,未安装的是图标路径
QStringList nameList, pathList, iconList, descList;
QVector<QStringList> appVector;
AppMatch::getAppMatch()->startMatchApp(m_keyword, m_installed_apps, m_uninstalled_apps);
QMapIterator<NameString,QStringList> installed_iter(m_installed_apps);
while(installed_iter.hasNext())
{
installed_iter.next();
nameList << installed_iter.key().app_name;
pathList << installed_iter.value().at(0);
iconList << installed_iter.value().at(1);
descList << installed_iter.value().at(3);
}
QMapIterator<NameString,QStringList> uninstalled_iter(m_uninstalled_apps);
while(uninstalled_iter.hasNext())
{
uninstalled_iter.next();
QString name;
//当返回列表的value中含包名时将名称按“应用名/包名”的格式存储
if (!uninstalled_iter.value().at(2).isEmpty() && uninstalled_iter.value().at(2) != "") {
name = uninstalled_iter.key().app_name + "/" + uninstalled_iter.value().at(2);
} else name = uninstalled_iter.key().app_name;
nameList << name;
pathList << uninstalled_iter.value().at(0);
iconList << uninstalled_iter.value().at(1);
descList << uninstalled_iter.value().at(3);
}
appVector.append(nameList);
appVector.append(pathList);
appVector.append(iconList);
appVector.append(descList);
m_mutex.lock();
if (uniqueSymbol == uniqueSymbol) {
Q_EMIT this->searchResultApp(appVector);
}
m_mutex.unlock();
m_installed_apps.clear();
m_uninstalled_apps.clear();
}

40
src/search-app-thread.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef SEARCHAPPTHREAD_H
#define SEARCHAPPTHREAD_H
#include <QThread>
#include <QObject>
#include <QRunnable>
#include "libsearch.h"
class SearchAppThread : public QObject
{
Q_OBJECT
public:
SearchAppThread(QObject * parent = nullptr);
~SearchAppThread() = default;
void startSearch(const QString&);
private:
QThreadPool m_pool;
Q_SIGNALS:
void searchResultApp(const QVector<QStringList>&);
};
class SearchApp : public QObject, public QRunnable
{
Q_OBJECT
public:
SearchApp(const QString& keyword, QObject * parent = nullptr);
~SearchApp();
// void setKeyword(const QString&);
protected:
void run() override;
private:
QString m_keyword;
QMap<NameString,QStringList> m_installed_apps;
QMap<NameString,QStringList> m_uninstalled_apps;
Q_SIGNALS:
void searchResultApp(const QVector<QStringList>&);
};
#endif // SEARCHAPPTHREAD_H

View File

@ -28,18 +28,24 @@
#include "folder-list-item.h"
#include "global-settings.h"
#include "file-utils.h"
#include "index/file-searcher.h"
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
SettingsWidget::SettingsWidget(QWidget *parent) : QDialog(parent)
SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
{
this->setWindowIcon(QIcon::fromTheme("kylin-search"));
this->setWindowTitle(tr("ukui-search"));
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowTitle(tr("ukui-search-settings"));
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
// this->setAttribute(Qt::WA_TranslucentBackground);
m_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
m_hints.functions = MWM_FUNC_ALL;
m_hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
initUi();
refreshIndexState();
setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
resetWebEngine();
}
SettingsWidget::~SettingsWidget()
@ -54,7 +60,7 @@ void SettingsWidget::initUi() {
// this->setMinimumHeight(460);
// this->setMaximumHeight(680);
m_mainLyt = new QVBoxLayout(this);
m_mainLyt->setContentsMargins(24, 9, 24, 24);
m_mainLyt->setContentsMargins(16, 8, 16, 24);
this->setLayout(m_mainLyt);
//标题栏
@ -87,30 +93,36 @@ void SettingsWidget::initUi() {
m_titleLyt->addWidget(m_closeBtn);
m_mainLyt->addWidget(m_titleFrame);
m_contentFrame = new QFrame(this);
m_contentLyt = new QVBoxLayout(m_contentFrame);
m_contentFrame->setLayout(m_contentLyt);
m_contentLyt->setContentsMargins(8,0,8,0);
m_mainLyt->addWidget(m_contentFrame);
//设置
m_settingLabel = new QLabel(this);
m_settingLabel = new QLabel(m_contentFrame);
m_settingLabel->setText(tr("<h2>Settings</h2>"));
m_mainLyt->addWidget(m_settingLabel);
m_contentLyt->addWidget(m_settingLabel);
//文件索引
m_indexTitleLabel = new QLabel(this);
m_indexTitleLabel = new QLabel(m_contentFrame);
m_indexTitleLabel->setText(tr("<h3>Index State</h3>"));
m_indexStateLabel = new QLabel(this);
m_indexStateLabel = new QLabel(m_contentFrame);
m_indexStateLabel->setText(tr("..."));
m_indexNumLabel = new QLabel(this);
m_indexNumLabel = new QLabel(m_contentFrame);
m_indexNumLabel->setText(tr("..."));
m_mainLyt->addWidget(m_indexTitleLabel);
m_mainLyt->addWidget(m_indexStateLabel);
m_contentLyt->addWidget(m_indexTitleLabel);
m_contentLyt->addWidget(m_indexStateLabel);
// m_mainLyt->addWidget(m_indexNumLabel);
m_indexNumLabel->hide();
//文件索引设置(黑名单)
m_indexSettingLabel = new QLabel(this);
m_indexSettingLabel = new QLabel(m_contentFrame);
m_indexSettingLabel->setText(tr("<h3>File Index Settings</h3>"));
m_indexDescLabel = new QLabel(this);
m_indexDescLabel = new QLabel(m_contentFrame);
m_indexDescLabel->setText(tr("Following folders will not be searched. You can set it by adding and removing folders."));
m_indexDescLabel->setWordWrap(true);
m_indexBtnFrame = new QFrame(this);
m_indexBtnFrame = new QFrame(m_contentFrame);
m_indexBtnLyt = new QHBoxLayout(m_indexBtnFrame);
m_indexBtnLyt->setContentsMargins(0, 0, 0, 0);
m_indexBtnFrame->setLayout(m_indexBtnLyt);
@ -121,35 +133,35 @@ void SettingsWidget::initUi() {
connect(m_addDirBtn, &QPushButton::clicked, this, &SettingsWidget::onBtnAddClicked);
m_indexBtnLyt->addWidget(m_addDirBtn);
m_indexBtnLyt->addStretch();
m_dirListArea = new QScrollArea(this);
m_dirListArea = new QScrollArea(m_contentFrame);
m_dirListArea->setStyleSheet("QScrollArea{background:transparent;}");
m_dirListWidget = new QWidget(this);
m_dirListWidget = new QWidget(m_contentFrame);
m_dirListWidget->setStyleSheet("QWidget{background:transparent;}");
m_dirListLyt = new QVBoxLayout(m_dirListWidget);
m_dirListLyt->setContentsMargins(0, 0, 0, 0);
m_dirListLyt->setSpacing(0);
m_dirListWidget->setLayout(m_dirListLyt);
m_dirListArea->setWidget(m_dirListWidget);
m_dirListArea->setWidgetResizable(true);
m_mainLyt->addWidget(m_indexSettingLabel);
m_mainLyt->addWidget(m_indexDescLabel);
m_mainLyt->addWidget(m_indexBtnFrame);
m_mainLyt->addWidget(m_dirListArea);
m_dirListArea->setWidgetResizable(m_contentFrame);
m_contentLyt->addWidget(m_indexSettingLabel);
m_contentLyt->addWidget(m_indexDescLabel);
m_contentLyt->addWidget(m_indexBtnFrame);
m_contentLyt->addWidget(m_dirListArea);
//搜索引擎设置
m_searchEngineLabel = new QLabel(this);
m_searchEngineLabel = new QLabel(m_contentFrame);
m_searchEngineLabel->setText(tr("<h3>Search Engine Settings</h3>"));
m_engineDescLabel = new QLabel(this);
m_engineDescLabel = new QLabel(m_contentFrame);
m_engineDescLabel->setText(tr("Please select search engine you preferred."));
m_engineDescLabel->setWordWrap(true);
m_engineBtnGroup = new QButtonGroup(this);
m_baiduBtn = new QRadioButton(this);
m_sougouBtn = new QRadioButton(this);
m_360Btn = new QRadioButton(this);
m_engineBtnGroup = new QButtonGroup(m_contentFrame);
m_baiduBtn = new QRadioButton(m_contentFrame);
m_sougouBtn = new QRadioButton(m_contentFrame);
m_360Btn = new QRadioButton(m_contentFrame);
m_baiduBtn->setFixedSize(16, 16);
m_sougouBtn->setFixedSize(16, 16);
m_360Btn->setFixedSize(16, 16);
m_radioBtnFrame = new QFrame(this);
m_radioBtnFrame = new QFrame(m_contentFrame);
m_radioBtnLyt = new QHBoxLayout(m_radioBtnFrame);
m_radioBtnFrame->setLayout(m_radioBtnLyt);
m_baiduLabel = new QLabel();
@ -170,12 +182,25 @@ void SettingsWidget::initUi() {
m_engineBtnGroup->addButton(m_baiduBtn);
m_engineBtnGroup->addButton(m_sougouBtn);
m_engineBtnGroup->addButton(m_360Btn);
m_mainLyt->addWidget(m_searchEngineLabel);
m_mainLyt->addWidget(m_engineDescLabel);
m_mainLyt->addWidget(m_radioBtnFrame);
m_searchEngineLabel->hide();
m_engineDescLabel->hide();
m_radioBtnFrame->hide();
// m_engineBtnGroup->setId(m_baiduBtn, WebEngine::Baidu);
// m_engineBtnGroup->setId(m_sougouBtn, WebEngine::Sougou);
// m_engineBtnGroup->setId(m_360Btn, WebEngine::_360);
// connect(m_engineBtnGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), [ = ] (int id) {
// setWebEngine(id);
// });
connect(m_baiduBtn, &QRadioButton::clicked, [ = ] (bool checked) {
if (checked) setWebEngine("baidu");
});
connect(m_sougouBtn, &QRadioButton::clicked, [ = ] (bool checked) {
if (checked) setWebEngine("sougou");
});
connect(m_360Btn, &QRadioButton::clicked, [ = ] (bool checked) {
if (checked) setWebEngine("360");
});
m_contentLyt->addWidget(m_searchEngineLabel);
m_contentLyt->addWidget(m_engineDescLabel);
m_contentLyt->addWidget(m_radioBtnFrame);
//取消与确认按钮 (隐藏)
// m_bottomBtnFrame = new QFrame(this);
@ -195,7 +220,7 @@ void SettingsWidget::initUi() {
// m_bottomBtnLyt->addWidget(m_confirmBtn);
// m_mainLyt->addWidget(m_bottomBtnFrame);
m_mainLyt->addStretch();
m_contentLyt->addStretch();
}
/**
@ -209,11 +234,11 @@ void SettingsWidget::setupBlackList(const QStringList& list) {
FolderListItem * item = new FolderListItem(m_dirListWidget, path);
m_dirListLyt->addWidget(item);
item->setMaximumWidth(this->width() - 52);
connect(item, SIGNAL(onDelBtnClicked(const QString&)), this, SLOT(onBtnDelClicked(const QString&)));
connect(item, &FolderListItem::onDelBtnClicked, this, &SettingsWidget::onBtnDelClicked);
m_blockdirs ++;
}
this->resize();
m_dirListWidget->setFixedWidth(this->width() - 52);
m_dirListWidget->setFixedWidth(this->width() - 68);
// m_dirListLyt->addStretch();
}
@ -245,7 +270,7 @@ void SettingsWidget::refreshIndexState()
} else {
this->setIndexState(false);
}
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileSearcher::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count)));
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(SearchManager::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count)));
m_timer = new QTimer;
connect(m_timer, &QTimer::timeout, this, [ = ]() {
qDebug()<<"FileUtils::_index_status: "<<FileUtils::_index_status;
@ -254,7 +279,7 @@ void SettingsWidget::refreshIndexState()
} else {
this->setIndexState(false);
}
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileSearcher::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count)));
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(SearchManager::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count)));
});
m_timer->start(0.5 * 1000);
}
@ -266,7 +291,7 @@ void SettingsWidget::refreshIndexState()
void SettingsWidget::onBtnDelClicked(const QString& path) {
QMessageBox message(QMessageBox::Question, tr("Search"), tr("Whether to delete this directory?"));
QPushButton * buttonYes = message.addButton(tr("Yes"), QMessageBox::YesRole);
QPushButton * buttonNo = message.addButton(tr("No"), QMessageBox::NoRole);
message.addButton(tr("No"), QMessageBox::NoRole);
message.exec();
if (message.clickedButton() != buttonYes) {
return;
@ -289,6 +314,36 @@ void SettingsWidget::onBtnDelClicked(const QString& path) {
}
}
/**
* @brief SettingsWidget::resetWebEngine UI控件上
*/
void SettingsWidget::resetWebEngine()
{
QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString();
m_engineBtnGroup->blockSignals(true);
if (!engine.isEmpty()) {
if (engine == "360") {
m_360Btn->setChecked(true);
} else if (engine == "sougou") {
m_sougouBtn->setChecked(true);
} else {
m_baiduBtn->setChecked(true);
}
} else {
m_baiduBtn->setChecked(true);
}
m_engineBtnGroup->blockSignals(false);
}
/**
* @brief SettingsWidget::setWebEngine
* @param engine
*/
void SettingsWidget::setWebEngine(const QString& engine)
{
GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
}
/**
* @brief setIndexState
* @param isCreatingIndex
@ -320,6 +375,7 @@ void SettingsWidget::showWidget()
flags &= ~Qt::WindowStaysOnTopHint;
this->setWindowFlags(flags);
m_timer->start();
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
this->show();
}
@ -383,40 +439,40 @@ void SettingsWidget::paintEvent(QPaintEvent *event) {
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainterPath rectPath;
rectPath.addRoundedRect(this->rect().adjusted(10, 10, -10, -10), 6, 6);
// rectPath.addRoundedRect(this->rect(), 6, 6);
rectPath.addRect(this->rect());
// 画一个黑底
QPixmap pixmap(this->rect().size());
pixmap.fill(Qt::transparent);
QPainter pixmapPainter(&pixmap);
pixmapPainter.setRenderHint(QPainter::Antialiasing);
pixmapPainter.setPen(Qt::transparent);
pixmapPainter.setBrush(Qt::black);
pixmapPainter.setOpacity(0.65);
pixmapPainter.drawPath(rectPath);
pixmapPainter.end();
// // 画一个黑底
// QPixmap pixmap(this->rect().size());
// pixmap.fill(Qt::transparent);
// QPainter pixmapPainter(&pixmap);
// pixmapPainter.setRenderHint(QPainter::Antialiasing);
// pixmapPainter.setPen(Qt::transparent);
// pixmapPainter.setBrush(Qt::black);
// pixmapPainter.setOpacity(0.65);
// pixmapPainter.drawPath(rectPath);
// pixmapPainter.end();
// 模糊这个黑底
QImage img = pixmap.toImage();
qt_blurImage(img, 10, false, false);
// // 模糊这个黑底
// QImage img = pixmap.toImage();
// qt_blurImage(img, 10, false, false);
// 挖掉中心
pixmap = QPixmap::fromImage(img);
QPainter pixmapPainter2(&pixmap);
pixmapPainter2.setRenderHint(QPainter::Antialiasing);
pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
pixmapPainter2.setPen(Qt::transparent);
pixmapPainter2.setBrush(Qt::transparent);
pixmapPainter2.drawPath(rectPath);
// // 挖掉中心
// pixmap = QPixmap::fromImage(img);
// QPainter pixmapPainter2(&pixmap);
// pixmapPainter2.setRenderHint(QPainter::Antialiasing);
// pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
// pixmapPainter2.setPen(Qt::transparent);
// pixmapPainter2.setBrush(Qt::transparent);
// pixmapPainter2.drawPath(rectPath);
// 绘制阴影
p.drawPixmap(this->rect(), pixmap, pixmap.rect());
// // 绘制阴影
// p.drawPixmap(this->rect(), pixmap, pixmap.rect());
// 绘制一个背景
p.save();
p.fillPath(rectPath,palette().color(QPalette::Base));
p.restore();
}
/**
@ -432,13 +488,13 @@ void SettingsWidget::resize()
// this->setFixedSize(528, 515);
// }
if (m_blockdirs <= 4) {
m_dirListArea->setFixedHeight(32 * m_blockdirs + 5);
m_dirListArea->setFixedHeight(32 * m_blockdirs + 4);
m_dirListWidget->setFixedHeight(32 * m_blockdirs);
} else {
m_dirListWidget->setFixedHeight(32 * m_blockdirs + 5);
m_dirListArea->setFixedHeight(32 * 4);
m_dirListWidget->setFixedHeight(32 * m_blockdirs);
m_dirListArea->setFixedHeight(32 * 4 + 4);
}
this->setFixedSize(528, 455);
this->setFixedSize(528, 410 + m_dirListArea->height());
}
/**
@ -467,6 +523,7 @@ void SettingsWidget::showWarningDialog(const int & errorCode)
break;
}
}
QMessageBox message(QMessageBox::Warning, tr("Search"), errorMessage, QMessageBox::Ok, this);
QMessageBox message(QMessageBox::Warning, tr("Search"), errorMessage);
message.addButton(tr("OK"), QMessageBox::AcceptRole);
message.exec();
}

View File

@ -32,8 +32,10 @@
#include <QPushButton>
#include <QScrollArea>
#include <QTimer>
#include <libsearch.h>
#include "xatom-helper.h"
class SettingsWidget : public QDialog
class SettingsWidget : public QWidget
{
Q_OBJECT
public:
@ -52,8 +54,14 @@ private:
void paintEvent(QPaintEvent *);
void resize();
void showWarningDialog(const int&);
void resetWebEngine();
MotifWmHints m_hints;
//标题栏
QVBoxLayout * m_mainLyt = nullptr;
QFrame * m_contentFrame = nullptr;
QVBoxLayout * m_contentLyt = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLyt = nullptr;
QLabel * m_titleIcon = nullptr;
@ -107,6 +115,7 @@ private Q_SLOTS:
// void onBtnCancelClicked();
void onBtnAddClicked();
void onBtnDelClicked(const QString&);
void setWebEngine(const QString&);
};
#endif // SETTINGSWIDGET_H

View File

@ -69,10 +69,10 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
#if defined(Q_OS_WIN)
id = id.toLower();
#endif
prefix = id.section(QLatin1Char('/'), -1);
prefix = id.section(QLatin1Char('/'), -1); //完整路径按‘/’分隔后取最后一个字段
}
prefix.remove(QRegExp("[^a-zA-Z]"));
prefix.truncate(6);
prefix.remove(QRegExp("[^a-zA-Z]")); //去掉名称中的非字母
prefix.truncate(6); //取前六位
QByteArray idc = id.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
@ -96,7 +96,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
server = new QLocalServer(this);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
+ QLatin1String("-lockfile"); //tmp目录下的锁文件
lockFile.setFileName(lockName);
lockFile.open(QIODevice::ReadWrite);
}
@ -111,6 +111,7 @@ bool QtLocalPeer::isClient()
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
return true;
//由于文件锁的存在仅当本进程第一次启动时能执行到此并使server进行监听和关联槽函数
bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
// ### Workaround
@ -121,7 +122,7 @@ bool QtLocalPeer::isClient()
#endif
if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
QObject::connect(server, &QLocalServer::newConnection, this, &QtLocalPeer::receiveConnection);
return false;
}
@ -162,10 +163,12 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
return res;
}
/**
* @brief QtLocalPeer::receiveConnection server,server接收到newConnection信号并触发此槽函数
*/
void QtLocalPeer::receiveConnection()
{
QLocalSocket* socket = server->nextPendingConnection();
QLocalSocket* socket = server->nextPendingConnection(); //获取新进程的socket
if (!socket)
return;
@ -202,5 +205,5 @@ void QtLocalPeer::receiveConnection()
socket->waitForBytesWritten(1000);
socket->waitForDisconnected(1000); // make sure client reads ack
delete socket;
Q_EMIT messageReceived(message); //### (might take a long time to return)
Q_EMIT messageReceived(message); //获取新进程的启动信息并作为信号发送给前端
}

View File

@ -145,7 +145,8 @@ void QtSingleApplication::sysInit(const QString &appId)
{
actWin = 0;
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
// connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::messageReceived);
}
@ -295,10 +296,11 @@ QString QtSingleApplication::id() const
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
{
actWin = aw;
if (activateOnMessage)
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
else
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
//目前不需要用到此处的置顶方法,故此信号槽暂时注释掉,若后续需要根据新起进程传递的信号执行部分操作时可以把这里放开
// if (activateOnMessage)
// connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
// else
// disconnect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
}

View File

@ -9,6 +9,7 @@ TEMPLATE = app
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0
CONFIG += c++11 link_pkgconfig no_keywords lrelease
LIBS += -lxapian -lgsettings-qt -lquazip5 -lX11
LIBS += -lukui-log4qt
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
@ -26,9 +27,11 @@ include(singleapplication/qt-single-application.pri)
SOURCES += \
content-widget.cpp \
custom-style.cpp \
input-box.cpp \
main.cpp \
mainwindow.cpp \
search-app-thread.cpp \
search-result.cpp \
settings-widget.cpp \
xatom-helper.cpp
@ -36,8 +39,10 @@ SOURCES += \
HEADERS += \
content-widget.h \
custom-style.h \
input-box.h \
mainwindow.h \
search-app-thread.h \
search-result.h \
settings-widget.h \
xatom-helper.h
@ -66,16 +71,15 @@ qm_files.files = $$OUT_PWD/.qm/*.qm
INSTALLS += qm_files
LIBS += -L$$OUT_PWD/../libsearch -lukui-search \
-L$$OUT_PWD/../libchinese-segmentation -lchinese-segmentation
# -L$$OUT_PWD/../libfriso -lfriso
LIBS += -L$$OUT_PWD/../libchinese-segmentation -lchinese-segmentation \
-L$$OUT_PWD/../libsearch -lukui-search
INCLUDEPATH += $$PWD/../libchinese-segmentation
DEPENDPATH += $$PWD/../libchinese-segmentation
INCLUDEPATH += $$PWD/../libsearch
DEPENDPATH += $$PWD/../libsearch
#INCLUDEPATH += $$PWD/../libfriso
#DEPENDPATH += $$PWD/../libfriso
#DISTFILES += \
# ../data/ukui-search-menu.desktop \
# $$OUT_PWD/.qm/bo.qm \

View File

@ -4,52 +4,57 @@
<context>
<name>ContentWidget</name>
<message>
<location filename="../../src/content-widget.cpp" line="328"/>
<location filename="../../src/content-widget.cpp" line="377"/>
<source>Recently Opened</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="359"/>
<location filename="../../src/content-widget.cpp" line="413"/>
<source>Open Quickly</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="360"/>
<location filename="../../src/content-widget.cpp" line="414"/>
<source>Commonly Used</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="602"/>
<location filename="../../src/content-widget.cpp" line="681"/>
<source>Apps</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="604"/>
<location filename="../../src/content-widget.cpp" line="683"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="606"/>
<location filename="../../src/content-widget.cpp" line="685"/>
<source>Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="608"/>
<location filename="../../src/content-widget.cpp" line="687"/>
<source>Dirs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="610"/>
<location filename="../../src/content-widget.cpp" line="689"/>
<source>File Contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="612"/>
<location filename="../../src/content-widget.cpp" line="691"/>
<source>Best Matches</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="614"/>
<location filename="../../src/content-widget.cpp" line="693"/>
<source>Web Pages</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="695"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
@ -70,12 +75,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="115"/>
<location filename="../../src/mainwindow.cpp" line="126"/>
<source>Global Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="169"/>
<location filename="../../src/mainwindow.cpp" line="188"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
@ -83,35 +88,40 @@
<context>
<name>OptionView</name>
<message>
<location filename="../../src/control/option-view.cpp" line="95"/>
<location filename="../../src/control/option-view.cpp" line="101"/>
<source>Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="102"/>
<location filename="../../src/control/option-view.cpp" line="108"/>
<source>Add Shortcut to Desktop</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="109"/>
<location filename="../../src/control/option-view.cpp" line="115"/>
<source>Add Shortcut to Panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="116"/>
<location filename="../../src/control/option-view.cpp" line="122"/>
<source>Open path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="123"/>
<location filename="../../src/control/option-view.cpp" line="129"/>
<source>Copy path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="136"/>
<source>Install</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="149"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation type="unfinished"></translation>
</message>
@ -127,213 +137,228 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="400"/>
<location filename="../../src/control/search-detail-view.cpp" line="525"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="408"/>
<location filename="../../src/control/search-detail-view.cpp" line="533"/>
<source>Last time modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="232"/>
<location filename="../../src/control/search-detail-view.cpp" line="234"/>
<source>Application</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="248"/>
<location filename="../../src/control/search-detail-view.cpp" line="215"/>
<source>Introduction: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="353"/>
<source>Document</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="475"/>
<source>Preview is not avaliable</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsWidget</name>
<message>
<location filename="../../src/settings-widget.cpp" line="69"/>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="470"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<location filename="../../src/settings-widget.cpp" line="519"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="99"/>
<location filename="../../src/settings-widget.cpp" line="101"/>
<location filename="../../src/settings-widget.cpp" line="105"/>
<location filename="../../src/settings-widget.cpp" line="107"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="111"/>
<location filename="../../src/settings-widget.cpp" line="117"/>
<source>Following folders will not be searched. You can set it by adding and removing folders.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="120"/>
<location filename="../../src/settings-widget.cpp" line="126"/>
<source>Add ignored folders</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="143"/>
<location filename="../../src/settings-widget.cpp" line="149"/>
<source>Please select search engine you preferred.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="156"/>
<location filename="../../src/settings-widget.cpp" line="162"/>
<source>baidu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="158"/>
<location filename="../../src/settings-widget.cpp" line="164"/>
<source>sougou</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="160"/>
<location filename="../../src/settings-widget.cpp" line="166"/>
<source>360</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="359"/>
<location filename="../../src/settings-widget.cpp" line="408"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="298"/>
<location filename="../../src/settings-widget.cpp" line="347"/>
<source>Creating ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="37"/>
<source>ukui-search</source>
<location filename="../../src/settings-widget.cpp" line="36"/>
<source>ukui-search-settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="92"/>
<location filename="../../src/settings-widget.cpp" line="98"/>
<source>&lt;h2&gt;Settings&lt;/h2&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="97"/>
<location filename="../../src/settings-widget.cpp" line="103"/>
<source>&lt;h3&gt;Index State&lt;/h3&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="109"/>
<location filename="../../src/settings-widget.cpp" line="115"/>
<source>&lt;h3&gt;File Index Settings&lt;/h3&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="141"/>
<location filename="../../src/settings-widget.cpp" line="147"/>
<source>&lt;h3&gt;Search Engine Settings&lt;/h3&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<source>Whether to delete this directory?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="268"/>
<location filename="../../src/settings-widget.cpp" line="287"/>
<source>Yes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="269"/>
<location filename="../../src/settings-widget.cpp" line="288"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="301"/>
<location filename="../../src/settings-widget.cpp" line="350"/>
<source>Done</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="309"/>
<location filename="../../src/settings-widget.cpp" line="358"/>
<source>Index Entry: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="353"/>
<location filename="../../src/settings-widget.cpp" line="402"/>
<source>Directories</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="354"/>
<location filename="../../src/settings-widget.cpp" line="403"/>
<source>select blocked folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="355"/>
<location filename="../../src/settings-widget.cpp" line="404"/>
<source>Select</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="356"/>
<location filename="../../src/settings-widget.cpp" line="405"/>
<source>Position: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="357"/>
<location filename="../../src/settings-widget.cpp" line="406"/>
<source>FileName: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="358"/>
<location filename="../../src/settings-widget.cpp" line="407"/>
<source>FileType: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="454"/>
<location filename="../../src/settings-widget.cpp" line="503"/>
<source>Choosen path is Empty!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="458"/>
<location filename="../../src/settings-widget.cpp" line="507"/>
<source>Choosen path is not in &quot;home&quot;!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="462"/>
<location filename="../../src/settings-widget.cpp" line="511"/>
<source>Its&apos; parent folder has been blocked!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="466"/>
<location filename="../../src/settings-widget.cpp" line="515"/>
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="520"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowMoreLabel</name>
<message>
<location filename="../../src/control/show-more-label.cpp" line="40"/>
<location filename="../../src/control/show-more-label.cpp" line="48"/>
<location filename="../../src/control/show-more-label.cpp" line="78"/>
<location filename="../../src/control/show-more-label.cpp" line="57"/>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<source>Show More...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="76"/>
<location filename="../../src/control/show-more-label.cpp" line="85"/>
<source>Retract</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<location filename="../../src/control/show-more-label.cpp" line="96"/>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="92"/>
<location filename="../../src/control/show-more-label.cpp" line="101"/>
<source>Loading.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="97"/>
<location filename="../../src/control/show-more-label.cpp" line="106"/>
<source>Loading..</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="102"/>
<location filename="../../src/control/show-more-label.cpp" line="111"/>
<source>Loading...</source>
<translation type="unfinished"></translation>
</message>

View File

@ -4,52 +4,57 @@
<context>
<name>ContentWidget</name>
<message>
<location filename="../../src/content-widget.cpp" line="328"/>
<location filename="../../src/content-widget.cpp" line="377"/>
<source>Recently Opened</source>
<translation>Yeni ılan</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="359"/>
<location filename="../../src/content-widget.cpp" line="413"/>
<source>Open Quickly</source>
<translation>Hızlı </translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="360"/>
<location filename="../../src/content-widget.cpp" line="414"/>
<source>Commonly Used</source>
<translation>Genel olarak kullanılan</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="602"/>
<location filename="../../src/content-widget.cpp" line="681"/>
<source>Apps</source>
<translation>Uygulamalar</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="604"/>
<location filename="../../src/content-widget.cpp" line="683"/>
<source>Settings</source>
<translation>Ayarlar</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="606"/>
<location filename="../../src/content-widget.cpp" line="685"/>
<source>Files</source>
<translation>Dosyalar</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="608"/>
<location filename="../../src/content-widget.cpp" line="687"/>
<source>Dirs</source>
<translation>Dizinler</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="610"/>
<location filename="../../src/content-widget.cpp" line="689"/>
<source>File Contents</source>
<translation>Dosya İçeriği</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="612"/>
<location filename="../../src/content-widget.cpp" line="691"/>
<source>Best Matches</source>
<translation>En İyi Eşleşen</translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="614"/>
<location filename="../../src/content-widget.cpp" line="693"/>
<source>Web Pages</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="695"/>
<source>Unknown</source>
<translation>Bilinmeyen</translation>
</message>
@ -70,12 +75,12 @@
<translation>ukui-ara</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="115"/>
<location filename="../../src/mainwindow.cpp" line="126"/>
<source>Global Search</source>
<translation>Genel Arama</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="169"/>
<location filename="../../src/mainwindow.cpp" line="188"/>
<source>Search</source>
<translation>Ara</translation>
</message>
@ -83,35 +88,40 @@
<context>
<name>OptionView</name>
<message>
<location filename="../../src/control/option-view.cpp" line="95"/>
<location filename="../../src/control/option-view.cpp" line="101"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="102"/>
<location filename="../../src/control/option-view.cpp" line="108"/>
<source>Add Shortcut to Desktop</source>
<translation>Masaüstüne Kısayol Ekle</translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="109"/>
<location filename="../../src/control/option-view.cpp" line="115"/>
<source>Add Shortcut to Panel</source>
<translation>Panele Kısayol Ekle</translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="116"/>
<location filename="../../src/control/option-view.cpp" line="122"/>
<source>Open path</source>
<translation>Yolu </translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="123"/>
<location filename="../../src/control/option-view.cpp" line="129"/>
<source>Copy path</source>
<translation>Yolu kopyala</translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="136"/>
<source>Install</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="149"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation>ukui-bul zaten çalışıyor!</translation>
</message>
@ -127,213 +137,232 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="400"/>
<location filename="../../src/control/search-detail-view.cpp" line="525"/>
<source>Path</source>
<translation>Yol</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="408"/>
<location filename="../../src/control/search-detail-view.cpp" line="533"/>
<source>Last time modified</source>
<translation>Son değiştirilme zamanı</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="232"/>
<location filename="../../src/control/search-detail-view.cpp" line="234"/>
<source>Application</source>
<translation>Uygulama</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="248"/>
<location filename="../../src/control/search-detail-view.cpp" line="215"/>
<source>Introduction: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="353"/>
<source>Document</source>
<translation>Belge</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="475"/>
<source>Preview is not avaliable</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsWidget</name>
<message>
<location filename="../../src/settings-widget.cpp" line="69"/>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="470"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<location filename="../../src/settings-widget.cpp" line="519"/>
<source>Search</source>
<translation>Ara</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="99"/>
<location filename="../../src/settings-widget.cpp" line="101"/>
<location filename="../../src/settings-widget.cpp" line="105"/>
<location filename="../../src/settings-widget.cpp" line="107"/>
<source>...</source>
<translation>...</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="111"/>
<location filename="../../src/settings-widget.cpp" line="117"/>
<source>Following folders will not be searched. You can set it by adding and removing folders.</source>
<translation>Aşağıdaki klasörler aranmayacaktır. Klasör ekleyip kaldırarak ayarlayabilirsiniz.</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="120"/>
<location filename="../../src/settings-widget.cpp" line="126"/>
<source>Add ignored folders</source>
<translation>Göz ardı edilen klasörleri ekleyin</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="143"/>
<location filename="../../src/settings-widget.cpp" line="149"/>
<source>Please select search engine you preferred.</source>
<translation>Lütfen tercih ettiğiniz arama motorunu seçin.</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="156"/>
<location filename="../../src/settings-widget.cpp" line="162"/>
<source>baidu</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="158"/>
<location filename="../../src/settings-widget.cpp" line="164"/>
<source>sougou</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="160"/>
<location filename="../../src/settings-widget.cpp" line="166"/>
<source>360</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="359"/>
<location filename="../../src/settings-widget.cpp" line="408"/>
<source>Cancel</source>
<translation>İptal</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="298"/>
<location filename="../../src/settings-widget.cpp" line="347"/>
<source>Creating ...</source>
<translation>Oluşturuluyor...</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="37"/>
<source>ukui-search</source>
<translation>ukui-bul</translation>
<translation type="vanished">ukui-bul</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="92"/>
<location filename="../../src/settings-widget.cpp" line="36"/>
<source>ukui-search-settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="98"/>
<source>&lt;h2&gt;Settings&lt;/h2&gt;</source>
<translation>&lt;h2&gt;Ayarlar&lt;/h2&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="97"/>
<location filename="../../src/settings-widget.cpp" line="103"/>
<source>&lt;h3&gt;Index State&lt;/h3&gt;</source>
<translation>&lt;h3&gt;Dizin Durumu&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="109"/>
<location filename="../../src/settings-widget.cpp" line="115"/>
<source>&lt;h3&gt;File Index Settings&lt;/h3&gt;</source>
<translation>&lt;h3&gt;Dosya Dizini Ayarları&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="141"/>
<location filename="../../src/settings-widget.cpp" line="147"/>
<source>&lt;h3&gt;Search Engine Settings&lt;/h3&gt;</source>
<translation>&lt;h3&gt;SArama Motoru Ayarları&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<source>Whether to delete this directory?</source>
<translation>Bu dizini silinsin mi?</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="268"/>
<location filename="../../src/settings-widget.cpp" line="287"/>
<source>Yes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="269"/>
<location filename="../../src/settings-widget.cpp" line="288"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="301"/>
<location filename="../../src/settings-widget.cpp" line="350"/>
<source>Done</source>
<translation>Tamam</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="309"/>
<location filename="../../src/settings-widget.cpp" line="358"/>
<source>Index Entry: %1</source>
<translation>Dizin Girişi: %1</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="353"/>
<location filename="../../src/settings-widget.cpp" line="402"/>
<source>Directories</source>
<translation>Dizinler</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="354"/>
<location filename="../../src/settings-widget.cpp" line="403"/>
<source>select blocked folder</source>
<translation>engellenen klasörü seç</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="355"/>
<location filename="../../src/settings-widget.cpp" line="404"/>
<source>Select</source>
<translation>Seç</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="356"/>
<location filename="../../src/settings-widget.cpp" line="405"/>
<source>Position: </source>
<translation>Pozisyon: </translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="357"/>
<location filename="../../src/settings-widget.cpp" line="406"/>
<source>FileName: </source>
<translation>Dosya Adı: </translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="358"/>
<location filename="../../src/settings-widget.cpp" line="407"/>
<source>FileType: </source>
<translation>Dosya Türü: </translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="454"/>
<location filename="../../src/settings-widget.cpp" line="503"/>
<source>Choosen path is Empty!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="458"/>
<location filename="../../src/settings-widget.cpp" line="507"/>
<source>Choosen path is not in &quot;home&quot;!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="462"/>
<location filename="../../src/settings-widget.cpp" line="511"/>
<source>Its&apos; parent folder has been blocked!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="466"/>
<location filename="../../src/settings-widget.cpp" line="515"/>
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="520"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowMoreLabel</name>
<message>
<location filename="../../src/control/show-more-label.cpp" line="40"/>
<location filename="../../src/control/show-more-label.cpp" line="48"/>
<location filename="../../src/control/show-more-label.cpp" line="78"/>
<location filename="../../src/control/show-more-label.cpp" line="57"/>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<source>Show More...</source>
<translation>Daha Fazla Göster...</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="76"/>
<location filename="../../src/control/show-more-label.cpp" line="85"/>
<source>Retract</source>
<translation>Geri çek</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<location filename="../../src/control/show-more-label.cpp" line="96"/>
<source>Loading</source>
<translation>Yükleniyor</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="92"/>
<location filename="../../src/control/show-more-label.cpp" line="101"/>
<source>Loading.</source>
<translation>Yükleniyor.</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="97"/>
<location filename="../../src/control/show-more-label.cpp" line="106"/>
<source>Loading..</source>
<translation>Yükleniyor..</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="102"/>
<location filename="../../src/control/show-more-label.cpp" line="111"/>
<source>Loading...</source>
<translation>Yükleniyor...</translation>
</message>

View File

@ -4,52 +4,57 @@
<context>
<name>ContentWidget</name>
<message>
<location filename="../../src/content-widget.cpp" line="328"/>
<location filename="../../src/content-widget.cpp" line="377"/>
<source>Recently Opened</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="359"/>
<location filename="../../src/content-widget.cpp" line="413"/>
<source>Open Quickly</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="360"/>
<location filename="../../src/content-widget.cpp" line="414"/>
<source>Commonly Used</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="602"/>
<location filename="../../src/content-widget.cpp" line="681"/>
<source>Apps</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="604"/>
<location filename="../../src/content-widget.cpp" line="683"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="606"/>
<location filename="../../src/content-widget.cpp" line="685"/>
<source>Files</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="608"/>
<location filename="../../src/content-widget.cpp" line="687"/>
<source>Dirs</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="610"/>
<location filename="../../src/content-widget.cpp" line="689"/>
<source>File Contents</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="612"/>
<location filename="../../src/content-widget.cpp" line="691"/>
<source>Best Matches</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="614"/>
<location filename="../../src/content-widget.cpp" line="693"/>
<source>Web Pages</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="695"/>
<source>Unknown</source>
<translation></translation>
</message>
@ -70,12 +75,12 @@
<translation></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="115"/>
<location filename="../../src/mainwindow.cpp" line="126"/>
<source>Global Search</source>
<translation></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="169"/>
<location filename="../../src/mainwindow.cpp" line="188"/>
<source>Search</source>
<translation></translation>
</message>
@ -83,35 +88,40 @@
<context>
<name>OptionView</name>
<message>
<location filename="../../src/control/option-view.cpp" line="95"/>
<location filename="../../src/control/option-view.cpp" line="101"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="102"/>
<location filename="../../src/control/option-view.cpp" line="108"/>
<source>Add Shortcut to Desktop</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="109"/>
<location filename="../../src/control/option-view.cpp" line="115"/>
<source>Add Shortcut to Panel</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="116"/>
<location filename="../../src/control/option-view.cpp" line="122"/>
<source>Open path</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="123"/>
<location filename="../../src/control/option-view.cpp" line="129"/>
<source>Copy path</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/option-view.cpp" line="136"/>
<source>Install</source>
<translation></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="149"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation></translation>
</message>
@ -127,178 +137,197 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="400"/>
<location filename="../../src/control/search-detail-view.cpp" line="525"/>
<source>Path</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="408"/>
<location filename="../../src/control/search-detail-view.cpp" line="533"/>
<source>Last time modified</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="232"/>
<location filename="../../src/control/search-detail-view.cpp" line="234"/>
<source>Application</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="248"/>
<location filename="../../src/control/search-detail-view.cpp" line="215"/>
<source>Introduction: %1</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="353"/>
<source>Document</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="475"/>
<source>Preview is not avaliable</source>
<translation></translation>
</message>
</context>
<context>
<name>SettingsWidget</name>
<message>
<location filename="../../src/settings-widget.cpp" line="36"/>
<source>ukui-search-settings</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="69"/>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="470"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<location filename="../../src/settings-widget.cpp" line="519"/>
<source>Search</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="92"/>
<location filename="../../src/settings-widget.cpp" line="98"/>
<source>&lt;h2&gt;Settings&lt;/h2&gt;</source>
<translation>&lt;h2&gt;&lt;/h2&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="97"/>
<location filename="../../src/settings-widget.cpp" line="103"/>
<source>&lt;h3&gt;Index State&lt;/h3&gt;</source>
<translation>&lt;h3&gt;&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="99"/>
<location filename="../../src/settings-widget.cpp" line="101"/>
<location filename="../../src/settings-widget.cpp" line="105"/>
<location filename="../../src/settings-widget.cpp" line="107"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="109"/>
<location filename="../../src/settings-widget.cpp" line="115"/>
<source>&lt;h3&gt;File Index Settings&lt;/h3&gt;</source>
<translation>&lt;h3&gt;&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="111"/>
<location filename="../../src/settings-widget.cpp" line="117"/>
<source>Following folders will not be searched. You can set it by adding and removing folders.</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="120"/>
<location filename="../../src/settings-widget.cpp" line="126"/>
<source>Add ignored folders</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="141"/>
<location filename="../../src/settings-widget.cpp" line="147"/>
<source>&lt;h3&gt;Search Engine Settings&lt;/h3&gt;</source>
<translation>&lt;h3&gt;&lt;/h3&gt;</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="143"/>
<location filename="../../src/settings-widget.cpp" line="149"/>
<source>Please select search engine you preferred.</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="156"/>
<location filename="../../src/settings-widget.cpp" line="162"/>
<source>baidu</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="158"/>
<location filename="../../src/settings-widget.cpp" line="164"/>
<source>sougou</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="160"/>
<location filename="../../src/settings-widget.cpp" line="166"/>
<source>360</source>
<translation>360</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="267"/>
<location filename="../../src/settings-widget.cpp" line="286"/>
<source>Whether to delete this directory?</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="268"/>
<location filename="../../src/settings-widget.cpp" line="287"/>
<source>Yes</source>
<translation>(Y)</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="269"/>
<location filename="../../src/settings-widget.cpp" line="288"/>
<source>No</source>
<translation>(N)</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="359"/>
<location filename="../../src/settings-widget.cpp" line="408"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="454"/>
<location filename="../../src/settings-widget.cpp" line="503"/>
<source>Choosen path is Empty!</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="458"/>
<location filename="../../src/settings-widget.cpp" line="507"/>
<source>Choosen path is not in &quot;home&quot;!</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="462"/>
<location filename="../../src/settings-widget.cpp" line="511"/>
<source>Its&apos; parent folder has been blocked!</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="466"/>
<location filename="../../src/settings-widget.cpp" line="515"/>
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="298"/>
<location filename="../../src/settings-widget.cpp" line="520"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="347"/>
<source>Creating ...</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="37"/>
<source>ukui-search</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="301"/>
<location filename="../../src/settings-widget.cpp" line="350"/>
<source>Done</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="309"/>
<location filename="../../src/settings-widget.cpp" line="358"/>
<source>Index Entry: %1</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="353"/>
<location filename="../../src/settings-widget.cpp" line="402"/>
<source>Directories</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="354"/>
<location filename="../../src/settings-widget.cpp" line="403"/>
<source>select blocked folder</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="355"/>
<location filename="../../src/settings-widget.cpp" line="404"/>
<source>Select</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="356"/>
<location filename="../../src/settings-widget.cpp" line="405"/>
<source>Position: </source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="357"/>
<location filename="../../src/settings-widget.cpp" line="406"/>
<source>FileName: </source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="358"/>
<location filename="../../src/settings-widget.cpp" line="407"/>
<source>FileType: </source>
<translation></translation>
</message>
@ -307,33 +336,33 @@
<name>ShowMoreLabel</name>
<message>
<location filename="../../src/control/show-more-label.cpp" line="40"/>
<location filename="../../src/control/show-more-label.cpp" line="48"/>
<location filename="../../src/control/show-more-label.cpp" line="78"/>
<location filename="../../src/control/show-more-label.cpp" line="57"/>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<source>Show More...</source>
<translation>...</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="76"/>
<location filename="../../src/control/show-more-label.cpp" line="85"/>
<source>Retract</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="87"/>
<location filename="../../src/control/show-more-label.cpp" line="96"/>
<source>Loading</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="92"/>
<location filename="../../src/control/show-more-label.cpp" line="101"/>
<source>Loading.</source>
<translation>.</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="97"/>
<location filename="../../src/control/show-more-label.cpp" line="106"/>
<source>Loading..</source>
<translation>..</translation>
</message>
<message>
<location filename="../../src/control/show-more-label.cpp" line="102"/>
<location filename="../../src/control/show-more-label.cpp" line="111"/>
<source>Loading...</source>
<translation>...</translation>
</message>

View File

@ -3,7 +3,6 @@ SUBDIRS += $$PWD/libchinese-segmentation \
$$PWD/libsearch \
$$PWD/src \
$$PWD/ukuisearch-systemdbus
# $$PWD/libfriso
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
@ -16,7 +15,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
libsearch.depends += libchinese-segmentation
# libfriso
src.depends = libsearch
CONFIG += ordered

View File

@ -20,13 +20,16 @@
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
#include <ukui-log4qt.h>
#include <QDebug>
#include "sysdbusregister.h"
int main(int argc, char *argv[]){
//init log module
initUkuiLog4qt("ukui-search-service");
QCoreApplication app(argc, argv);
app.setOrganizationName("Kylin Team");
app.setApplicationName("ukui-search-service");

View File

@ -2,12 +2,15 @@ QT += core dbus
QT -= gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
VERSION = 0.0.1
TARGET = ukui-search-systemdbus
TEMPLATE = app
CONFIG += console c++11 link_pkgconfig
CONFIG -= app_bundle
LIBS += -lukui-log4qt
DESTDIR = .
INCLUDEPATH += .