From ea5242b921396e5fb8ca2fd80a0cc15f1c9f8000 Mon Sep 17 00:00:00 2001 From: iaom <18504285112@163.com> Date: Fri, 6 Aug 2021 10:54:48 +0800 Subject: [PATCH] Update UI;Update internal plugins. --- frontend/control/search-line-edit.cpp | 5 +++ frontend/control/search-line-edit.h | 1 + frontend/mainwindow.cpp | 32 +++++++++--------- libsearch/appsearch/app-search-plugin.cpp | 14 ++------ libsearch/file-utils.cpp | 2 +- libsearch/index/file-search-plugin.cpp | 6 ++-- libsearch/index/search-manager.cpp | 2 +- libsearch/plugininterface/data-queue.h | 9 +++++ libsearch/res/icons/close.svg | 1 + libsearch/res/icons/desktop.png | Bin 0 -> 998 bytes libsearch/res/icons/edit-find-symbolic.svg | 14 ++++++++ libsearch/res/icons/net-disconnected.svg | 30 ++++++++++++++++ .../res/icons/system-search.symbolic.png | Bin 0 -> 498 bytes libsearch/resource1.qrc | 5 +++ .../settingsearch/settings-search-plugin.cpp | 8 ++--- 15 files changed, 93 insertions(+), 36 deletions(-) create mode 100644 libsearch/res/icons/close.svg create mode 100644 libsearch/res/icons/desktop.png create mode 100644 libsearch/res/icons/edit-find-symbolic.svg create mode 100644 libsearch/res/icons/net-disconnected.svg create mode 100644 libsearch/res/icons/system-search.symbolic.png diff --git a/frontend/control/search-line-edit.cpp b/frontend/control/search-line-edit.cpp index 9e83b05..6b4032e 100644 --- a/frontend/control/search-line-edit.cpp +++ b/frontend/control/search-line-edit.cpp @@ -108,6 +108,11 @@ void SeachBarWidget::clear() m_searchLineEdit->clear(); } +void SeachBarWidget::reSearch() +{ + Q_EMIT this->m_searchLineEdit->requestSearchKeyword(m_searchLineEdit->text()); +} + void SeachBarWidget::paintEvent(QPaintEvent *e) { Q_UNUSED(e) diff --git a/frontend/control/search-line-edit.h b/frontend/control/search-line-edit.h index 493d291..85b99f6 100644 --- a/frontend/control/search-line-edit.h +++ b/frontend/control/search-line-edit.h @@ -62,6 +62,7 @@ public: ~SeachBarWidget(); void clear(); + void reSearch(); protected: void paintEvent(QPaintEvent *e); diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index 4c6aee1..7e5e04d 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -411,7 +411,7 @@ void MainWindow::centerToScreen(QWidget* widget) { desk_x = width; desk_y = height; } - widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); + widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 3 + desk_rect.top()); } void MainWindow::initGsettings() { @@ -457,21 +457,21 @@ void MainWindow::initTimer() { }); m_researchTimer = new QTimer; m_researchTimer->setInterval(RESEARCH_TIME); -// connect(m_researchTimer, &QTimer::timeout, this, [ = ]() { -// if(this->isVisible()) { -// m_searchLayout->reSearch(); -// } -// m_researchTimer->stop(); -// }); -// connect(m_searchLayout, &SearchBarHLayout::requestSearchKeyword, this, [ = ](QString text) { -// if(text == "" || text.isEmpty()) { -// m_askTimer->stop(); -// } else { -// //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索 -// if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) -// m_askTimer->start(); -// } -// }); + connect(m_researchTimer, &QTimer::timeout, this, [ = ]() { + if(this->isVisible()) { + m_searchBarWidget->reSearch(); + } + m_researchTimer->stop(); + }); + connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, [ = ](QString text) { + if(text == "" || text.isEmpty()) { + m_askTimer->stop(); + } else { + //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索 + if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) + m_askTimer->start(); + } + }); } /** diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index a1d9ffa..815b8e2 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -15,7 +15,7 @@ AppSearchPlugin::AppSearchPlugin(QObject *parent) : QObject(parent) m_actionInfo_installed << open << addtoDesktop << addtoPanel; m_actionInfo_not_installed << install; AppMatch::getAppMatch()->start(); - m_pool.setMaxThreadCount(2); + m_pool.setMaxThreadCount(1); m_pool.setExpiryTimeout(1000); initDetailPage(); } @@ -292,11 +292,7 @@ void AppSearch::run() while (i.hasNext()) { i.next(); SearchPluginIface::ResultInfo ri; - if(!QIcon::fromTheme(i.value().at(1)).isNull()) { - ri.icon = QIcon::fromTheme(i.value().at(1)); - }else { - ri.icon = QIcon(":/res/icons/desktop.png"); - } + ri.icon = QIcon::fromTheme(i.value().at(1), QIcon(":/res/icons/desktop.png")); ri.name = i.key().app_name; ri.actionKey = i.value().at(0); ri.type = 0; //0 means installed apps. @@ -310,11 +306,7 @@ void AppSearch::run() while (in.hasNext()) { in.next(); SearchPluginIface::ResultInfo ri; - if(!QIcon(in.value().at(1)).isNull()) { - ri.icon = QIcon(in.value().at(1)); - }else { - ri.icon = QIcon(":/res/icons/desktop.png"); - } + ri.icon = QIcon::fromTheme(in.value().at(1), QIcon(":/res/icons/desktop.png")); ri.name = in.key().app_name; SearchPluginIface::DescriptionInfo di; di.key = QString(tr("Application Description:")); diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 9a054c6..9159a08 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -73,7 +73,7 @@ QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) { } } } - if(QIcon::fromTheme(icon_name).isNull()) { + if(!QIcon::hasThemeIcon(icon_name)) { return QIcon::fromTheme("unknown"); } return QIcon::fromTheme(icon_name); diff --git a/libsearch/index/file-search-plugin.cpp b/libsearch/index/file-search-plugin.cpp index 2e29131..63d7c59 100644 --- a/libsearch/index/file-search-plugin.cpp +++ b/libsearch/index/file-search-plugin.cpp @@ -11,7 +11,7 @@ FileSearchPlugin::FileSearchPlugin(QObject *parent) : QObject(parent) SearchPluginIface::Actioninfo Openpath { 1, tr("Open path")}; SearchPluginIface::Actioninfo CopyPath { 2, tr("Copy Path")}; m_actionInfo << open << Openpath << CopyPath; - m_pool.setMaxThreadCount(2); + m_pool.setMaxThreadCount(1); m_pool.setExpiryTimeout(1000); initDetailPage(); } @@ -200,7 +200,7 @@ DirSearchPlugin::DirSearchPlugin(QObject *parent) : QObject(parent) SearchPluginIface::Actioninfo Openpath { 1, tr("Open path")}; SearchPluginIface::Actioninfo CopyPath { 2, tr("Copy Path")}; m_actionInfo << open << Openpath << CopyPath; - m_pool.setMaxThreadCount(2); + m_pool.setMaxThreadCount(1); m_pool.setExpiryTimeout(1000); initDetailPage(); } @@ -380,7 +380,7 @@ FileContengSearchPlugin::FileContengSearchPlugin(QObject *parent) : QObject(pare SearchPluginIface::Actioninfo Openpath { 1, tr("Open path")}; SearchPluginIface::Actioninfo CopyPath { 2, tr("Copy Path")}; m_actionInfo << open << Openpath << CopyPath; - m_pool.setMaxThreadCount(2); + m_pool.setMaxThreadCount(1); m_pool.setExpiryTimeout(1000); initDetailPage(); } diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index e8dad92..f59a600 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -94,7 +94,7 @@ bool SearchManager::creatResultInfo(SearchPluginIface::ResultInfo &ri, QString p if(!info.exists()) { return false; } - ri.icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()); + ri.icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString(), false); ri.name = info.fileName(); ri.description = QVector() \ << SearchPluginIface::DescriptionInfo{tr("Path:"), path} \ diff --git a/libsearch/plugininterface/data-queue.h b/libsearch/plugininterface/data-queue.h index 6820299..6c08d0b 100644 --- a/libsearch/plugininterface/data-queue.h +++ b/libsearch/plugininterface/data-queue.h @@ -18,6 +18,15 @@ public: QMutexLocker locker(&m_mutex); return QList::takeFirst(); } + inline void clear() { + QMutexLocker locker(&m_mutex); + QList::clear(); + return; + } + inline bool isEmpty() { + QMutexLocker locker(&m_mutex); + return QList::isEmpty(); + } private: QMutex m_mutex; }; diff --git a/libsearch/res/icons/close.svg b/libsearch/res/icons/close.svg new file mode 100644 index 0000000..06a5a23 --- /dev/null +++ b/libsearch/res/icons/close.svg @@ -0,0 +1 @@ +close \ No newline at end of file diff --git a/libsearch/res/icons/desktop.png b/libsearch/res/icons/desktop.png new file mode 100644 index 0000000000000000000000000000000000000000..92c38eea599766ac785310ae4413cb8fee9875c2 GIT binary patch literal 998 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGooCO|{#S9GGLLkg|>2BR01_tIC zo-U3d6?5LsJ(zttK<0S-?X#hd+ZHKYd}t;+kA;0+n=^YHtG`m*5_SDUU+fG1u{(cw zv~pfb#m#qIO3ktAC-@cxrQSH5AZA;V6Z<4Q>P6B$?``{@%>GtuFQAcl^3r?t_kZK! zCh0!^y-&&F(-}E#)`o=)1|ke?Oa}rOB)Axy851-Zc(4hc3AnQUf7snwx9vY@|32I7 zy>ER{vs?#nk>yi<(NFi=KkfYV^yEj=%X+=rRrZH%fA{{K>3xGAj}?{N+PL|bsUM$S zYJGugg7N;1*Z-XOQ0=TD(#~yOs_S^0)pPsh^$+*2S<|+zK4#zSU+2BsCM^xhvdWRp z6`W>gfA6|#;EYXIxDu`>^9N6pX=?(z*3Fvd@1Lja^CP#MxT-C@u(UxJ;5;-Bsur+NsI0^HhUJ#yKA@F&SuvNHSfcJ3r=i2xu;>N z_46xhR|c;=e|?YO){O>B)AlI+*^x6blkw^6#jj5GURqdsb?)A4Mj9z$4Rf9reJc;n zms#=YcGMfI3;ZcT4I;5Gzq@z0^ZOsVzrr-(_*9meGOV6Igp=F5-+umnJ1h0G|C`zZ zqjxh(#P9O0o?Ur^Rk+r+P-xGYs~n%#*ByJceX`CjKi^}ehojGe3({XV?G9C#G)jb248i zc2}X(*L8-PExnT6Wg+ynEY0{W&sK^5y`r9Se9i}9HfS((2ECGB YT~xKkc%{1yFyk_Ky85}Sb4q9e07G%Q?EnA( literal 0 HcmV?d00001 diff --git a/libsearch/res/icons/edit-find-symbolic.svg b/libsearch/res/icons/edit-find-symbolic.svg new file mode 100644 index 0000000..82e1356 --- /dev/null +++ b/libsearch/res/icons/edit-find-symbolic.svg @@ -0,0 +1,14 @@ + + + edit-find-symbolic + + + + + + + + + + + \ No newline at end of file diff --git a/libsearch/res/icons/net-disconnected.svg b/libsearch/res/icons/net-disconnected.svg new file mode 100644 index 0000000..4d5f99f --- /dev/null +++ b/libsearch/res/icons/net-disconnected.svg @@ -0,0 +1,30 @@ + + + + image-viewer-app-symbolic + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libsearch/res/icons/system-search.symbolic.png b/libsearch/res/icons/system-search.symbolic.png new file mode 100644 index 0000000000000000000000000000000000000000..170e2a2a05297dedb13f5ffb07a5c53f07251503 GIT binary patch literal 498 zcmV=FZ%C=REh%IfoIe zHh^amEi|wnU-1qb*r@`@Fpm@1Q}BHY4{;AahXL%vHO!^euHY#?;ydbSVis+D!cDyD zx0BA`i+F;o7%%a+u#8ol90YJZ1wTKCIq3kF@CeiWjG4bHA68R%j9dLoi@2}+SbFKA zSYXyUnP1vH##SBz*ri47R-R! z)^&$D;7b}0Rs_`XtqAZojm?UHCN_%z8=|+&RtTPndU#d@*b$AZEi!6Y)o?}huC-pK zG0_>9Mfne-OQOh5ml= index/pinyinWithTone.txt index/pinyinWithoutTone.txt + res/icons/desktop.png + res/icons/close.svg + res/icons/edit-find-symbolic.svg + res/icons/net-disconnected.svg + res/icons/system-search.symbolic.png diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index 88549b2..23c5539 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -50,7 +50,7 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueueappend(resultInfo); + searchResult->enqueue(resultInfo); continue; } @@ -63,7 +63,7 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueueappend(resultInfo); + searchResult->enqueue(resultInfo); break; } if (keyword.size() < 2) @@ -74,7 +74,7 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueueappend(resultInfo); + searchResult->enqueue(resultInfo); break; } } @@ -94,7 +94,7 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueueappend(resultInfo); + searchResult->enqueue(resultInfo); } } }