diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 5e03d2d..2f0864d 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -12,6 +12,7 @@ #include size_t FileUtils::_max_index_count = 0; size_t FileUtils::_current_index_count = 0; +unsigned short FileUtils::_index_status = INITIAL_STATE; QMap FileUtils::map_chinese2pinyin = QMap(); FileUtils::FileUtils() diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index 3e8b19f..2c6e692 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -6,6 +6,9 @@ #include #include #include "libsearch_global.h" +#define INITIAL_STATE 0 +#define CREATING_INDEX 1 +#define FINISH_CREATING_INDEX 2 class LIBSEARCH_EXPORT FileUtils { @@ -31,6 +34,7 @@ public: static void getTxtContent(QString &path, QString &textcontent); static size_t _max_index_count; static size_t _current_index_count; + static unsigned short _index_status; private: FileUtils(); diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index 366f3b7..3dc3c39 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -75,6 +75,7 @@ bool IndexGenerator::creatAllIndex(QQueue > *messageList) //文件内容索引 bool IndexGenerator::creatAllIndex(QQueue *messageList) { + FileUtils::_index_status = CREATING_INDEX; HandlePathList(messageList); try { @@ -99,6 +100,7 @@ bool IndexGenerator::creatAllIndex(QQueue *messageList) } m_doc_list_content->clear(); Q_EMIT this->transactionFinished(); + FileUtils::_index_status = FINISH_CREATING_INDEX; return true; } @@ -359,7 +361,9 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist) qDebug()<<"delete path"<commit(); - FileUtils::_current_index_count -= 1; + + FileUtils::_current_index_count = m_datebase_path->get_doccount(); + qDebug()<< "--delete finish--"; } catch(const Xapian::Error &e) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9fa7359..864d480 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,6 +99,20 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair pair) { m_contentFrame->appendSearchItem(SearchItem::SearchType::Contents, pair.first, m_searchLayout->text(), pair.second); }); + + m_sys_tray_icon = new QSystemTrayIcon(this); + m_sys_tray_icon->setIcon(QIcon::fromTheme("system-search-symbolic")); + m_sys_tray_icon->setToolTip(tr("Global Search")); + m_sys_tray_icon->show(); + connect(m_sys_tray_icon,&QSystemTrayIcon::activated,this,[=](QSystemTrayIcon::ActivationReason reason){ + if(reason == QSystemTrayIcon::Trigger) + { + clearSearchResult(); + this->show(); + this->raise(); + this->activateWindow(); + } + }); } MainWindow::~MainWindow() diff --git a/src/mainwindow.h b/src/mainwindow.h index 38d0d6c..cb3519f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "content-widget.h" #include "input-box.h" #include "index/index-generator.h" @@ -90,6 +91,7 @@ private: SearchResult * m_search_result_thread = nullptr; FileSearcher* m_searcher = nullptr; + QSystemTrayIcon *m_sys_tray_icon; protected: void paintEvent(QPaintEvent *); diff --git a/src/search-result.cpp b/src/search-result.cpp index 13f6170..36431c4 100644 --- a/src/search-result.cpp +++ b/src/search-result.cpp @@ -43,7 +43,7 @@ void SearchResult::run() m_mainwindow->m_searcher->m_mutex2.unlock(); } m_mainwindow->m_searcher->m_mutex3.lock(); - if (!m_mainwindow->m_search_result_content->isEmpty()) +// if (!m_mainwindow->m_search_result_content->isEmpty()) // qDebug() << m_mainwindow->m_search_result_content->head(); if (!m_mainwindow->m_search_result_content->isEmpty()) { Q_EMIT this->searchResultContent(m_mainwindow->m_search_result_content->dequeue());