2021-10-28 20:46:39 +08:00
|
|
|
#ifndef SEARCH_H
|
|
|
|
#define SEARCH_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QGSettings>
|
2022-12-07 14:04:21 +08:00
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusReply>
|
2021-10-28 20:46:39 +08:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QPushButton>
|
2022-12-07 14:04:21 +08:00
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QButtonGroup>
|
2021-10-28 20:46:39 +08:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
2022-07-06 14:22:59 +08:00
|
|
|
#include <kswitchbutton.h>
|
|
|
|
|
2021-10-28 20:46:39 +08:00
|
|
|
#include <ukcc/interface/interface.h>
|
|
|
|
#include <ukcc/widgets/comboboxitem.h>
|
|
|
|
#include <ukcc/widgets/switchbutton.h>
|
|
|
|
#include <ukcc/widgets/hoverwidget.h>
|
|
|
|
#include <ukcc/widgets/switchbutton.h>
|
|
|
|
#include <ukcc/widgets/comboxframe.h>
|
|
|
|
#include <ukcc/widgets/titlelabel.h>
|
2022-08-17 10:04:24 +08:00
|
|
|
#include <ukcc/widgets/addbtn.h>
|
2021-10-28 20:46:39 +08:00
|
|
|
|
|
|
|
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
2022-04-14 11:16:26 +08:00
|
|
|
#define SEARCH_METHOD_KEY "fileIndexEnable"
|
2021-10-28 20:46:39 +08:00
|
|
|
#define WEB_ENGINE_KEY "webEngine"
|
2022-12-07 14:04:21 +08:00
|
|
|
#define CONTENT_SEARCH_KEY "contentFuzzySearch"
|
2021-10-28 20:46:39 +08:00
|
|
|
//TODO
|
|
|
|
#define CONFIG_FILE "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf"
|
|
|
|
|
|
|
|
enum ReturnCode {
|
|
|
|
Succeed,
|
|
|
|
PathEmpty,
|
|
|
|
NotInHomeDir,
|
|
|
|
ParentExist,
|
|
|
|
HasBeenBlocked
|
|
|
|
};
|
|
|
|
|
|
|
|
class Search : public QObject, CommonInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
|
|
|
|
Q_INTERFACES(CommonInterface)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Search();
|
2022-01-28 09:33:50 +08:00
|
|
|
virtual ~Search() = default;
|
2021-10-28 20:46:39 +08:00
|
|
|
|
|
|
|
QString plugini18nName() Q_DECL_OVERRIDE;
|
|
|
|
int pluginTypes() Q_DECL_OVERRIDE;
|
|
|
|
QWidget * pluginUi() Q_DECL_OVERRIDE;
|
|
|
|
const QString name() const Q_DECL_OVERRIDE;
|
|
|
|
QString translationPath() const;
|
|
|
|
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
|
|
|
|
QIcon icon() const Q_DECL_OVERRIDE;
|
|
|
|
bool isEnable() const Q_DECL_OVERRIDE;
|
|
|
|
|
2022-12-27 09:41:32 +08:00
|
|
|
public Q_SLOTS:
|
|
|
|
void refreshSearchDirsUi();
|
|
|
|
|
2021-10-28 20:46:39 +08:00
|
|
|
private:
|
|
|
|
QWidget * m_pluginWidget = nullptr;
|
|
|
|
QString m_plugin_name = "";
|
|
|
|
int m_plugin_type = 0;
|
|
|
|
|
|
|
|
QGSettings * m_gsettings = nullptr;
|
|
|
|
|
|
|
|
void initUi();
|
|
|
|
QVBoxLayout * m_mainLyt = nullptr;
|
|
|
|
TitleLabel * m_titleLabel = nullptr;
|
|
|
|
|
2022-12-07 14:04:21 +08:00
|
|
|
//设置搜索引擎
|
|
|
|
// TitleLabel * m_webEngineLabel = nullptr;
|
|
|
|
ComboxFrame * m_webEngineFrame = nullptr;
|
|
|
|
QVBoxLayout * m_webEngineLyt = nullptr;
|
|
|
|
|
|
|
|
//索引详细设置
|
2021-10-28 20:46:39 +08:00
|
|
|
QFrame *m_setFrame = nullptr;
|
|
|
|
QVBoxLayout *m_setFrameLyt = nullptr;
|
2022-12-07 14:04:21 +08:00
|
|
|
//索引开关
|
2021-10-28 20:46:39 +08:00
|
|
|
QFrame *m_descFrame = nullptr;
|
|
|
|
QVBoxLayout *m_descFrameLyt = nullptr;
|
|
|
|
QLabel *m_descLabel1 = nullptr;
|
|
|
|
QLabel *m_descLabel2 = nullptr;
|
|
|
|
QFrame *m_searchMethodFrame = nullptr;
|
|
|
|
QHBoxLayout *m_searchMethodLyt = nullptr;
|
|
|
|
// QLabel *m_searchMethodLabel = nullptr;
|
2022-07-06 14:22:59 +08:00
|
|
|
kdk::KSwitchButton *m_searchMethodBtn = nullptr;
|
2022-12-07 14:04:21 +08:00
|
|
|
//设置索引搜索模式
|
|
|
|
QFrame *m_indexSetFrame = nullptr;
|
|
|
|
QVBoxLayout *m_indexSetLyt = nullptr;
|
|
|
|
//模糊搜索开关
|
|
|
|
QFrame *m_indexMethodFrame = nullptr;
|
|
|
|
QVBoxLayout *m_indexMethodLyt = nullptr;
|
|
|
|
QLabel *m_indexMethodDescLabel = nullptr;
|
|
|
|
//模糊搜索按钮
|
|
|
|
QButtonGroup *m_indexMethodBtnGroup = nullptr;
|
|
|
|
QFrame *m_fuzzyBtnFrame = nullptr;
|
|
|
|
QHBoxLayout *m_fuzzyBtnLyt = nullptr;
|
|
|
|
QRadioButton *m_fuzzyBtn = nullptr;
|
|
|
|
QLabel *m_fuzzyDescLabel = nullptr;
|
|
|
|
//精确搜索按钮
|
|
|
|
QFrame *m_preciseBtnFrame = nullptr;
|
|
|
|
QHBoxLayout *m_preciseBtnLyt = nullptr;
|
|
|
|
QRadioButton *m_preciseBtn = nullptr;
|
|
|
|
QLabel *m_preciseDescLabel = nullptr;
|
|
|
|
|
|
|
|
//设置当前搜索目录
|
|
|
|
TitleLabel *m_searchDirTitleLabel = nullptr;
|
|
|
|
QLabel *m_searchDirDescLabel = nullptr;
|
|
|
|
QFrame *m_searchDirsFrame = nullptr;
|
|
|
|
QVBoxLayout *m_searchDirLyt = nullptr;
|
|
|
|
QLabel *m_searchDirLabel = nullptr;
|
|
|
|
AddBtn *m_addSearchDirBtn = nullptr;
|
|
|
|
QFrame *m_addSearchDirFrame = nullptr;
|
2021-10-28 20:46:39 +08:00
|
|
|
|
|
|
|
//设置黑名单
|
|
|
|
TitleLabel * m_blockDirTitleLabel = nullptr;
|
|
|
|
QLabel * m_blockDirDescLabel = nullptr;
|
|
|
|
QFrame * m_blockDirsFrame = nullptr;
|
|
|
|
QVBoxLayout * m_blockDirsLyt = nullptr;
|
2022-08-17 10:04:24 +08:00
|
|
|
// QPushButton * m_addBlockDirWidget = nullptr;
|
|
|
|
AddBtn * m_addBlockDirWidget = nullptr;
|
2021-10-28 20:46:39 +08:00
|
|
|
QLabel * m_addBlockDirIcon = nullptr;
|
|
|
|
QLabel * m_addBlockDirLabel = nullptr;
|
|
|
|
QHBoxLayout * m_addBlockDirLyt = nullptr;
|
|
|
|
|
2022-12-07 14:04:21 +08:00
|
|
|
void initFileDialog();
|
|
|
|
QFileDialog *m_blockDirDialog = nullptr;
|
|
|
|
QFileDialog *m_searchDirDialog = nullptr;
|
|
|
|
|
2021-10-28 20:46:39 +08:00
|
|
|
QStringList m_blockDirs;
|
|
|
|
QSettings * m_dirSettings = nullptr;
|
|
|
|
void getBlockDirs();
|
|
|
|
int setBlockDir(const QString &dirPath, const bool &is_add = true);
|
|
|
|
void appendBlockDirToList(const QString &path);
|
|
|
|
void removeBlockDirFromList(const QString &path);
|
|
|
|
void initBlockDirsList();
|
|
|
|
// void refreshBlockDirsList();
|
|
|
|
|
2022-12-07 14:04:21 +08:00
|
|
|
QDBusInterface *m_interface = nullptr;
|
|
|
|
QDBusInterface *m_setSearchDirInterface = nullptr;
|
|
|
|
void initSearchDirs();
|
|
|
|
int setSearchDir(const QString &dirPath, const bool isAdd);
|
|
|
|
void appendSearchDirToList(const QString &path);
|
|
|
|
void removeSearchDirFromList(const QString &path);
|
2021-10-28 20:46:39 +08:00
|
|
|
|
|
|
|
void setupConnection();
|
|
|
|
|
|
|
|
private slots:
|
2022-12-07 14:04:21 +08:00
|
|
|
void onBtnAddBlockFolderClicked();
|
|
|
|
void onAddSearchDirBtnClicked();
|
2021-10-28 20:46:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCH_H
|