forked from openkylin/ukui-search
Merge branch '0902-newfrontend' into 'new-frontend'
Update quickly open desktop file names;Fix: Search icon in search lineediter is not visble in dark theme. See merge request kylin-desktop/ukui-search!129
This commit is contained in:
commit
f62f4ba53c
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
#include "app-match.h"
|
||||
#include <glib.h>
|
||||
#include <qt5xdg/XdgIcon>
|
||||
#include "file-utils.h"
|
||||
#include "app-search-plugin.h"
|
||||
#define ANDROID_APP_DESKTOP_PATH QDir::homePath() + "/.local/share/applications/"
|
||||
|
@ -252,8 +253,6 @@ void AppMatch::appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<Sear
|
|||
QMapIterator<NameString, QStringList> iter(m_installAppMap);
|
||||
while(iter.hasNext()) {
|
||||
iter.next();
|
||||
// list = iter.value();
|
||||
// name.app_name = iter.key().app_name;
|
||||
if(iter.key().app_name.contains(keyWord, Qt::CaseInsensitive)) {
|
||||
SearchPluginIface::ResultInfo ri;
|
||||
creatResultInfo(ri, iter, true);
|
||||
|
@ -261,17 +260,17 @@ void AppMatch::appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<Sear
|
|||
if (uniqueSymbol == AppSearchPlugin::uniqueSymbol) {
|
||||
searchResult->enqueue(ri);
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
continue;
|
||||
} else {
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
// installed.insert(name, list);
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList pinyinlist;
|
||||
pinyinlist = FileUtils::findMultiToneWords(iter.key().app_name);
|
||||
|
||||
bool matched = false;
|
||||
for(int i = 0; i < pinyinlist.size() / 2; i++) {
|
||||
QString shouzimu = pinyinlist.at(2 * i + 1); // 中文转首字母
|
||||
if(shouzimu.contains(keyWord, Qt::CaseInsensitive)) {
|
||||
|
@ -281,12 +280,12 @@ void AppMatch::appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<Sear
|
|||
if (uniqueSymbol == AppSearchPlugin::uniqueSymbol) {
|
||||
searchResult->enqueue(ri);
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
matched = true;
|
||||
break;
|
||||
} else {
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
// installed.insert(name, list);
|
||||
break;
|
||||
}
|
||||
if(keyWord.size() < 2)
|
||||
break;
|
||||
|
@ -298,14 +297,17 @@ void AppMatch::appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<Sear
|
|||
if (uniqueSymbol == AppSearchPlugin::uniqueSymbol) {
|
||||
searchResult->enqueue(ri);
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
} else {
|
||||
AppSearchPlugin::m_mutex.lock();
|
||||
matched = true;
|
||||
break;
|
||||
} else {
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
return;
|
||||
}
|
||||
// installed.insert(name, list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(matched) {
|
||||
continue;
|
||||
}
|
||||
QStringList tmpList;
|
||||
tmpList << iter.value().at(2) << iter.value().at(3);
|
||||
for(QString s : tmpList) {
|
||||
|
@ -316,12 +318,11 @@ void AppMatch::appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<Sear
|
|||
if (uniqueSymbol == AppSearchPlugin::uniqueSymbol) {
|
||||
searchResult->enqueue(ri);
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
break;
|
||||
} else {
|
||||
AppSearchPlugin::m_mutex.unlock();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
// installed.insert(name, list);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +398,8 @@ void AppMatch::getInstalledAppsVersion(QString appname) {
|
|||
|
||||
void AppMatch::creatResultInfo(SearchPluginIface::ResultInfo &ri, QMapIterator<NameString, QStringList> &iter, bool isInstalled)
|
||||
{
|
||||
ri.icon = QIcon::fromTheme(iter.value().at(1), QIcon(":/res/icons/desktop.png"));
|
||||
// ri.icon = QIcon::fromTheme(iter.value().at(1), QIcon(":/res/icons/desktop.png"));
|
||||
ri.icon = XdgIcon::fromTheme(iter.value().at(1), QIcon(":/res/icons/desktop.png"));
|
||||
ri.name = iter.key().app_name;
|
||||
ri.actionKey = iter.value().at(0);
|
||||
ri.type = 0; //0 means installed apps.
|
||||
|
|
|
@ -838,6 +838,12 @@ QString FileUtils::chineseSubString(const std::string &myStr, int start, int len
|
|||
return sub;
|
||||
}
|
||||
|
||||
QIcon FileUtils::iconFromTheme(const QString &name, const QIcon &iconDefault)
|
||||
{
|
||||
QMutexLocker locker(&iconMutex);
|
||||
return QIcon::fromTheme(name, iconDefault);
|
||||
}
|
||||
|
||||
QString FileUtils::getHtmlText(const QString &text, const QString &keyword)
|
||||
{
|
||||
QString htmlString;
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
static bool copyPath(QString &path);
|
||||
static QString escapeHtml(const QString & str);
|
||||
static QString chineseSubString(const std::string &myStr,int start,int length);
|
||||
static QIcon iconFromTheme(const QString& name, const QIcon &iconDefault);
|
||||
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;
|
||||
|
|
|
@ -54,12 +54,12 @@ void ConstructDocumentForPath::run() {
|
|||
// }
|
||||
|
||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
||||
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath.section("/", 0, -2, QString::SectionIncludeLeadingSep)));
|
||||
QString upTerm = QString::fromStdString("ZEEKERUPTERM" + FileUtils::makeDocUterm(sourcePath.section("/", 0, -2, QString::SectionIncludeLeadingSep)));
|
||||
// qDebug()<<"sourcePath"<<sourcePath.section("/",0,-2,QString::SectionIncludeLeadingSep);
|
||||
// qDebug() << "sourcePath ---------------------------: " << sourcePath;
|
||||
// qDebug() << "sourcePath.section -------------------: " << sourcePath.section("/",0,-2,QString::SectionIncludeLeadingSep);
|
||||
// qDebug() << "ConstructDocumentForPath -- uniqueterm: " << uniqueterm;
|
||||
// qDebug() << "ConstructDocumentForPath -- upTerm: " << upTerm;
|
||||
// qDebug() << "ConstructDocumentForPath -- upTerm : " << upTerm;
|
||||
|
||||
|
||||
doc.setData(sourcePath);
|
||||
|
@ -115,7 +115,7 @@ void ConstructDocumentForContent::run() {
|
|||
//doc.setUniqueTerm(uniqueterm);
|
||||
doc.setUniqueTerm(FileUtils::makeDocUterm(m_path));
|
||||
//doc.addTerm(upTerm);
|
||||
doc.addTerm(FileUtils::makeDocUterm(m_path.section("/", 0, -2, QString::SectionIncludeLeadingSep)));
|
||||
doc.addTerm("ZEEKERUPTERM" + FileUtils::makeDocUterm(m_path.section("/", 0, -2, QString::SectionIncludeLeadingSep)));
|
||||
doc.addValue(m_path);
|
||||
|
||||
//'\xEF\xBC\x8C' is "," "\xE3\x80\x82" is "。" use three " " to replace ,to ensure the offset info.
|
||||
|
|
|
@ -456,20 +456,27 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist) {
|
|||
if(list->isEmpty())
|
||||
return true;
|
||||
try {
|
||||
qDebug() << "--delete start--";
|
||||
for(int i = 0; i < list->size(); i++) {
|
||||
QString doc = list->at(i);
|
||||
std::string uniqueterm = FileUtils::makeDocUterm(doc);
|
||||
qDebug() << "--delete start--";
|
||||
std::string upterm = "ZEEKERUPTERM" + FileUtils::makeDocUterm(doc);
|
||||
|
||||
m_database_path->delete_document(uniqueterm);
|
||||
m_database_content->delete_document(uniqueterm);
|
||||
|
||||
//delete all files under it if it's a dir.
|
||||
m_database_path->delete_document(upterm);
|
||||
m_database_content->delete_document(upterm);
|
||||
qDebug() << "delete path" << doc;
|
||||
qDebug() << "delete md5" << QString::fromStdString(uniqueterm);
|
||||
qDebug() << "--delete finish--";
|
||||
// qDebug() << "delete md5" << QString::fromStdString(uniqueterm);
|
||||
|
||||
// qDebug()<<"m_database_path->get_lastdocid()!!!"<<m_database_path->get_lastdocid();
|
||||
// qDebug()<<"m_database_path->get_doccount()!!!"<<m_database_path->get_doccount();
|
||||
}
|
||||
m_database_path->commit();
|
||||
m_database_content->commit();
|
||||
qDebug() << "--delete finish--";
|
||||
} catch(const Xapian::Error &e) {
|
||||
qWarning() << QString::fromStdString(e.get_description());
|
||||
return false;
|
||||
|
|
|
@ -232,8 +232,8 @@ void InotifyWatch::run()
|
|||
void InotifyWatch::slotEvent(char *buf, ssize_t len)
|
||||
{
|
||||
// eventProcess(socket);
|
||||
++FileUtils::_index_status;
|
||||
if(FileUtils::SearchMethod::INDEXSEARCH == FileUtils::searchMethod) {
|
||||
++FileUtils::_index_status;
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
if(pid == 0) {
|
||||
|
|
|
@ -33,7 +33,7 @@ include(notesearch/notesearch.pri)
|
|||
include(settingsearch/settingsearch.pri)
|
||||
|
||||
LIBS += -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
|
||||
LIBS += -lxapian -lquazip5 -luchardet #-L/usr/local/lib/libjemalloc -ljemalloc
|
||||
LIBS += -lxapian -lquazip5 -luchardet -lQt5Xdg#-L/usr/local/lib/libjemalloc -ljemalloc
|
||||
|
||||
SOURCES += \
|
||||
file-utils.cpp \
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "note-search-plugin.h"
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <qt5xdg/xdgicon.h>
|
||||
#include "file-utils.h"
|
||||
#include "chinese-segmentation.h"
|
||||
using namespace Zeeker;
|
||||
|
@ -183,7 +184,7 @@ void NoteSearch::run() {
|
|||
dbusArgs.endArray();
|
||||
qDebug() << str;
|
||||
SearchPluginIface::ResultInfo ri = {
|
||||
icon : QIcon::fromTheme("kylin-notebook"),
|
||||
icon : XdgIcon::fromTheme("kylin-notebook", QIcon(":/res/icons/desktop.png")),
|
||||
name : str.at(1),
|
||||
description : QVector<SearchPluginIface::DescriptionInfo>() << SearchPluginIface::DescriptionInfo {
|
||||
key : QString(tr("Note Description:")),
|
||||
|
|
|
@ -4874,6 +4874,7 @@ bool KBinaryParser::read8DocText(FILE *pFile, const ppsInfoType *pPPS,
|
|||
const ULONG *aulBlockDepot;
|
||||
ULONG ulTextOffset, ulBeginTextInfo;
|
||||
ULONG ulTotLength, ulLen;
|
||||
ULONG ulEncryptInfo;
|
||||
long lIndex, lPieces, lOff;
|
||||
size_t tTextInfoLen, tBlockDepotLen, tBlockSize;
|
||||
int iType, iLen;
|
||||
|
@ -4882,6 +4883,11 @@ bool KBinaryParser::read8DocText(FILE *pFile, const ppsInfoType *pPPS,
|
|||
|
||||
ulBeginTextInfo = ulGetLong(0x1a2, aucHeader); /* fcClx */
|
||||
tTextInfoLen = (size_t)ulGetLong(0x1a6, aucHeader); /* lcbClx */
|
||||
ulEncryptInfo = ulGetLong(0x0a, aucHeader);
|
||||
if(ulEncryptInfo & 0x0100) {
|
||||
qDebug() << "Encrypt file:" << m_strFileName << (size_t)ulEncryptInfo;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pPPS->tTable.ulSize == 0)
|
||||
return false;
|
||||
|
|
|
@ -39,7 +39,7 @@ ContentWidget::ContentWidget(QWidget * parent): QStackedWidget(parent) {
|
|||
m_quicklyOpenList.replace(2, "/usr/share/applications/eom.desktop");
|
||||
}
|
||||
if (QString::compare(FileUtils::getAppName(m_quicklyOpenList.at(4)), "Unknown App") == 0) {
|
||||
m_quicklyOpenList.replace(4, "/usr/share/applications/org.gnome.Evolution.desktop");
|
||||
m_quicklyOpenList.replace(4, "/usr/share/applications/evolution.desktop");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,20 +105,9 @@ void SearchBarHLayout::initUI() {
|
|||
queryWidLayout->setSpacing(5);
|
||||
m_queryWidget->setLayout(queryWidLayout);
|
||||
|
||||
|
||||
if (!QIcon::fromTheme("system-search-symbolic").isNull()) {
|
||||
QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20)));
|
||||
m_queryIcon = new QLabel;
|
||||
m_queryIcon->setFixedSize(pixmap.size());
|
||||
m_queryIcon->setPixmap(pixmap);
|
||||
} else {
|
||||
QPixmap pixmap(QIcon(":/res/icons/system-search.symbolic.png").pixmap(QSize(20, 20)));
|
||||
m_queryIcon = new QLabel;
|
||||
m_queryIcon->setFixedSize(pixmap.size());
|
||||
m_queryIcon->setPixmap(pixmap);
|
||||
}
|
||||
QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20)));
|
||||
QPixmap pixmap(QIcon::fromTheme("system-search-symbolic", QIcon(":/res/icons/system-search.symbolic.png")).pixmap(QSize(20, 20)));
|
||||
m_queryIcon = new QLabel;
|
||||
m_queryIcon->setProperty("useIconHighlightEffect", 0x10);
|
||||
m_queryIcon->setFixedSize(pixmap.size());
|
||||
m_queryIcon->setPixmap(pixmap);
|
||||
|
||||
|
|
Loading…
Reference in New Issue