mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 14:12:30 -06:00
committed by
GitHub
parent
facfa26eed
commit
dd1bd8ad10
@@ -309,10 +309,10 @@ void PluginSelectDialog::addNewPlugin(const QString &pluginName)
|
||||
setRowColor(m_ui->pluginsTree->indexOfTopLevelItem(item), "red");
|
||||
}
|
||||
// Handle icon
|
||||
if (QFile::exists(plugin->iconPath))
|
||||
if (plugin->iconPath.exists())
|
||||
{
|
||||
// Good, we already have the icon
|
||||
item->setData(PLUGIN_NAME, Qt::DecorationRole, QIcon(plugin->iconPath));
|
||||
item->setData(PLUGIN_NAME, Qt::DecorationRole, QIcon(plugin->iconPath.data()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -406,10 +406,10 @@ void PluginSelectDialog::iconDownloadFinished(const Net::DownloadResult &result)
|
||||
return;
|
||||
}
|
||||
|
||||
const QString filePath = Utils::Fs::toUniformPath(result.filePath);
|
||||
const Path filePath = result.filePath;
|
||||
|
||||
// Icon downloaded
|
||||
QIcon icon(filePath);
|
||||
QIcon icon {filePath.data()};
|
||||
// Detect a non-decodable icon
|
||||
QList<QSize> sizes = icon.availableSizes();
|
||||
bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
|
||||
@@ -421,21 +421,19 @@ void PluginSelectDialog::iconDownloadFinished(const Net::DownloadResult &result)
|
||||
PluginInfo *plugin = m_pluginManager->pluginInfo(id);
|
||||
if (!plugin) continue;
|
||||
|
||||
QString iconPath = QString("%1/%2.%3")
|
||||
.arg(SearchPluginManager::pluginsLocation()
|
||||
, id
|
||||
, result.url.endsWith(".ico", Qt::CaseInsensitive) ? "ico" : "png");
|
||||
if (QFile::copy(filePath, iconPath))
|
||||
const QString ext = result.url.endsWith(QLatin1String(".ico"), Qt::CaseInsensitive) ? QLatin1String(".ico") : QLatin1String(".png");
|
||||
const Path iconPath = SearchPluginManager::pluginsLocation() / Path(id + ext);
|
||||
if (Utils::Fs::copyFile(filePath, iconPath))
|
||||
{
|
||||
// This 2nd check is necessary. Some favicons (eg from piratebay)
|
||||
// decode fine without an ext, but fail to do so when appending the ext
|
||||
// from the url. Probably a Qt bug.
|
||||
QIcon iconWithExt(iconPath);
|
||||
QIcon iconWithExt {iconPath.data()};
|
||||
QList<QSize> sizesExt = iconWithExt.availableSizes();
|
||||
bool invalidExt = (sizesExt.isEmpty() || iconWithExt.pixmap(sizesExt.first()).isNull());
|
||||
if (invalidExt)
|
||||
{
|
||||
Utils::Fs::forceRemove(iconPath);
|
||||
Utils::Fs::removeFile(iconPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -445,7 +443,7 @@ void PluginSelectDialog::iconDownloadFinished(const Net::DownloadResult &result)
|
||||
}
|
||||
}
|
||||
// Delete tmp file
|
||||
Utils::Fs::forceRemove(filePath);
|
||||
Utils::Fs::removeFile(filePath);
|
||||
}
|
||||
|
||||
void PluginSelectDialog::checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo)
|
||||
|
||||
Reference in New Issue
Block a user