forked from openkylin/ukui-search
Add system tray icon.
This commit is contained in:
parent
b225dfa49e
commit
d7ff0e2a31
|
@ -12,6 +12,7 @@
|
|||
#include <QQueue>
|
||||
size_t FileUtils::_max_index_count = 0;
|
||||
size_t FileUtils::_current_index_count = 0;
|
||||
unsigned short FileUtils::_index_status = INITIAL_STATE;
|
||||
QMap<QString, QStringList> FileUtils::map_chinese2pinyin = QMap<QString, QStringList>();
|
||||
|
||||
FileUtils::FileUtils()
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include <QIcon>
|
||||
#include <QMap>
|
||||
#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();
|
||||
|
|
|
@ -75,6 +75,7 @@ bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
|
|||
//文件内容索引
|
||||
bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
|
||||
{
|
||||
FileUtils::_index_status = CREATING_INDEX;
|
||||
HandlePathList(messageList);
|
||||
try
|
||||
{
|
||||
|
@ -99,6 +100,7 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *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"<<doc;
|
||||
qDebug()<<"delete md5"<<QString::fromStdString(uniqueterm);
|
||||
m_datebase_path->commit();
|
||||
FileUtils::_current_index_count -= 1;
|
||||
|
||||
FileUtils::_current_index_count = m_datebase_path->get_doccount();
|
||||
|
||||
qDebug()<< "--delete finish--";
|
||||
}
|
||||
catch(const Xapian::Error &e)
|
||||
|
|
|
@ -99,6 +99,20 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair<QString, QStringList> 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()
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <QFrame>
|
||||
#include <QPushButton>
|
||||
#include <QGSettings/QGSettings>
|
||||
#include <QSystemTrayIcon>
|
||||
#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 *);
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue