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 0000000..92c38ee Binary files /dev/null and b/libsearch/res/icons/desktop.png differ 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 0000000..170e2a2 Binary files /dev/null and b/libsearch/res/icons/system-search.symbolic.png differ diff --git a/libsearch/resource1.qrc b/libsearch/resource1.qrc index 3e92670..cdcb612 100644 --- a/libsearch/resource1.qrc +++ b/libsearch/resource1.qrc @@ -2,5 +2,10 @@ 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); } } }