2023-04-11 10:19:35 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, 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 <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2021-04-30 16:28:50 +08:00
|
|
|
#ifndef SEARCHPLUGINIFACE_H
|
|
|
|
#define SEARCHPLUGINIFACE_H
|
|
|
|
#define SearchPluginIface_iid "org.ukui.ukui-search.plugin-iface.SearchPluginInterface"
|
2023-12-20 15:51:38 +08:00
|
|
|
/**
|
|
|
|
* changelog:1.2.0 增加toolTip
|
|
|
|
*/
|
|
|
|
#define SEARCH_PLUGIN_IFACE_VERSION "1.2.0"
|
2021-04-30 16:28:50 +08:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QIcon>
|
2021-05-27 21:10:11 +08:00
|
|
|
#include <QList>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QtPlugin>
|
2021-04-30 16:28:50 +08:00
|
|
|
#include "plugin-iface.h"
|
2021-05-27 21:10:11 +08:00
|
|
|
#include "data-queue.h"
|
2021-04-30 16:28:50 +08:00
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2021-04-30 16:28:50 +08:00
|
|
|
class SearchPluginIface : public PluginInterface
|
|
|
|
{
|
|
|
|
public:
|
2022-11-02 20:50:30 +08:00
|
|
|
enum InvokableAction
|
|
|
|
{
|
|
|
|
None = 1u << 0,
|
|
|
|
HideUI = 1u << 1
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(InvokableActions, InvokableAction)
|
|
|
|
|
2021-05-12 16:27:24 +08:00
|
|
|
struct DescriptionInfo
|
|
|
|
{
|
|
|
|
QString key;
|
|
|
|
QString value;
|
|
|
|
};
|
2021-05-27 21:10:11 +08:00
|
|
|
struct Actioninfo
|
|
|
|
{
|
|
|
|
int actionkey;
|
|
|
|
QString displayName;
|
|
|
|
};
|
2021-05-03 00:21:36 +08:00
|
|
|
/**
|
2021-05-12 16:27:24 +08:00
|
|
|
* @brief The ResultInfo struct
|
2021-05-03 00:21:36 +08:00
|
|
|
*/
|
2021-05-12 16:27:24 +08:00
|
|
|
struct ResultInfo
|
2021-04-30 16:28:50 +08:00
|
|
|
{
|
|
|
|
QIcon icon;
|
|
|
|
QString name;
|
2023-12-20 15:51:38 +08:00
|
|
|
QString toolTip;
|
2021-05-12 16:27:24 +08:00
|
|
|
QVector<DescriptionInfo> description;
|
2021-05-27 21:10:11 +08:00
|
|
|
QString actionKey;
|
|
|
|
int type;
|
2023-12-20 15:51:38 +08:00
|
|
|
ResultInfo(const QIcon &iconToSet = QIcon(),
|
|
|
|
const QString &nameToSet = QString(),
|
|
|
|
const QString &toolTipToSet = QString(),
|
2023-01-21 11:37:39 +08:00
|
|
|
const QVector<DescriptionInfo> &descriptionToSet = QVector<DescriptionInfo>(),
|
2023-12-20 15:51:38 +08:00
|
|
|
const QString &actionKeyToSet = QString(),
|
|
|
|
const int &typeToSet = 0) {
|
2023-01-21 11:37:39 +08:00
|
|
|
icon = iconToSet;
|
|
|
|
name = nameToSet;
|
2023-12-20 15:51:38 +08:00
|
|
|
toolTip = toolTipToSet;
|
2023-01-21 11:37:39 +08:00
|
|
|
description = descriptionToSet;
|
|
|
|
actionKey = actionKeyToSet;
|
|
|
|
type = typeToSet;
|
|
|
|
}
|
2023-09-01 11:07:57 +08:00
|
|
|
~ResultInfo() {
|
|
|
|
description.clear();
|
|
|
|
description.squeeze();
|
|
|
|
}
|
2021-04-30 16:28:50 +08:00
|
|
|
};
|
2021-05-27 21:10:11 +08:00
|
|
|
|
2021-05-03 00:21:36 +08:00
|
|
|
virtual ~SearchPluginIface() {}
|
2021-04-30 16:28:50 +08:00
|
|
|
virtual QString getPluginName() = 0;
|
2021-05-27 21:10:11 +08:00
|
|
|
virtual void KeywordSearch(QString keyword,DataQueue<ResultInfo> *searchResult) = 0;
|
2022-02-12 14:20:55 +08:00
|
|
|
virtual void stopSearch() = 0;
|
2021-05-27 21:10:11 +08:00
|
|
|
virtual QList<Actioninfo> getActioninfo(int type) = 0;
|
2021-06-17 14:08:55 +08:00
|
|
|
virtual void openAction(int actionkey, QString key, int type) = 0;
|
2021-07-31 16:12:04 +08:00
|
|
|
// virtual bool isPreviewEnable(QString key, int type) = 0;
|
|
|
|
// virtual QWidget *previewPage(QString key, int type, QWidget *parent = nullptr) = 0;
|
|
|
|
virtual QWidget *detailPage(const ResultInfo &ri) = 0;
|
2022-11-02 20:50:30 +08:00
|
|
|
|
|
|
|
void invokeActions(InvokableActions actions);
|
2021-04-30 16:28:50 +08:00
|
|
|
};
|
|
|
|
}
|
2021-12-14 14:43:35 +08:00
|
|
|
Q_DECLARE_INTERFACE(UkuiSearch::SearchPluginIface, SearchPluginIface_iid)
|
2021-04-30 16:28:50 +08:00
|
|
|
|
|
|
|
#endif // SEARCHPLUGINIFACE_H
|