Merge branch '1019-3.1' into 'new-frontend'

Merge from dev-unity.

See merge request kylin-desktop/ukui-search!170
This commit is contained in:
纪笑旭 2021-10-20 08:46:50 +00:00
commit 58b28603ab
7 changed files with 21 additions and 15 deletions

View File

@ -51,7 +51,7 @@ AppMatch::AppMatch(QObject *parent) : QThread(parent)
if(!m_interFace->isValid()) { if(!m_interFace->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
} }
m_interFace->setTimeout(200); m_interFace->setTimeout(1500);
qDebug() << "AppMatch init finished."; qDebug() << "AppMatch init finished.";
} }

View File

@ -1,12 +1,17 @@
#ifndef COMMON_H #ifndef COMMON_H
#define COMMON_H #define COMMON_H
#include <QMap> #include <QMap>
#include <QString>
#include <QDir>
#define UKUI_SEARCH_PIPE_PATH (QDir::homePath()+"/.config/org.ukui/ukui-search/ukuisearch").toLocal8Bit().constData() #define UKUI_SEARCH_PIPE_PATH (QDir::homePath()+"/.config/org.ukui/ukui-search/ukuisearch").toLocal8Bit().constData()
#define FILE_SEARCH_VALUE "0" #define FILE_SEARCH_VALUE "0"
#define DIR_SEARCH_VALUE "1" #define DIR_SEARCH_VALUE "1"
#define LABEL_MAX_WIDTH 300 #define LABEL_MAX_WIDTH 300
#define HOME_PATH QDir::homePath() #define HOME_PATH QDir::homePath()
static const QStringList allAppPath = {
QDir::homePath()+"/.local/share/applications/",
"/usr/share/applications/"
};
static const QMap<QString, bool> targetFileTypeMap = { static const QMap<QString, bool> targetFileTypeMap = {
std::map<QString, bool>::value_type("doc", true), std::map<QString, bool>::value_type("doc", true),
std::map<QString, bool>::value_type("docx", true), std::map<QString, bool>::value_type("docx", true),

View File

@ -54,7 +54,7 @@ QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) {
nullptr, nullptr,
nullptr)); nullptr));
if(!G_IS_FILE_INFO(info.get()->get())) if(!G_IS_FILE_INFO(info.get()->get()))
return QIcon::fromTheme("unknown"); return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png"));
GIcon *g_icon = g_file_info_get_icon(info.get()->get()); GIcon *g_icon = g_file_info_get_icon(info.get()->get());
//do not unref the GIcon from info. //do not unref the GIcon from info.
@ -72,8 +72,7 @@ QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) {
} }
} }
} }
return QIcon::fromTheme("unknown"); return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png"));
} }
/** /**
@ -88,7 +87,7 @@ QIcon FileUtils::getAppIcon(const QString &path) {
keyfile = g_key_file_new(); keyfile = g_key_file_new();
if(!g_key_file_load_from_file(keyfile, ba.data(), G_KEY_FILE_NONE, NULL)) { if(!g_key_file_load_from_file(keyfile, ba.data(), G_KEY_FILE_NONE, NULL)) {
g_key_file_free(keyfile); g_key_file_free(keyfile);
return QIcon::fromTheme("unknown"); return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png"));
} }
QString icon = QString(g_key_file_get_locale_string(keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL)); QString icon = QString(g_key_file_get_locale_string(keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL));
g_key_file_free(keyfile); g_key_file_free(keyfile);

View File

@ -52,6 +52,7 @@
#include <uchardet/uchardet.h> #include <uchardet/uchardet.h>
//#include <poppler-qt5.h> //#include <poppler-qt5.h>
#include <poppler/qt5/poppler-qt5.h> #include <poppler/qt5/poppler-qt5.h>
#include <common.h>
#include "libsearch_global.h" #include "libsearch_global.h"
#include "gobject-template.h" #include "gobject-template.h"

View File

@ -69,14 +69,13 @@ void ConstructDocumentForPath::run() {
/* QStringList temp; /* QStringList temp;
// temp.append(index_text); // temp.append(index_text);
temp.append(pinyin_text_list)*/; temp.append(pinyin_text_list)*/;
int postingCount = 0;
while(postingCount < index_text.size()) {
// QVector<size_t> p;
// p.append(postingCount);
doc.addPosting(QUrl::toPercentEncoding(index_text.at(postingCount)).toStdString(), postingCount);
++postingCount;
}
int i = 0; int i = 0;
int postingCount = 1; //terms post of Xapian document is start from 1!
while(postingCount < index_text.size()) {
doc.addPosting(QUrl::toPercentEncoding(index_text.at(i)).toStdString(), postingCount);
++postingCount;
++i;
}
for(QString& s : pinyin_text_list) { for(QString& s : pinyin_text_list) {
i = 0; i = 0;
while(i < s.size()) { while(i < s.size()) {

View File

@ -435,6 +435,10 @@ DirectSearch::DirectSearch(QString keyword, DataQueue<SearchPluginIface::ResultI
} }
void DirectSearch::run() { void DirectSearch::run() {
QStringList blockList = GlobalSettings::getInstance()->getBlockDirs();
if(blockList.contains(QStandardPaths::writableLocation(QStandardPaths::HomeLocation).remove(0,1), Qt::CaseSensitive)) {
return;
}
QQueue<QString> bfs; QQueue<QString> bfs;
bfs.enqueue(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); bfs.enqueue(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
QFileInfoList list; QFileInfoList list;
@ -446,8 +450,6 @@ void DirectSearch::run() {
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
dir.setSorting(QDir::DirsFirst); dir.setSorting(QDir::DirsFirst);
} }
QStringList blockList = GlobalSettings::getInstance()->getBlockDirs();
while(!bfs.empty()) { while(!bfs.empty()) {
dir.setPath(bfs.dequeue()); dir.setPath(bfs.dequeue());
list = dir.entryInfoList(); list = dir.entryInfoList();

BIN
src/res/icons/unknown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB