#ifndef SEARCHPLUGINFACTORY_H #define SEARCHPLUGINFACTORY_H #include #include #include "search-plugin-iface.h" #include "plugin-info.h" namespace UkuiSearch { class SearchPluginManager : public QObject { Q_OBJECT QStringList m_defaultPluginOrder = { "Applications Search", "Note Search", "Settings Search", "Dir Search", "File Search", "File Content Search", "Web Page" }; public: bool registerPlugin(SearchPluginIface *plugin); 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); static SearchPluginManager *getInstance(); const QList getPluginIds(); SearchPluginIface *getPlugin(const QString &pluginId); void close(); private: explicit SearchPluginManager(QObject *parent = nullptr); ~SearchPluginManager(); void initOrderSettings(); std::map m_map; std::map m_plugin_order;//绑定plugin ID和优先级 QSettings *m_orderSettings = nullptr; QStringList m_externalPlugins; Q_SIGNALS: void unregistered(const QString& pluginName); void reRegistered(const QString& pluginName); void changePos(const QString& pluginName, int index); }; } #endif // SEARCHPLUGINFACTORY_H