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)
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;

1
src/base/searchengine.h

@ -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);

4
src/gui/search/pluginselectdlg.cpp

@ -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…
Cancel
Save