diff --git a/data/org.ukui.search.data.gschema.xml b/data/org.ukui.search.data.gschema.xml new file mode 100644 index 0000000..2494b22 --- /dev/null +++ b/data/org.ukui.search.data.gschema.xml @@ -0,0 +1,9 @@ + + + + false + search method + Is current search-method index-search. + + + diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 6c89018..91944e1 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -25,6 +25,7 @@ size_t FileUtils::_max_index_count = 0; size_t FileUtils::_current_index_count = 0; unsigned short FileUtils::_index_status = 0; +FileUtils::SearchMethod FileUtils::searchMethod = FileUtils::SearchMethod::DIRECTSEARCH; QMap FileUtils::map_chinese2pinyin = QMap(); FileUtils::FileUtils() diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index 223be43..77c2808 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -88,8 +88,8 @@ public: static size_t _current_index_count; //this one has been Abandoned,do not use it. static unsigned short _index_status; -// enum class SearchMethod{ DIRECTSEARCH = 0, INDEXSEARCH = 1}; -// static SearchMethod searchMethod = FileUtils::SearchMethod::DIRECTSEARCH; + enum class SearchMethod{ DIRECTSEARCH = 0, INDEXSEARCH = 1}; + static SearchMethod searchMethod; private: FileUtils(); diff --git a/libsearch/global-settings.cpp b/libsearch/global-settings.cpp index 34b7176..318f3e3 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -268,14 +268,14 @@ void GlobalSettings::setValue(const QString &key, const QVariant &value) // m_settings->sync(); QtConcurrent::run([=]() { // qDebug()<status(); - // if (m_mutex.tryLock(1000)) { +// if (m_mutex.tryLock(1000)) { // m_mutex.lock(); m_settings->setValue(key, value); // qDebug()<<"setvalue========finish!!!"<sync(); // qDebug()<<"setvalue========sync!!!"<(); qDebug("---------------------------%s %s %s new at %d..",__FILE__,__FUNCTION__,#a,__LINE__); //#define DELETE_QUEUE(a ) -FirstIndex::FirstIndex(const QString& path) : Traverse_BFS(path) +FirstIndex::FirstIndex() { +} + +FirstIndex::~FirstIndex() +{ + qDebug() << "~FirstIndex"; + if(this->q_index) + delete this->q_index; + this->q_index = nullptr; + if(this->q_content_index) + delete this->q_content_index; + this->q_content_index = nullptr; + if (this->p_indexGenerator) + delete this->p_indexGenerator; + this->p_indexGenerator = nullptr; + qDebug() << "~FirstIndex end"; +} + +void FirstIndex::DoSomething(const QFileInfo& fileInfo){ +// qDebug() << "there are some shit here"<q_index->enqueue(QVector() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0")); + if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){ + this->q_content_index->enqueue(fileInfo.absoluteFilePath()); + } +} + +void FirstIndex::run(){ + QTime t1 = QTime::currentTime(); + + // Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running. + QDir fifoDir = QDir(QDir::homePath()+"/.config/org.ukui/ukui-search"); + if(!fifoDir.exists()) + qDebug()<<"create fifo path"<getValue(INDEX_DATABASE_STATE).toString(); QString contentIndexDataBaseStatus = GlobalSettings::getInstance()->getValue(CONTENT_INDEX_DATABASE_STATE).toString(); QString inotifyIndexStatus = GlobalSettings::getInstance()->getValue(INOTIFY_NORMAL_EXIT).toString(); @@ -53,35 +97,6 @@ FirstIndex::FirstIndex(const QString& path) : Traverse_BFS(path) //this->q_content_index = new QQueue(); NEW_QUEUE(this->q_content_index); // this->mlm = new MessageListManager(); -} - -FirstIndex::~FirstIndex() -{ - qDebug() << "~FirstIndex"; - if(this->q_index) - delete this->q_index; - this->q_index = nullptr; - if(this->q_content_index) - delete this->q_content_index; - this->q_content_index = nullptr; - if (this->p_indexGenerator) - delete this->p_indexGenerator; - this->p_indexGenerator = nullptr; - qDebug() << "~FirstIndex end"; -// delete this->mlm; -// this->mlm = nullptr; -} - -void FirstIndex::DoSomething(const QFileInfo& fileInfo){ -// qDebug() << "there are some shit here"<q_index->enqueue(QVector() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0")); - if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){ - this->q_content_index->enqueue(fileInfo.absoluteFilePath()); - } -} - -void FirstIndex::run(){ - QTime t1 = QTime::currentTime(); int fifo_fd; char buffer[2]; @@ -189,7 +204,7 @@ void FirstIndex::run(){ if (p_indexGenerator) delete p_indexGenerator; p_indexGenerator = nullptr; - GlobalSettings::getInstance()->forceSync(); +// GlobalSettings::getInstance()->forceSync(); ::_exit(0); } else if(pid < 0) @@ -204,8 +219,8 @@ void FirstIndex::run(){ GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "2"); - int retval = write(fifo_fd, buffer, strlen(buffer)); - if(retval == -1) + int retval1 = write(fifo_fd, buffer, strlen(buffer)); + if(retval1 == -1) { qWarning("write error\n"); } diff --git a/libsearch/index/first-index.h b/libsearch/index/first-index.h index 2d90ba9..5a19edb 100644 --- a/libsearch/index/first-index.h +++ b/libsearch/index/first-index.h @@ -34,6 +34,7 @@ #include #include #include +#include //#include #include "traverse_bfs.h" #include "global-settings.h" @@ -44,7 +45,7 @@ class FirstIndex : public QThread, public Traverse_BFS { public: - FirstIndex(const QString&); + FirstIndex(); ~FirstIndex(); virtual void DoSomething(const QFileInfo &) final; protected: diff --git a/libsearch/index/index.pri b/libsearch/index/index.pri index 8d96cc7..9ae146d 100644 --- a/libsearch/index/index.pri +++ b/libsearch/index/index.pri @@ -8,6 +8,7 @@ HEADERS += \ $$PWD/index-generator.h \ $$PWD/inotify-index.h \ $$PWD/search-manager.h \ + $$PWD/searchmethodmanager.h \ $$PWD/traverse_bfs.h \ $$PWD/ukui-search-qdbus.h @@ -19,6 +20,7 @@ SOURCES += \ $$PWD/index-generator.cpp \ $$PWD/inotify-index.cpp \ $$PWD/search-manager.cpp \ + $$PWD/searchmethodmanager.cpp \ $$PWD/traverse_bfs.cpp \ $$PWD/ukui-search-qdbus.cpp diff --git a/libsearch/index/inotify-index.cpp b/libsearch/index/inotify-index.cpp index fa7ae2b..2923fc8 100644 --- a/libsearch/index/inotify-index.cpp +++ b/libsearch/index/inotify-index.cpp @@ -53,17 +53,12 @@ InotifyIndex::InotifyIndex(const QString& path) : Traverse_BFS(path) usQDBus.setInotifyMaxUserWatches(); qDebug() << "setInotifyMaxUserWatches end"; - m_fd = inotify_init(); - qDebug() << "m_fd----------->" <AddWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); - this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); - this->firstTraverse(); } InotifyIndex::~InotifyIndex() { IndexGenerator::getInstance()->~IndexGenerator(); + qWarning() << "~InotifyIndex"; } void InotifyIndex::firstTraverse(){ @@ -113,7 +108,7 @@ bool InotifyIndex::AddWatch(const QString &path){ return true; } -bool InotifyIndex::RemoveWatch(const QString &path){ +bool InotifyIndex::RemoveWatch(const QString &path, bool removeFromDatabase){ int ret = inotify_rm_watch(m_fd, currentPath.key(path)); if (ret){ qDebug() << "remove path error"; @@ -122,33 +117,60 @@ bool InotifyIndex::RemoveWatch(const QString &path){ // Q_ASSERT(ret == 0); assert(ret == 0); - for (QMap::Iterator i = currentPath.begin(); i != currentPath.end();){ -// qDebug() << i.value(); - if (i.value().length() > path.length()){ -// if (i.value().mid(0, path.length()) == path){ -// if (path.startsWith(i.value())){ - if (i.value().startsWith(path)){ - qDebug() << "remove path: " << i.value(); - ret = inotify_rm_watch(m_fd, currentPath.key(path)); - if (ret){ - qDebug() << "remove path error"; -// return false; + if (removeFromDatabase) { + for (QMap::Iterator i = currentPath.begin(); i != currentPath.end();) { + // qDebug() << i.value(); + if (i.value().length() > path.length()){ + // if (i.value().mid(0, path.length()) == path){ + // if (path.startsWith(i.value())){ + if (i.value().startsWith(path)){ + qDebug() << "remove path: " << i.value(); + ret = inotify_rm_watch(m_fd, currentPath.key(path)); + if (ret){ + qDebug() << "remove path error"; + // return false; + } + // assert(ret == 0); + /*--------------------------------*/ + //在此调用删除索引 + qDebug() << i.value(); + IndexGenerator::getInstance()->deleteAllIndex(new QStringList(i.value())); + /*--------------------------------*/ + currentPath.erase(i++); + // i++; + } + else{ + i++; } -// assert(ret == 0); - /*--------------------------------*/ - //在此调用删除索引 - qDebug() << i.value(); - IndexGenerator::getInstance()->deleteAllIndex(new QStringList(i.value())); - /*--------------------------------*/ - currentPath.erase(i++); -// i++; } else{ i++; } } - else{ - i++; + } else { + for (QMap::Iterator i = currentPath.begin(); i != currentPath.end();) { + // qDebug() << i.value(); + if (i.value().length() > path.length()){ + // if (i.value().mid(0, path.length()) == path){ + // if (path.startsWith(i.value())){ + if (i.value().startsWith(path)){ + qDebug() << "remove path: " << i.value(); + ret = inotify_rm_watch(m_fd, currentPath.key(path)); + if (ret){ + qDebug() << "remove path error"; + // return false; + } + // assert(ret == 0); + currentPath.erase(i++); + // i++; + } + else{ + i++; + } + } + else{ + i++; + } } } // qDebug() << path; @@ -228,6 +250,13 @@ next: } void InotifyIndex::run(){ + m_fd = inotify_init(); + qDebug() << "m_fd----------->" <AddWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + this->firstTraverse(); + int fifo_fd; char buffer[2]; memset(buffer, 0, sizeof(buffer)); @@ -256,8 +285,8 @@ void InotifyIndex::run(){ ssize_t numRead; - for (;;) { /* Read events forever */ -read: + while (FileUtils::SearchMethod::INDEXSEARCH == FileUtils::searchMethod) { +// for (;;) { /* Read events forever */ memset(buf, 0x00, BUF_LEN); numRead = read(m_fd, buf, BUF_LEN); @@ -276,14 +305,14 @@ read: // qDebug() << "Read Event: " << currentPath[event->wd] << QString(event->name) << event->cookie << event->wd << event->mask; if(event->name[0] != '.'){ GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0"); - goto fork; + break; } tmp += sizeof(struct inotify_event) + event->len; - } - goto read; + if (tmp >= buf + numRead) { + continue; + } -fork: ++FileUtils::_index_status; pid_t pid; @@ -323,7 +352,7 @@ fork: qDebug() << "select timeout!"; ::free(read_timeout); IndexGenerator::getInstance()->~IndexGenerator(); - GlobalSettings::getInstance()->forceSync(); +// GlobalSettings::getInstance()->forceSync(); ::_exit(0); }else{ GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0"); @@ -343,7 +372,6 @@ fork: else if (pid > 0){ memset(buf, 0x00, BUF_LEN); waitpid(pid, NULL, 0); - --FileUtils::_index_status; } else{ @@ -351,4 +379,11 @@ fork: } } + if (FileUtils::SearchMethod::DIRECTSEARCH == FileUtils::searchMethod) { + GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "3"); + RemoveWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation), false); + } + + + } diff --git a/libsearch/index/inotify-index.h b/libsearch/index/inotify-index.h index 0bbb7c9..d8c5227 100644 --- a/libsearch/index/inotify-index.h +++ b/libsearch/index/inotify-index.h @@ -48,7 +48,7 @@ public: ~InotifyIndex(); bool AddWatch(const QString&); - bool RemoveWatch(const QString&); + bool RemoveWatch(const QString&, bool removeFromDatabase = true); virtual void DoSomething(const QFileInfo &) final; void eventProcess(const char*, ssize_t); @@ -56,7 +56,6 @@ public: protected: void run() override; private: - QString* m_watch_path; int m_fd; QMap currentPath; diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index b8202cb..ca16f93 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -37,14 +37,11 @@ SearchManager::~SearchManager() int SearchManager::getCurrentIndexCount() { - try - { + try { Xapian::Database db(INDEX_PATH); return db.get_doccount(); - } - catch(const Xapian::Error &e) - { - qWarning() < *searchResul ++uniqueSymbol3; m_mutex3.unlock(); + if (FileUtils::SearchMethod::DIRECTSEARCH == FileUtils::searchMethod) { + DirectSearch *directSearch; + directSearch = new DirectSearch(keyword, searchResultFile, searchResultDir, uniqueSymbol1); + m_pool.start(directSearch); + } else if (FileUtils::SearchMethod::INDEXSEARCH == FileUtils::searchMethod) { + FileSearch *filesearch; + filesearch = new FileSearch(searchResultFile,uniqueSymbol1,keyword,"0",1,0,5); + m_pool.start(filesearch); + FileSearch *dirsearch; + dirsearch = new FileSearch(searchResultDir,uniqueSymbol2,keyword,"1",1,0,5); + m_pool.start(dirsearch); - FileSearch *filesearch; - filesearch = new FileSearch(searchResultFile,uniqueSymbol1,keyword,"0",1,0,5); - m_pool.start(filesearch); - - FileSearch *dirsearch; - dirsearch = new FileSearch(searchResultDir,uniqueSymbol2,keyword,"1",1,0,5); - m_pool.start(dirsearch); - - FileContentSearch *contentSearch; - contentSearch = new FileContentSearch(searchResultContent,uniqueSymbol3,keyword,0,5); - m_pool.start(contentSearch); + FileContentSearch *contentSearch; + contentSearch = new FileContentSearch(searchResultContent,uniqueSymbol3,keyword,0,5); + m_pool.start(contentSearch); + } else { + qWarning() << "Unknown search method! FileUtils::searchMethod: " << static_cast(FileUtils::searchMethod); + } return; } @@ -109,14 +112,14 @@ FileSearch::~FileSearch() void FileSearch::run() { - if(!m_search_result->isEmpty()) + if (!m_search_result->isEmpty()){ m_search_result->clear(); + } int resultCount = 0; int total = 0; - while(total < 100) - { + while (total < 100) { resultCount = keywordSearchfile(); - if(resultCount == 0 || resultCount == -1) + if (resultCount == 0 || resultCount == -1) break; total += resultCount; m_begin += m_num; @@ -126,22 +129,18 @@ void FileSearch::run() int FileSearch::keywordSearchfile() { - try - { + try { qDebug() << "--keywordSearchfile start--"; Xapian::Database db(INDEX_PATH); Xapian::Query query = creatQueryForFileSearch(db); Xapian::Enquire enquire(db); Xapian::Query queryFile; - if(!m_value.isEmpty()) - { + if (!m_value.isEmpty()) { std::string slotValue = m_value.toStdString(); Xapian::Query queryValue = Xapian::Query(Xapian::Query::OP_VALUE_RANGE,m_slot,slotValue,slotValue); queryFile = Xapian::Query(Xapian::Query::OP_AND,query,queryValue); - } - else - { + } else { queryFile = query; } @@ -150,19 +149,17 @@ int FileSearch::keywordSearchfile() enquire.set_query(queryFile); Xapian::MSet result = enquire.get_mset(m_begin, m_num); int resultCount = result.size(); - qDebug()<< "keywordSearchfile results count=" < v; - for(int i=0;iappend(QString::fromStdString(data)); + if (!info.exists()) { +// pathTobeDelete->append(QString::fromStdString(data)); qDebug()<enqueue(path); SearchManager::m_mutex1.unlock(); - } - else - { + } else { SearchManager::m_mutex1.unlock(); return -1; } @@ -221,13 +210,10 @@ int FileSearch::getResult(Xapian::MSet &result) break; case 0: SearchManager::m_mutex2.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbol1) - { + if(m_uniqueSymbol == SearchManager::uniqueSymbol1) { m_search_result->enqueue(path); SearchManager::m_mutex2.unlock(); - } - else - { + } else { SearchManager::m_mutex2.unlock(); return -1; } @@ -237,7 +223,7 @@ int FileSearch::getResult(Xapian::MSet &result) } // searchResult.append(path); } - qDebug()<< "doc="<< path << ",weight=" < sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword); //Creat a query std::string words; - for(int i=0;iappend(QString::fromStdString(data)); - qDebug()< 6 + QString::fromStdString(keyWord).size()) + if (snippet.size() > 6 + QString::fromStdString(keyWord).size()){ snippet.replace(0,3,"...").replace(snippet.size()-3,3,"..."); - else + } else { snippet.append("...").prepend("..."); + } snippets.append(snippet); QString().swap(snippet); std::string().swap(s); @@ -418,23 +402,71 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord) // } SearchManager::m_mutex3.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbol3) - { - + if (m_uniqueSymbol == SearchManager::uniqueSymbol3) { m_search_result->enqueue(qMakePair(path,snippets)); SearchManager::m_mutex3.unlock(); snippets.clear(); QStringList().swap(snippets); - } - else - { + } else { SearchManager::m_mutex3.unlock(); return -1; } // searchResult.insert(path,snippets); - qDebug()<< "path="<< path << ",weight=" <(sm); + if (FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == sm) { + FileUtils::searchMethod = sm; + } else { + printf("enum class error!!!\n"); + qWarning("enum class error!!!\n"); + } + if (FileUtils::SearchMethod::INDEXSEARCH == sm && 0 == FileUtils::_index_status) { + qWarning() << "start first index"; +// m_fi = FirstIndex("/home/zhangzihao/Desktop"); + m_fi.start(); + qWarning() << "start inotify index"; +// InotifyIndex ii("/home"); +// ii.start(); + this->m_ii = InotifyIndex::getInstance("/home"); + if (!this->m_ii->isRunning()) { + this->m_ii->start(); + } + qDebug()<<"Search method has been set to INDEXSEARCH"; + } + qWarning() << "searchMethod end: " << static_cast(FileUtils::searchMethod); +} diff --git a/libsearch/index/searchmethodmanager.h b/libsearch/index/searchmethodmanager.h new file mode 100644 index 0000000..ec6267a --- /dev/null +++ b/libsearch/index/searchmethodmanager.h @@ -0,0 +1,17 @@ +#ifndef SEARCHMETHODMANAGER_H +#define SEARCHMETHODMANAGER_H + +#include "first-index.h" +#include "inotify-index.h" + +class SearchMethodManager +{ +public: + SearchMethodManager() = default; + void searchMethod(FileUtils::SearchMethod sm); +private: + FirstIndex m_fi; + InotifyIndex* m_ii; +}; + +#endif // SEARCHMETHODMANAGER_H diff --git a/libsearch/index/traverse_bfs.h b/libsearch/index/traverse_bfs.h index b3c414c..d8a4e1d 100644 --- a/libsearch/index/traverse_bfs.h +++ b/libsearch/index/traverse_bfs.h @@ -28,12 +28,13 @@ class Traverse_BFS { public: + Traverse_BFS() = default; void Traverse(); virtual ~Traverse_BFS() = default; virtual void DoSomething(const QFileInfo&) = 0; void setPath(const QString&); protected: - explicit Traverse_BFS(const QString&); + Traverse_BFS(const QString&); QString path = "/home"; private: Traverse_BFS(const Traverse_BFS&) = delete; diff --git a/libsearch/libsearch.h b/libsearch/libsearch.h index 83febb4..f0217ab 100644 --- a/libsearch/libsearch.h +++ b/libsearch/libsearch.h @@ -21,15 +21,16 @@ #define LIBSEARCH_H #include "libsearch_global.h" -#include "index/search-manager.h" #include "appsearch/app-match.h" #include "settingsearch/setting-match.h" #include "file-utils.h" #include "global-settings.h" -#include "index/first-index.h" +#include "index/searchmethodmanager.h" +#include "index/first-index.h" #include "index/ukui-search-qdbus.h" #include "index/inotify-index.h" +#include "index/search-manager.h" class LIBSEARCH_EXPORT GlobalSearch { diff --git a/src/create-index-ask-dialog.cpp b/src/create-index-ask-dialog.cpp new file mode 100644 index 0000000..1f982a9 --- /dev/null +++ b/src/create-index-ask-dialog.cpp @@ -0,0 +1,131 @@ +/* + * + * Copyright (C) 2020, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: zhangjiaping + * + */ + +#include "create-index-ask-dialog.h" +#include + +CreateIndexAskDialog::CreateIndexAskDialog(QWidget *parent) : QDialog(parent) +{ + this->setWindowIcon(QIcon::fromTheme("kylin-search")); + this->setWindowTitle(tr("ukui-search")); + + initUi(); +} + +void CreateIndexAskDialog::initUi() +{ + this->setFixedSize(380, 202); + m_mainLyt = new QVBoxLayout(this); + this->setLayout(m_mainLyt); + m_mainLyt->setContentsMargins(0, 0, 0, 0); + + //标题栏 + m_titleFrame = new QFrame(this); + m_titleFrame->setFixedHeight(40); + m_titleLyt = new QHBoxLayout(m_titleFrame); + m_titleLyt->setContentsMargins(8, 8, 8, 8); + m_titleFrame->setLayout(m_titleLyt); + m_iconLabel = new QLabel(m_titleFrame); + m_iconLabel->setFixedSize(24, 24); + m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + m_titleLabel = new QLabel(m_titleFrame); + m_titleLabel->setText(tr("Search")); + m_closeBtn = new QPushButton(m_titleFrame); + m_closeBtn->setFixedSize(24, 24); + m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); + m_closeBtn->setProperty("isWindowButton", 0x02); + m_closeBtn->setProperty("useIconHighlightEffect", 0x08); + m_closeBtn->setFlat(true); + connect(m_closeBtn, &QPushButton::clicked, this, [ = ]() { + this->hide(); + Q_EMIT this->closed(); + }); + m_titleLyt->addWidget(m_iconLabel); + m_titleLyt->addWidget(m_titleLabel); + m_titleLyt->addStretch(); + m_titleLyt->addWidget(m_closeBtn); + + m_mainLyt->addWidget(m_titleFrame); + + //内容区域 + m_contentFrame = new QFrame(this); + m_contentLyt = new QVBoxLayout(m_contentFrame); + m_contentFrame->setLayout(m_contentLyt); + m_contentLyt->setContentsMargins(32, 16, 32, 24); + + m_tipLabel = new QLabel(m_contentFrame); + m_tipLabel->setText(tr("Creating index can help you getting results quickly, whether to create or not?")); + m_tipLabel->setWordWrap(true); + m_contentLyt->addWidget(m_tipLabel); + + m_checkFrame = new QFrame(m_contentFrame); + m_checkLyt = new QHBoxLayout(m_checkFrame); + m_checkLyt->setContentsMargins(0, 0, 0, 0); + m_checkFrame->setLayout(m_checkLyt); + m_checkBox = new QCheckBox(m_checkFrame); + m_checkBox->setText(tr("Don't remind")); + m_checkLyt->addWidget(m_checkBox); + m_checkLyt->addStretch(); + m_contentLyt->addWidget(m_checkFrame); + m_contentLyt->addStretch(); + + m_btnFrame = new QFrame(m_contentFrame); + m_btnLyt = new QHBoxLayout(m_btnFrame); + m_btnFrame->setLayout(m_btnLyt); + m_btnLyt->setContentsMargins(0, 0, 0, 0); + m_cancelBtn = new QPushButton(m_btnFrame); + m_cancelBtn->setText(tr("No")); + m_confirmBtn = new QPushButton(m_btnFrame); + m_confirmBtn->setText(tr("Yes")); + connect(m_cancelBtn, &QPushButton::clicked, this, [ = ]() { + Q_EMIT this->btnClicked(false, m_checkBox->isChecked()); + this->hide(); + Q_EMIT this->closed(); + }); + connect(m_confirmBtn, &QPushButton::clicked, this, [ = ]() { + Q_EMIT this->btnClicked(true, m_checkBox->isChecked()); + this->hide(); + Q_EMIT this->closed(); + }); + m_btnLyt->addStretch(); + m_btnLyt->addWidget(m_cancelBtn); + m_btnLyt->addWidget(m_confirmBtn); + m_contentLyt->addWidget(m_btnFrame); + + m_mainLyt->addWidget(m_contentFrame); +} + +/** + * @brief CreateIndexAskDialog::paintEvent 绘制窗口背景(默认背景较暗) + */ +void CreateIndexAskDialog::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + QPainterPath rectPath; + rectPath.addRect(this->rect()); + p.save(); + p.fillPath(rectPath,palette().color(QPalette::Base)); + p.restore(); + return QDialog::paintEvent(event); +} diff --git a/src/create-index-ask-dialog.h b/src/create-index-ask-dialog.h new file mode 100644 index 0000000..8a2f940 --- /dev/null +++ b/src/create-index-ask-dialog.h @@ -0,0 +1,72 @@ +/* + * + * Copyright (C) 2020, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: zhangjiaping + * + */ + +#ifndef CREATEINDEXASKDIALOG_H +#define CREATEINDEXASKDIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class CreateIndexAskDialog : public QDialog +{ + Q_OBJECT +public: + CreateIndexAskDialog(QWidget *parent = nullptr); + ~CreateIndexAskDialog() = default; + +private: + void initUi(); + + QVBoxLayout * m_mainLyt = nullptr; + //标题栏 + QFrame * m_titleFrame = nullptr; + QHBoxLayout * m_titleLyt = nullptr; + QLabel * m_iconLabel = nullptr; + QLabel * m_titleLabel = nullptr; + QPushButton * m_closeBtn = nullptr; + + //内容区域 + QFrame * m_contentFrame = nullptr; + QVBoxLayout * m_contentLyt = nullptr; + QLabel * m_tipLabel = nullptr; //提示语 + QFrame * m_checkFrame = nullptr; //"不再提示"选项框区域 + QHBoxLayout * m_checkLyt = nullptr; + QCheckBox * m_checkBox = nullptr; + QFrame * m_btnFrame = nullptr; //底部按钮区域 + QHBoxLayout * m_btnLyt = nullptr; + QPushButton * m_cancelBtn = nullptr; + QPushButton * m_confirmBtn = nullptr; + + void paintEvent(QPaintEvent *); + +Q_SIGNALS: + void closed(); + void btnClicked(const bool&, const bool&); + +}; + +#endif // CREATEINDEXASKDIALOG_H diff --git a/src/main.cpp b/src/main.cpp index eb76c89..d5eeca2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,7 +117,31 @@ void centerToScreen(QWidget* widget) { int y = widget->height(); widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); } - +/* +void searchMethod(FileUtils::SearchMethod sm){ + qWarning() << "searchMethod start: " << static_cast(sm); + if (FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == sm) { + FileUtils::searchMethod = sm; + } else { + printf("enum class error!!!\n"); + qWarning("enum class error!!!\n"); + } + if (FileUtils::SearchMethod::INDEXSEARCH == sm && 0 == FileUtils::_index_status) { + qWarning() << "start first index"; + FirstIndex fi("/home/zhangzihao/Desktop"); + fi.start(); + qWarning() << "start inotify index"; +// InotifyIndex ii("/home"); +// ii.start(); + InotifyIndex* ii = InotifyIndex::getInstance("/home"); + if (!ii->isRunning()) { + ii->start(); + } + qDebug()<<"Search method has been set to INDEXSEARCH"; + } + qWarning() << "searchMethod end: " << static_cast(FileUtils::searchMethod); +} +*/ int main(int argc, char *argv[]) { // Determine whether the home directory has been created, and if not, keep waiting. @@ -178,7 +202,7 @@ int main(int argc, char *argv[]) parser.addOptions({debugOption, showsearch}); parser.process(app); }*/ - +/* // Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running. QDir fifoDir = QDir(QDir::homePath()+"/.config/org.ukui/ukui-search"); if(!fifoDir.exists()) @@ -194,7 +218,7 @@ int main(int argc, char *argv[]) return -1; } qDebug()<<"create fifo success\n"; - +*/ // Set max_user_watches to a number which is enough big. UkuiSearchQDBus usQDBus; usQDBus.setInotifyMaxUserWatches(); @@ -249,6 +273,9 @@ int main(int argc, char *argv[]) // w->moveToPanel(); centerToScreen(w); + //请务必在connect之后初始化mainwindow的Gsettings,为了保证gsettings第一次读取到的配置值能成功应用 + w->initGsettings(); + //使用窗管的无边框策略 // w->setProperty("useStyleWindowManager", false); //禁用拖动 // MotifWmHints hints; @@ -278,13 +305,13 @@ int main(int argc, char *argv[]) // TODO // First insdex start, the parameter us useless, should remove the parameter - FirstIndex fi("/home/zhangzihao/Desktop"); - fi.start(); +// FirstIndex fi("/home/zhangzihao/Desktop"); +// fi.start(); // TODO // Inotify index start, the parameter us useless, should remove the parameter - InotifyIndex* ii = InotifyIndex::getInstance("/home"); - ii->start(); +// InotifyIndex* ii = InotifyIndex::getInstance("/home"); +// ii->start(); return app.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 227c691..66c65ab 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -65,6 +65,7 @@ MainWindow::MainWindow(QWidget *parent) : this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); this->setWindowTitle(tr("ukui-search")); initUi(); + initTimer(); // setProperty("useStyleWindowManager", false); //禁止拖动 m_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; @@ -80,11 +81,6 @@ MainWindow::MainWindow(QWidget *parent) : setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - const QByteArray id("org.ukui.control-center.personalise"); - if (QGSettings::isSchemaInstalled(id)) { - m_transparency_gsettings = new QGSettings(id); - } - connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) { this->setPalette(pal); this->update(); @@ -144,6 +140,10 @@ MainWindow::MainWindow(QWidget *parent) : } } }); + QObject::connect(this, &MainWindow::searchMethodChanged, this, [ = ](FileUtils::SearchMethod sm) { + this->m_searchMethodManager.searchMethod(sm); + }); + } MainWindow::~MainWindow() @@ -160,6 +160,18 @@ MainWindow::~MainWindow() delete m_settingsWidget; m_settingsWidget = NULL; } + if (m_askDialog) { + delete m_askDialog; + m_askDialog = NULL; + } + if (m_askTimer) { + delete m_askTimer; + m_askTimer = NULL; + } + if (m_search_gsettings) { + delete m_search_gsettings; + m_search_gsettings = NULL; + } } /** @@ -243,6 +255,7 @@ void MainWindow::initUi() } // m_seach_app_thread->stop(); m_contentFrame->setCurrentIndex(0); + m_askTimer->stop(); } else { m_contentFrame->setCurrentIndex(1); QTimer::singleShot(10,this,[=](){ @@ -253,13 +266,45 @@ void MainWindow::initUi() m_search_result_thread->start(); } searchContent(text); + //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索 + if (GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) + m_askTimer->start(); }); } + m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时 }); //初始化homepage // m_contentFrame->setQuicklyOpenList(list); //如需自定义快捷打开使用本函数 m_contentFrame->initHomePage(); + + //创建索引询问弹窗 + m_askDialog = new CreateIndexAskDialog(this); + MotifWmHints ask_dialog_hints; + ask_dialog_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; + ask_dialog_hints.functions = MWM_FUNC_ALL; + ask_dialog_hints.decorations = MWM_DECOR_BORDER; + XAtomHelper::getInstance()->setWindowMotifHint(m_askDialog->winId(), ask_dialog_hints); + connect(m_askDialog, &CreateIndexAskDialog::closed, this, [ = ]() { + m_isAskDialogVisible = false; + }); + connect(m_askDialog, &CreateIndexAskDialog::btnClicked, this, [ = ](const bool &create_index, const bool &no_longer_ask) { + if (no_longer_ask) { + GlobalSettings::getInstance()->setValue(ENABLE_CREATE_INDEX_ASK_DIALOG, "false"); + } else { + GlobalSettings::getInstance()->setValue(ENABLE_CREATE_INDEX_ASK_DIALOG, "true"); + } + if (create_index) { + if (m_search_gsettings && m_search_gsettings->keys().contains(SEARCH_METHOD_KEY)) { + m_search_gsettings->set(SEARCH_METHOD_KEY, true); + } else { + //调用创建索引接口 + Q_EMIT this->searchMethodChanged(FileUtils::SearchMethod::INDEXSEARCH); + //创建索引十秒后重新搜索一次(如果用户十秒内没有退出搜索界面且没有重新搜索) + m_researchTimer->start(); + } + } + }); } /** @@ -289,6 +334,13 @@ void MainWindow::clearSearchResult() { m_searchLayout->focusOut(); } +/** + * @brief MainWindow::createIndexSlot 允许创建索引的槽函数 + */ +void MainWindow::createIndexSlot() +{ +} + /** * @brief loadMainWindow 加载主界面的函数 * 不删除的原因是在单例和main函数里面需要用 @@ -414,12 +466,69 @@ void MainWindow::centerToScreen(QWidget* widget) { widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); } +void MainWindow::initGsettings() +{ + const QByteArray id(UKUI_SEARCH_SCHEMAS); + if (QGSettings::isSchemaInstalled(id)) { + m_search_gsettings = new QGSettings(id); + connect(m_search_gsettings, &QGSettings::changed, this, [ = ](const QString &key) { + if (key == SEARCH_METHOD_KEY) { + bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool(); + this->setSearchMethod(is_index_search); + } + }); + if (m_search_gsettings->keys().contains(SEARCH_METHOD_KEY)) { + bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool(); + this->setSearchMethod(is_index_search); + } + } +} + //使用GSetting获取当前窗口应该使用的透明度 double MainWindow::getTransparentData() { return GlobalSettings::getInstance()->getValue(TRANSPARENCY_KEY).toDouble(); } +void MainWindow::initTimer() +{ + m_askTimer = new QTimer; + m_askTimer->setInterval(5 * 1000); + connect(m_askTimer, &QTimer::timeout, this, [ = ]() { + if (this->isVisible()) { + m_isAskDialogVisible = true; + m_askDialog->show(); + m_currentSearchAsked = true; + } + m_askTimer->stop(); + }); + m_researchTimer = new QTimer; + m_researchTimer->setInterval(10 * 1000); + connect(m_researchTimer, &QTimer::timeout, this, [ = ]() { + if (this->isVisible()) { + searchContent(m_searchLayout->text()); + } + m_researchTimer->stop(); + }); +} + +/** + * @brief MainWindow::setSearchMethod 设置搜索模式 + * @param is_index_search true为索引搜索,false为暴力搜索 + */ +void MainWindow::setSearchMethod(const bool &is_index_search) +{ + if (is_index_search) { + //调用创建索引接口 + Q_EMIT this->searchMethodChanged(FileUtils::SearchMethod::INDEXSEARCH); + //创建索引十秒后重新搜索一次(如果用户十秒内没有退出搜索界面且没有重新搜索) + m_researchTimer->start(); + } else { + Q_EMIT this->searchMethodChanged(FileUtils::SearchMethod::DIRECTSEARCH); + m_researchTimer->stop(); + } +} + /** * @brief MainWindow::nativeEvent 处理窗口失焦事件 * @param eventType @@ -438,10 +547,15 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r switch (event->response_type & ~0x80) { case XCB_FOCUS_OUT: - this->hide(); - m_contentFrame->closeWebView(); - m_search_result_thread->requestInterruption(); - m_search_result_thread->quit(); + if (!m_isAskDialogVisible) { + m_currentSearchAsked = false; + this->hide(); + m_askTimer->stop(); + m_researchTimer->stop(); + m_contentFrame->closeWebView(); + m_search_result_thread->requestInterruption(); + m_search_result_thread->quit(); + } // m_seach_app_thread->stop(); break; default: diff --git a/src/mainwindow.h b/src/mainwindow.h index be2a3fe..fea8092 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,6 +43,7 @@ #include #include #include +#include #include "content-widget.h" #include "input-box.h" @@ -51,6 +52,11 @@ #include "libsearch.h" #include "search-app-thread.h" #include "xatom-helper.h" +#include "create-index-ask-dialog.h" + + +#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" +#define SEARCH_METHOD_KEY "indexSearch" class SearchResult; class MainWindow : public QMainWindow @@ -73,6 +79,7 @@ public: // The position which mainwindow shows in the center of screen where the cursor in. void centerToScreen(QWidget* widget); + void initGsettings(); MotifWmHints m_hints; @@ -92,8 +99,7 @@ private: SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout SeachBarWidget * m_searchWidget = nullptr; // Search bar - QGSettings * m_transparency_gsettings = nullptr; - double getTransparentData(); + QStringList m_dirList; @@ -105,13 +111,29 @@ private: SearchManager* m_searcher = nullptr; SettingsMatch *m_settingsMatch = nullptr; - QSystemTrayIcon *m_sys_tray_icon; + QSystemTrayIcon *m_sys_tray_icon = nullptr; + CreateIndexAskDialog * m_askDialog = nullptr; + bool m_isAskDialogVisible = false; + + QTimer * m_askTimer = nullptr; //询问是否创建索引弹窗弹出的计时器 + QTimer * m_researchTimer = nullptr; //创建索引后重新执行一次搜索的计时器 + bool m_currentSearchAsked = false; //本次搜索是否已经询问过是否创建索引了 + QGSettings * m_search_gsettings = nullptr; + + SearchMethodManager m_searchMethodManager; + + void setSearchMethod(const bool&); + double getTransparentData(); + void initTimer(); protected: void paintEvent(QPaintEvent *); void keyPressEvent(QKeyEvent *event); void initUi(); +Q_SIGNALS: + void searchMethodChanged(FileUtils::SearchMethod); + public Q_SLOTS: /** * @brief Monitor screen resolution @@ -126,6 +148,7 @@ public Q_SLOTS: void bootOptionsFilter(QString opt); // 过滤终端命令 void clearSearchResult(); //清空搜索结果 + void createIndexSlot(); }; #endif // MAINWINDOW_H diff --git a/src/src.pro b/src/src.pro index 35eff8a..a6574be 100644 --- a/src/src.pro +++ b/src/src.pro @@ -26,6 +26,7 @@ include(singleapplication/qt-single-application.pri) SOURCES += \ content-widget.cpp \ + create-index-ask-dialog.cpp \ custom-style.cpp \ input-box.cpp \ main.cpp \ @@ -38,6 +39,7 @@ SOURCES += \ HEADERS += \ content-widget.h \ + create-index-ask-dialog.h \ custom-style.h \ input-box.h \ mainwindow.h \ @@ -55,7 +57,9 @@ data-menu.path = /usr/share/applications data-menu.files += ../data/ukui-search-menu.desktop data.path = /etc/xdg/autostart data.files += ../data/ukui-search.desktop -INSTALLS += data data-menu +schemes.path = /usr/share/glib-2.0/schemas/ +schemes.files += ../data/org.ukui.search.data.gschema.xml +INSTALLS += data data-menu schemes RESOURCES += \ resource.qrc @@ -84,3 +88,6 @@ DEPENDPATH += $$PWD/../libsearch # $$OUT_PWD/.qm/bo.qm \ # $$OUT_PWD/.qm/tr.qm \ # $$OUT_PWD/.qm/zh_CN.qm + +DISTFILES += \ + ../data/org.ukui.search.data.gschema.xml diff --git a/translations/ukui-search/bo.ts b/translations/ukui-search/bo.ts index 9e5b6d5..82ef300 100644 --- a/translations/ukui-search/bo.ts +++ b/translations/ukui-search/bo.ts @@ -4,61 +4,94 @@ ContentWidget - + Recently Opened - + Open Quickly - + Commonly Used - + Apps - + Settings - + Files - + Dirs - + File Contents - + Best Matches - + Web Pages - + Unknown + + CreateIndexAskDialog + + + ukui-search + + + + + Search + + + + + Creating index can help you getting results quickly, whether to create or not? + + + + + Don't remind + + + + + No + + + + + Yes + + + FolderListItem @@ -70,17 +103,17 @@ MainWindow - + ukui-search - + Global Search - + Search @@ -121,7 +154,7 @@ QObject - + ukui-search is already running! @@ -129,7 +162,7 @@ SearchBarHLayout - + Search @@ -137,32 +170,32 @@ SearchDetailView - + Path - + Last time modified - + Application - + Introduction: %1 - + Document - + Preview is not avaliable @@ -170,55 +203,55 @@ SettingsWidget - - - + + + Search - - + + ... - + Following folders will not be searched. You can set it by adding and removing folders. - + Add ignored folders - + Please select search engine you preferred. - + baidu - + sougou - + 360 - + Cancel - + Creating ... @@ -228,102 +261,102 @@ - + <h2>Settings</h2> - + <h3>Index State</h3> - + <h3>File Index Settings</h3> - + <h3>Search Engine Settings</h3> - + Whether to delete this directory? - + Yes - + No - + Done - + Index Entry: %1 - + Directories - + select blocked folder - + Select - + Position: - + FileName: - + FileType: - + Choosen path is Empty! - + Choosen path is not in "home"! - + Its' parent folder has been blocked! - + Set blocked folder failed! - + OK diff --git a/translations/ukui-search/tr.ts b/translations/ukui-search/tr.ts index 6f1933a..830579f 100644 --- a/translations/ukui-search/tr.ts +++ b/translations/ukui-search/tr.ts @@ -4,61 +4,94 @@ ContentWidget - + Recently Opened Yeni Açılan - + Open Quickly Hızlı Aç - + Commonly Used Genel olarak kullanılan - + Apps Uygulamalar - + Settings Ayarlar - + Files Dosyalar - + Dirs Dizinler - + File Contents Dosya İçeriği - + Best Matches En İyi Eşleşen - + Web Pages - + Unknown Bilinmeyen + + CreateIndexAskDialog + + + ukui-search + + + + + Search + Ara + + + + Creating index can help you getting results quickly, whether to create or not? + + + + + Don't remind + + + + + No + + + + + Yes + + + FolderListItem @@ -70,17 +103,17 @@ MainWindow - + ukui-search ukui-ara - + Global Search Genel Arama - + Search Ara @@ -121,7 +154,7 @@ QObject - + ukui-search is already running! ukui-bul zaten çalışıyor! @@ -129,7 +162,7 @@ SearchBarHLayout - + Search Ara @@ -137,32 +170,32 @@ SearchDetailView - + Path Yol - + Last time modified Son değiştirilme zamanı - + Application Uygulama - + Introduction: %1 - + Document Belge - + Preview is not avaliable @@ -170,55 +203,55 @@ SettingsWidget - - - + + + Search Ara - - + + ... ... - + Following folders will not be searched. You can set it by adding and removing folders. Aşağıdaki klasörler aranmayacaktır. Klasör ekleyip kaldırarak ayarlayabilirsiniz. - + Add ignored folders Göz ardı edilen klasörleri ekleyin - + Please select search engine you preferred. Lütfen tercih ettiğiniz arama motorunu seçin. - + baidu - + sougou - + 360 - + Cancel İptal - + Creating ... Oluşturuluyor... @@ -232,102 +265,102 @@ - + <h2>Settings</h2> <h2>Ayarlar</h2> - + <h3>Index State</h3> <h3>Dizin Durumu</h3> - + <h3>File Index Settings</h3> <h3>Dosya Dizini Ayarları</h3> - + <h3>Search Engine Settings</h3> <h3>SArama Motoru Ayarları</h3> - + Whether to delete this directory? Bu dizini silinsin mi? - + Yes - + No - + Done Tamam - + Index Entry: %1 Dizin Girişi: %1 - + Directories Dizinler - + select blocked folder engellenen klasörü seç - + Select Seç - + Position: Pozisyon: - + FileName: Dosya Adı: - + FileType: Dosya Türü: - + Choosen path is Empty! - + Choosen path is not in "home"! - + Its' parent folder has been blocked! - + Set blocked folder failed! - + OK diff --git a/translations/ukui-search/zh_CN.ts b/translations/ukui-search/zh_CN.ts index 983c03b..cd6710b 100644 --- a/translations/ukui-search/zh_CN.ts +++ b/translations/ukui-search/zh_CN.ts @@ -4,61 +4,94 @@ ContentWidget - + Recently Opened 最近 - + Open Quickly 快速入口 - + Commonly Used 常用 - + Apps 应用 - + Settings 配置项 - + Files 文件 - + Dirs 文件夹 - + File Contents 文件内容 - + Best Matches 最佳匹配 - + Web Pages 网页 - + Unknown 未知 + + CreateIndexAskDialog + + + ukui-search + 搜索 + + + + Search + 搜索 + + + + Creating index can help you getting results quickly, whether to create or not? + 创建索引可以快速获取搜索结果,是否创建? + + + + Don't remind + 不再提醒 + + + + No + 否(N) + + + + Yes + 是(Y) + + FolderListItem @@ -70,17 +103,17 @@ MainWindow - + ukui-search 搜索 - + Global Search 搜索 - + Search 搜索 @@ -121,7 +154,7 @@ QObject - + ukui-search is already running! @@ -129,7 +162,7 @@ SearchBarHLayout - + Search 搜索 @@ -137,32 +170,32 @@ SearchDetailView - + Path 路径 - + Last time modified 上次修改时间 - + Application 应用 - + Introduction: %1 软件介绍: %1 - + Document 文件 - + Preview is not avaliable 当前预览不可用 @@ -175,115 +208,115 @@ 搜索 - - - + + + Search 搜索 - + <h2>Settings</h2> <h2>设置</h2> - + <h3>Index State</h3> <h3>索引状态</h3> - - + + ... - + <h3>File Index Settings</h3> <h3>文件索引设置</h3> - + Following folders will not be searched. You can set it by adding and removing folders. 搜索将不再查看以下文件夹。通过增加和删除文件夹可进行文件索引设置。 - + Add ignored folders 添加文件夹至黑名单 - + <h3>Search Engine Settings</h3> <h3>搜索引擎设置</h3> - + Please select search engine you preferred. 设置互联网搜索引擎 - + baidu 百度 - + sougou 搜狗 - + 360 360 - + Whether to delete this directory? 是否要删除此目录 - + Yes 是(Y) - + No 否(N) - + Cancel 取消 - + Choosen path is Empty! 选择的路径不存在! - + Choosen path is not in "home"! 请选择家目录下的文件夹! - + Its' parent folder has been blocked! 父文件夹已被屏蔽! - + Set blocked folder failed! - + OK 好的 - + Creating ... 正在索引 @@ -292,42 +325,42 @@ 搜索 - + Done 索引完成 - + Index Entry: %1 索引项: %1 - + Directories 文件夹 - + select blocked folder 选择屏蔽文件夹 - + Select 选择 - + Position: 位置: - + FileName: 名称: - + FileType: 类型: