2021-05-03 00:21:36 +08:00
|
|
|
#ifndef SEARCHPLUGINFACTORY_H
|
|
|
|
#define SEARCHPLUGINFACTORY_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2022-11-22 10:17:36 +08:00
|
|
|
#include <QSettings>
|
2021-05-27 21:10:11 +08:00
|
|
|
#include "search-plugin-iface.h"
|
2022-11-22 10:17:36 +08:00
|
|
|
#include "plugin-info.h"
|
2021-05-03 00:21:36 +08:00
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2021-08-02 13:46:59 +08:00
|
|
|
|
2021-05-03 00:21:36 +08:00
|
|
|
class SearchPluginManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-11-22 10:17:36 +08:00
|
|
|
|
|
|
|
QStringList m_defaultPluginOrder = {
|
|
|
|
"Applications Search",
|
|
|
|
"Note Search",
|
|
|
|
"Settings Search",
|
|
|
|
"Dir Search",
|
|
|
|
"File Search",
|
|
|
|
"File Content Search",
|
|
|
|
"Web Page"
|
|
|
|
};
|
|
|
|
|
2021-05-03 00:21:36 +08:00
|
|
|
public:
|
|
|
|
bool registerPlugin(SearchPluginIface *plugin);
|
2022-11-22 10:17:36 +08:00
|
|
|
bool registerExternalPlugin(SearchPluginIface *plugin, const QString &path);
|
|
|
|
bool reRegisterPlugin(SearchPluginIface *plugin, bool isExternal, const QString &externalPluginPath = QString());
|
|
|
|
bool unregisterPlugin(SearchPluginIface *plugin, bool isExternal, const QString &externalPluginPath = QString());
|
|
|
|
|
|
|
|
//测试用接口
|
|
|
|
bool reRegisterPlugin(const QString &pluginName);
|
|
|
|
bool unregisterPlugin(const QString &pluginName);
|
|
|
|
bool changePluginPos(const QString &pluginName, int pos);
|
2021-05-03 00:21:36 +08:00
|
|
|
|
|
|
|
static SearchPluginManager *getInstance();
|
2022-11-22 10:17:36 +08:00
|
|
|
const QList<PluginInfo> getPluginIds();
|
2021-05-03 00:21:36 +08:00
|
|
|
SearchPluginIface *getPlugin(const QString &pluginId);
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit SearchPluginManager(QObject *parent = nullptr);
|
|
|
|
~SearchPluginManager();
|
2022-11-22 10:17:36 +08:00
|
|
|
void initOrderSettings();
|
|
|
|
|
|
|
|
std::map<QString, SearchPluginIface*> m_map;
|
|
|
|
std::map<int, QString> m_plugin_order;//绑定plugin ID和优先级
|
|
|
|
|
|
|
|
QSettings *m_orderSettings = nullptr;
|
|
|
|
QStringList m_externalPlugins;
|
2021-05-03 00:21:36 +08:00
|
|
|
|
2022-11-22 10:17:36 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void unregistered(const QString& pluginName);
|
|
|
|
void reRegistered(const QString& pluginName);
|
|
|
|
void changePos(const QString& pluginName, int index);
|
2021-05-03 00:21:36 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SEARCHPLUGINFACTORY_H
|