Browse Source

Update the backend when a new plugin favicon is downloaded.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
34c29b78f9
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 25
      src/base/searchengine.cpp
  2. 1
      src/base/searchengine.h
  3. 4
      src/gui/search/pluginselectdlg.cpp

25
src/base/searchengine.cpp

@ -240,6 +240,20 @@ bool SearchEngine::uninstallPlugin(const QString &name) @@ -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() @@ -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;

1
src/base/searchengine.h

@ -84,6 +84,7 @@ public: @@ -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);

4
src/gui/search/pluginselectdlg.cpp

@ -374,8 +374,10 @@ void PluginSelectDlg::iconDownloaded(const QString &url, QString filePath) @@ -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…
Cancel
Save