mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
// Download version file from update server on sourceforge
|
||||
@ -528,16 +542,7 @@ void SearchEngine::update()
|
||||
QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
|
||||
plugin->enabled = !disabledEngines.contains(pluginName);
|
||||
|
||||
// Handle icon
|
||||
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;
|
||||
}
|
||||
updateIconPath(plugin);
|
||||
|
||||
if (!m_plugins.contains(pluginName)) {
|
||||
m_plugins[pluginName] = plugin;
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
void updatePlugin(const QString &name);
|
||||
void installPlugin(const QString &source);
|
||||
bool uninstallPlugin(const QString &name);
|
||||
static void updateIconPath(PluginInfo * const plugin);
|
||||
void checkForUpdates();
|
||||
|
||||
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);
|
||||
icon.open(QIODevice::ReadOnly);
|
||||
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)));
|
||||
m_pluginManager->updateIconPath(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete tmp file
|
||||
|
Loading…
x
Reference in New Issue
Block a user