mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Make SearchManager singleton
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <QDomElement>
|
||||
#include <QDomNode>
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
|
||||
#include "base/logger.h"
|
||||
@@ -47,12 +48,17 @@
|
||||
#include "searchdownloadhandler.h"
|
||||
#include "searchhandler.h"
|
||||
|
||||
static inline void removePythonScriptIfExists(const QString &scriptPath)
|
||||
namespace
|
||||
{
|
||||
Utils::Fs::forceRemove(scriptPath);
|
||||
Utils::Fs::forceRemove(scriptPath + "c");
|
||||
inline void removePythonScriptIfExists(const QString &scriptPath)
|
||||
{
|
||||
Utils::Fs::forceRemove(scriptPath);
|
||||
Utils::Fs::forceRemove(scriptPath + "c");
|
||||
}
|
||||
}
|
||||
|
||||
QPointer<SearchPluginManager> SearchPluginManager::m_instance = nullptr;
|
||||
|
||||
const QHash<QString, QString> SearchPluginManager::m_categoryNames {
|
||||
{"all", QT_TRANSLATE_NOOP("SearchEngine", "All categories")},
|
||||
{"movies", QT_TRANSLATE_NOOP("SearchEngine", "Movies")},
|
||||
@@ -68,6 +74,9 @@ const QHash<QString, QString> SearchPluginManager::m_categoryNames {
|
||||
SearchPluginManager::SearchPluginManager()
|
||||
: m_updateUrl(QString("http://searchplugins.qbittorrent.org/%1/engines/").arg(Utils::Misc::pythonVersion() >= 3 ? "nova3" : "nova"))
|
||||
{
|
||||
Q_ASSERT(!m_instance); // only one instance is allowed
|
||||
m_instance = this;
|
||||
|
||||
updateNova();
|
||||
update();
|
||||
}
|
||||
@@ -77,6 +86,11 @@ SearchPluginManager::~SearchPluginManager()
|
||||
qDeleteAll(m_plugins);
|
||||
}
|
||||
|
||||
SearchPluginManager *SearchPluginManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
QStringList SearchPluginManager::allPlugins() const
|
||||
{
|
||||
return m_plugins.keys();
|
||||
|
||||
Reference in New Issue
Block a user