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/global-settings.cpp b/libsearch/global-settings.cpp index a70199d..318f3e3 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -77,8 +77,18 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent) if (key == STYLE_NAME_KEY) { //当前主题改变时也发出paletteChanged信号,通知主界面刷新 qApp->paletteChanged(qApp->palette()); + m_cache.remove(STYLE_NAME_KEY); + m_cache.insert(STYLE_NAME_KEY, m_theme_gsettings->get(STYLE_NAME_KEY).toString()); + } else if (key == FONT_SIZE_KEY) { + qApp->paletteChanged(qApp->palette()); + m_cache.remove(FONT_SIZE_KEY); + m_cache.insert(FONT_SIZE_KEY, m_theme_gsettings->get(FONT_SIZE_KEY).toDouble()); } }); + m_cache.remove(STYLE_NAME_KEY); + m_cache.insert(STYLE_NAME_KEY, m_theme_gsettings->get(STYLE_NAME_KEY).toString()); + m_cache.remove(FONT_SIZE_KEY); + m_cache.insert(FONT_SIZE_KEY, m_theme_gsettings->get(FONT_SIZE_KEY).toDouble()); } } @@ -258,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()) @@ -69,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]; @@ -205,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) @@ -220,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 a7af436..5a19edb 100644 --- a/libsearch/index/first-index.h +++ b/libsearch/index/first-index.h @@ -45,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 2f44bc6..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,7 +285,7 @@ void InotifyIndex::run(){ ssize_t numRead; - while (!isInterruptionRequested()) { + while (FileUtils::SearchMethod::INDEXSEARCH == FileUtils::searchMethod) { // for (;;) { /* Read events forever */ memset(buf, 0x00, BUF_LEN); numRead = read(m_fd, buf, BUF_LEN); @@ -323,7 +352,7 @@ void InotifyIndex::run(){ 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 @@ void InotifyIndex::run(){ else if (pid > 0){ memset(buf, 0x00, BUF_LEN); waitpid(pid, NULL, 0); - --FileUtils::_index_status; } else{ @@ -351,4 +379,11 @@ void InotifyIndex::run(){ } } + 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 c3651c3..ca16f93 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -446,7 +446,7 @@ void DirectSearch::run() } if (i.fileName().contains(m_keyword)) { SearchManager::m_mutex1.lock(); - qWarning() << i.fileName() << m_keyword; +// qWarning() << i.fileName() << m_keyword; if (m_uniqueSymbol == SearchManager::uniqueSymbol1) { // TODO if (i.isDir() && m_searchResultDir->length() < 51) { diff --git a/libsearch/index/searchmethodmanager.cpp b/libsearch/index/searchmethodmanager.cpp new file mode 100644 index 0000000..8e35d43 --- /dev/null +++ b/libsearch/index/searchmethodmanager.cpp @@ -0,0 +1,26 @@ +#include "searchmethodmanager.h" + +void SearchMethodManager::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"; +// 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/control/highlight-item-delegate.cpp b/src/control/highlight-item-delegate.cpp index 9aae3d8..334a8bc 100644 --- a/src/control/highlight-item-delegate.cpp +++ b/src/control/highlight-item-delegate.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "global-settings.h" HighlightItemDelegate::HighlightItemDelegate(QObject *parent) : QStyledItemDelegate (parent) { @@ -83,8 +84,11 @@ QString HighlightItemDelegate::getHtmlText(QPainter *painter, const QStyleOption { int indexFindLeft = 0; QString indexString = index.model()->data(index,Qt::DisplayRole).toString(); - QFontMetrics m_QFontMetrics = painter->fontMetrics(); - QString indexColString = m_QFontMetrics.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号 + QFont ft(painter->font().family(), GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toInt()); + QFontMetrics fm(ft); + QString indexColString = fm.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号 +// QFontMetrics m_QFontMetrics = painter->fontMetrics(); +// QString indexColString = m_QFontMetrics.elidedText(indexString, Qt::ElideRight, itemOption.rect.width() + 10); //当字体超过Item的长度时显示为省略号 QString htmlString; if ((indexColString.toUpper()).contains((m_regFindKeyWords.toUpper()))) { indexFindLeft = indexColString.toUpper().indexOf(m_regFindKeyWords.toUpper()); //得到查找字体在当前整个Item字体中的位置 diff --git a/src/control/home-page-item.cpp b/src/control/home-page-item.cpp index 7ee8c35..d98bbc2 100644 --- a/src/control/home-page-item.cpp +++ b/src/control/home-page-item.cpp @@ -35,7 +35,11 @@ HomePageItem::HomePageItem(QWidget *parent, const int& type, const QString& path connect(qApp, &QApplication::paletteChanged, this, [ = ]() { if (m_namelabel) { QString name = this->toolTip(); - m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 108)); + if (m_type == ItemType::Recent) { + m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 250)); + } else { + m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 108)); + } } }); } @@ -51,6 +55,7 @@ HomePageItem::~HomePageItem() */ void HomePageItem::setupUi(const int& type, const QString& path) { m_path = path; + m_type = type; m_widget = new QWidget(this); m_widget->setObjectName("MainWidget"); // m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.05); border-radius: 4px;}"); diff --git a/src/control/home-page-item.h b/src/control/home-page-item.h index 1c8fa61..58acdac 100644 --- a/src/control/home-page-item.h +++ b/src/control/home-page-item.h @@ -56,6 +56,7 @@ private: QLabel * m_namelabel = nullptr; double m_transparency = 0; QString m_path; + int m_type = 0; }; #endif // HOMEPAGEITEM_H diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 5fcca26..a4ddca6 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -21,9 +21,13 @@ #include "search-list-view.h" #include #include +#include "custom-style.h" SearchListView::SearchListView(QWidget * parent, const QStringList& list, const int& type) : QTreeView(parent) { + CustomStyle * style = new CustomStyle(GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString()); + this->setStyle(style); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::SingleSelection); 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/custom-style.cpp b/src/custom-style.cpp new file mode 100644 index 0000000..2e82aa8 --- /dev/null +++ b/src/custom-style.cpp @@ -0,0 +1,18 @@ +#include "custom-style.h" + +CustomStyle::CustomStyle(const QString &proxyStyleName, QObject *parent) : QProxyStyle(proxyStyleName) +{ + +} + +QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const +{ + switch (type) { + case CT_ItemViewItem: { + QSize size(0, GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toDouble() * 2); + return size; + } break; + default: break; + } + return QProxyStyle::sizeFromContents(type, option, contentsSize, widget); +} diff --git a/src/custom-style.h b/src/custom-style.h new file mode 100644 index 0000000..c220bc5 --- /dev/null +++ b/src/custom-style.h @@ -0,0 +1,14 @@ +#ifndef CUSTOMSTYLE_H +#define CUSTOMSTYLE_H +#include +#include "global-settings.h" + +class CustomStyle : public QProxyStyle +{ + Q_OBJECT +public: + explicit CustomStyle(const QString &proxyStyleName = "windows",QObject *parent = nullptr); + virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const; +}; + +#endif // CUSTOMSTYLE_H diff --git a/src/main.cpp b/src/main.cpp index 4aaa3a2..d5eeca2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,24 +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){ - if (FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == 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) { + 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"); - ii->start(); - } else if (FileUtils::SearchMethod::DIRECTSEARCH == sm) { - InotifyIndex::getInstance("/home")->requestInterruption(); + 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. @@ -163,7 +170,7 @@ int main(int argc, char *argv[]) } // Output log to file -// qInstallMessageHandler(messageOutput); + qInstallMessageHandler(messageOutput); // Register meta type qDebug() << "ukui-search main start"; @@ -266,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; 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 8a4b878..a6574be 100644 --- a/src/src.pro +++ b/src/src.pro @@ -26,6 +26,8 @@ include(singleapplication/qt-single-application.pri) SOURCES += \ content-widget.cpp \ + create-index-ask-dialog.cpp \ + custom-style.cpp \ input-box.cpp \ main.cpp \ mainwindow.cpp \ @@ -37,6 +39,8 @@ SOURCES += \ HEADERS += \ content-widget.h \ + create-index-ask-dialog.h \ + custom-style.h \ input-box.h \ mainwindow.h \ search-app-thread.h \ @@ -53,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 @@ -82,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: 类型: