diff --git a/libsearch/appsearch/appsearch.pri b/libsearch/appsearch/appsearch.pri index aba082d..4a3d55d 100644 --- a/libsearch/appsearch/appsearch.pri +++ b/libsearch/appsearch/appsearch.pri @@ -1 +1,7 @@ INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/app-match.h \ + +SOURCES += \ + $$PWD/app-match.cpp \ diff --git a/src/control/control.pri b/src/control/control.pri index a45e52e..11120f7 100644 --- a/src/control/control.pri +++ b/src/control/control.pri @@ -2,7 +2,7 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/config-file.h \ - $$PWD/floder-list-item.h \ + $$PWD/folder-list-item.h \ $$PWD/search-list-view.h \ $$PWD/search-detail-view.h \ $$PWD/option-view.h \ @@ -10,7 +10,7 @@ HEADERS += \ SOURCES += \ $$PWD/config-file.cpp \ - $$PWD/floder-list-item.cpp \ + $$PWD/folder-list-item.cpp \ $$PWD/search-list-view.cpp \ $$PWD/search-detail-view.cpp \ $$PWD/option-view.cpp \ diff --git a/src/control/floder-list-item.cpp b/src/control/folder-list-item.cpp similarity index 69% rename from src/control/floder-list-item.cpp rename to src/control/folder-list-item.cpp index dcffcae..66171a8 100644 --- a/src/control/floder-list-item.cpp +++ b/src/control/folder-list-item.cpp @@ -1,22 +1,22 @@ -#include "floder-list-item.h" +#include "folder-list-item.h" #include #include -FloderListItem::FloderListItem(QWidget *parent, const QString &path) : QWidget(parent) +FolderListItem::FolderListItem(QWidget *parent, const QString &path) : QWidget(parent) { m_path = path; initUi(); } -FloderListItem::~FloderListItem() +FolderListItem::~FolderListItem() { } /** - * @brief FloderListItem::initUi 构建ui + * @brief FolderListItem::initUi 构建ui */ -void FloderListItem::initUi() { +void FolderListItem::initUi() { m_layout = new QVBoxLayout(this); m_layout->setSpacing(0); m_layout->setContentsMargins(0,0,0,0); @@ -33,7 +33,7 @@ void FloderListItem::initUi() { m_delLabel = new QLabel(m_widget); m_iconLabel->setPixmap(QIcon::fromTheme("inode-directory").pixmap(QSize(16, 16))); m_pathLabel->setText(m_path); - m_delLabel->setText(tr("Delete the floder out of blacklist")); + m_delLabel->setText(tr("Delete the folder out of blacklist")); m_pathLabel->setStyleSheet("QLabel{color: palette(text); background: transparent;}"); m_delLabel->setStyleSheet("QLabel{color: #3790FA; background: transparent;}"); m_delLabel->setCursor(QCursor(Qt::PointingHandCursor)); @@ -46,20 +46,28 @@ void FloderListItem::initUi() { } /** - * @brief FloderListItem::enterEvent 鼠标移入事件 + * @brief FolderListItem::getPath 获取当前文件夹路径 + * @return + */ +QString FolderListItem::getPath() { + return m_path; +} + +/** + * @brief FolderListItem::enterEvent 鼠标移入事件 * @param event */ -void FloderListItem::enterEvent(QEvent *event){ +void FolderListItem::enterEvent(QEvent *event){ m_delLabel->show(); m_widget->setStyleSheet("QWidget#mWidget{background: rgba(0,0,0,0.1);}"); QWidget::enterEvent(event); } /** - * @brief FloderListItem::leaveEvent 鼠标移出事件 + * @brief FolderListItem::leaveEvent 鼠标移出事件 * @param event */ -void FloderListItem::leaveEvent(QEvent *event){ +void FolderListItem::leaveEvent(QEvent *event){ m_delLabel->hide(); m_widget->setStyleSheet("QWidget#mWidget{background: transparent;}"); QWidget::leaveEvent(event); @@ -67,15 +75,16 @@ void FloderListItem::leaveEvent(QEvent *event){ /** - * @brief FloderListItem::eventFilter 处理删除按钮点击事件 + * @brief FolderListItem::eventFilter 处理删除按钮点击事件 * @param watched * @param event * @return */ -bool FloderListItem::eventFilter(QObject *watched, QEvent *event){ +bool FolderListItem::eventFilter(QObject *watched, QEvent *event){ if (watched == m_delLabel) { if (event->type() == QEvent::MouseButtonPress) { // qDebug()<<"pressed!"; + Q_EMIT this->onDelBtnClicked(m_path); } } return QObject::eventFilter(watched, event); diff --git a/src/control/floder-list-item.h b/src/control/folder-list-item.h similarity index 57% rename from src/control/floder-list-item.h rename to src/control/folder-list-item.h index 6bc7c7a..fa767b2 100644 --- a/src/control/floder-list-item.h +++ b/src/control/folder-list-item.h @@ -1,21 +1,22 @@ -#ifndef FLODERLISTITEM_H -#define FLODERLISTITEM_H +#ifndef FOLDERLISTITEM_H +#define FOLDERLISTITEM_H #include #include #include #include -class FloderListItem : public QWidget +class FolderListItem : public QWidget { Q_OBJECT public: - explicit FloderListItem(QWidget *parent = nullptr, const QString &path = 0); - ~FloderListItem(); + explicit FolderListItem(QWidget *parent = nullptr, const QString &path = 0); + ~FolderListItem(); + QString getPath(); protected: - virtual void enterEvent(QEvent * event); - virtual void leaveEvent(QEvent * event); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); bool eventFilter(QObject *, QEvent *); private: @@ -30,6 +31,7 @@ private: QLabel * m_pathLabel = nullptr; QLabel * m_delLabel = nullptr; Q_SIGNALS: + void onDelBtnClicked(const QString&); }; -#endif // FLODERLISTITEM_H +#endif // FOLDERLISTITEM_H diff --git a/src/res/translations/bo.ts b/src/res/translations/bo.ts index c870a50..ab9cae4 100644 --- a/src/res/translations/bo.ts +++ b/src/res/translations/bo.ts @@ -4,63 +4,63 @@ ContentWidget - + Recently Opened - + Open Quickly - + Commonly Used - + Apps - + Settings - + Files - + Dirs - + Best Matches - + Unknown - FloderListItem + FolderListItem - - Delete the floder out of blacklist + + Delete the folder out of blacklist MainWindow - + Search @@ -96,7 +96,7 @@ QObject - + ukui-search is already running! @@ -127,88 +127,88 @@ SettingsWidget - + Search - + Settings - + Index State - - + + ... - + File Index Settings - + Following folders will not be searched. You can set it by adding and removing folders. - + Add ignored folders - + Search Engine Settings - + Please select search engine you preferred. - + baidu - + sougou - + 360 - + Cancel - + Confirm - + Creating ... - + Done - + Index Entry: %1 diff --git a/src/res/translations/tr.ts b/src/res/translations/tr.ts index c870a50..ab9cae4 100644 --- a/src/res/translations/tr.ts +++ b/src/res/translations/tr.ts @@ -4,63 +4,63 @@ ContentWidget - + Recently Opened - + Open Quickly - + Commonly Used - + Apps - + Settings - + Files - + Dirs - + Best Matches - + Unknown - FloderListItem + FolderListItem - - Delete the floder out of blacklist + + Delete the folder out of blacklist MainWindow - + Search @@ -96,7 +96,7 @@ QObject - + ukui-search is already running! @@ -127,88 +127,88 @@ SettingsWidget - + Search - + Settings - + Index State - - + + ... - + File Index Settings - + Following folders will not be searched. You can set it by adding and removing folders. - + Add ignored folders - + Search Engine Settings - + Please select search engine you preferred. - + baidu - + sougou - + 360 - + Cancel - + Confirm - + Creating ... - + Done - + Index Entry: %1 diff --git a/src/res/translations/zh_CN.ts b/src/res/translations/zh_CN.ts index 55bcd98..20ad8ee 100644 --- a/src/res/translations/zh_CN.ts +++ b/src/res/translations/zh_CN.ts @@ -4,63 +4,63 @@ ContentWidget - + Recently Opened 最近 - + Open Quickly 快速 - + Commonly Used 常用 - + Apps 应用 - + Settings 配置项 - + Files 文件 - + Dirs 文件夹 - + Best Matches 最佳匹配 - + Unknown 未知 - FloderListItem + FolderListItem - - Delete the floder out of blacklist + + Delete the folder out of blacklist 删除 MainWindow - + Search 从列表搜索 @@ -96,7 +96,7 @@ QObject - + ukui-search is already running! @@ -127,88 +127,88 @@ SettingsWidget - + Search 搜索 - + Settings 配置项 - + Index State 索引状态 - - + + ... - + File Index Settings 文件索引设置 - + Following folders will not be searched. You can set it by adding and removing folders. 搜索将不再查看以下文件夹。通过增加和删除文件夹可进行文件索引设置。 - + Add ignored folders 添加禁止索引文件夹 - + Search Engine Settings 搜索引擎设置 - + Please select search engine you preferred. 设置互联网搜索引擎 - + baidu 百度 - + sougou 搜狗 - + 360 360 - + Cancel 取消 - + Confirm 确认 - + Creating ... 正在索引 - + Done 索引完成 - + Index Entry: %1 索引项: %1 diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp index 8738975..bf50906 100644 --- a/src/settings-widget.cpp +++ b/src/settings-widget.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "floder-list-item.h" +#include "folder-list-item.h" extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent) @@ -178,13 +178,30 @@ void SettingsWidget::initUi() { */ void SettingsWidget::setupBlackList(const QStringList& list) { Q_FOREACH(QString path, list) { - FloderListItem * item = new FloderListItem(m_dirListWidget, path); + FolderListItem * item = new FolderListItem(m_dirListWidget, path); m_dirListLyt->addWidget(item); item->setMaximumWidth(470); + //测试用,实际调用中应等待后端完成操作后删除该控件 + connect(item, SIGNAL(onDelBtnClicked(const QString&)), this, SLOT(onBtnDelClicked(const QString&))); } m_dirListLyt->addStretch(); } +/** + * @brief SettingsWidget::onBtnDelClicked 删除黑名单中的目录 + * @param path 文件夹路径 + */ +void SettingsWidget::onBtnDelClicked(const QString& path) { + qDebug()<findChildren()) { + if (item->getPath() == path) { + item->deleteLater(); + item = NULL; + return; + } + } +} + /** * @brief setIndexState 设置当前索引状态 * @param isCreatingIndex 是否正在创建索引 diff --git a/src/settings-widget.h b/src/settings-widget.h index 21a7a2f..2618da7 100644 --- a/src/settings-widget.h +++ b/src/settings-widget.h @@ -73,6 +73,7 @@ private Q_SLOTS: void onBtnConfirmClicked(); void onBtnCancelClicked(); void onBtnAddClicked(); + void onBtnDelClicked(const QString&); }; #endif // SETTINGSWIDGET_H