mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-08 21:04:26 +00:00
Update the backend when a new plugin favicon is downloaded.
This commit is contained in:
parent
8c98c8cb3f
commit
34c29b78f9
@ -240,6 +240,20 @@ bool SearchEngine::uninstallPlugin(const QString &name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchEngine::updateIconPath(PluginInfo * const plugin)
|
||||||
|
{
|
||||||
|
if (!plugin) return;
|
||||||
|
QString iconPath = QString("%1/%2.png").arg(pluginsLocation()).arg(plugin->name);
|
||||||
|
if (QFile::exists(iconPath)) {
|
||||||
|
plugin->iconPath = iconPath;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iconPath = QString("%1/%2.ico").arg(pluginsLocation()).arg(plugin->name);
|
||||||
|
if (QFile::exists(iconPath))
|
||||||
|
plugin->iconPath = iconPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SearchEngine::checkForUpdates()
|
void SearchEngine::checkForUpdates()
|
||||||
{
|
{
|
||||||
// Download version file from update server on sourceforge
|
// Download version file from update server on sourceforge
|
||||||
@ -528,16 +542,7 @@ void SearchEngine::update()
|
|||||||
QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
|
QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
|
||||||
plugin->enabled = !disabledEngines.contains(pluginName);
|
plugin->enabled = !disabledEngines.contains(pluginName);
|
||||||
|
|
||||||
// Handle icon
|
updateIconPath(plugin);
|
||||||
QString iconPath = QString("%1/%2.png").arg(pluginsLocation()).arg(pluginName);
|
|
||||||
if (QFile::exists(iconPath)) {
|
|
||||||
plugin->iconPath = iconPath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iconPath = QString("%1/%2.ico").arg(pluginsLocation()).arg(pluginName);
|
|
||||||
if (QFile::exists(iconPath))
|
|
||||||
plugin->iconPath = iconPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_plugins.contains(pluginName)) {
|
if (!m_plugins.contains(pluginName)) {
|
||||||
m_plugins[pluginName] = plugin;
|
m_plugins[pluginName] = plugin;
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
void updatePlugin(const QString &name);
|
void updatePlugin(const QString &name);
|
||||||
void installPlugin(const QString &source);
|
void installPlugin(const QString &source);
|
||||||
bool uninstallPlugin(const QString &name);
|
bool uninstallPlugin(const QString &name);
|
||||||
|
static void updateIconPath(PluginInfo * const plugin);
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
|
|
||||||
void startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);
|
void startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);
|
||||||
|
@ -374,8 +374,10 @@ void PluginSelectDlg::iconDownloaded(const QString &url, QString filePath)
|
|||||||
QFile icon(filePath);
|
QFile icon(filePath);
|
||||||
icon.open(QIODevice::ReadOnly);
|
icon.open(QIODevice::ReadOnly);
|
||||||
QString iconPath = QString("%1/%2.%3").arg(SearchEngine::pluginsLocation()).arg(id).arg(ICOHandler::canRead(&icon) ? "ico" : "png");
|
QString iconPath = QString("%1/%2.%3").arg(SearchEngine::pluginsLocation()).arg(id).arg(ICOHandler::canRead(&icon) ? "ico" : "png");
|
||||||
if (QFile::copy(filePath, iconPath))
|
if (QFile::copy(filePath, iconPath)) {
|
||||||
item->setData(PLUGIN_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
item->setData(PLUGIN_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||||
|
m_pluginManager->updateIconPath(plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete tmp file
|
// Delete tmp file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user