Skip to content
Permalink
Browse files

[pluginmanager] show trusted plugins (fix #14916)

  • Loading branch information
alexbruy committed Jun 1, 2016
1 parent 479ceb3 commit 6e1302047c090fb4a90b70bd898b29c97f6ca54b
@@ -30,8 +30,10 @@
import qgis
from qgis.core import QgsApplication, QgsNetworkAccessManager
from qgis.gui import QgsMessageBar
from qgis.utils import iface, startPlugin, unloadPlugin, loadPlugin, reloadPlugin, updateAvailablePlugins
from .installer_data import repositories, plugins, officialRepo, settingsGroup, reposGroup, removeDir
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin,
reloadPlugin, updateAvailablePlugins)
from .installer_data import (repositories, plugins, officialRepo,
settingsGroup, reposGroup, removeDir)
from .qgsplugininstallerinstallingdialog import QgsPluginInstallerInstallingDialog
from .qgsplugininstallerpluginerrordialog import QgsPluginInstallerPluginErrorDialog
from .qgsplugininstallerfetchingdialog import QgsPluginInstallerFetchingDialog
@@ -211,6 +213,7 @@ def exportPluginsToManager(self):
"error_details": plugin["error_details"],
"experimental": plugin["experimental"] and "true" or "false",
"deprecated": plugin["deprecated"] and "true" or "false",
"trusted": plugin["trusted"] and "true" or "false",
"version_available": plugin["version_available"],
"zip_repository": plugin["zip_repository"],
"download_url": plugin["download_url"],
@@ -23,7 +23,9 @@
***************************************************************************/
"""

from qgis.PyQt.QtCore import pyqtSignal, QObject, QCoreApplication, QFile, QDir, QDirIterator, QSettings, QDate, QUrl, QFileInfo, QLocale, QByteArray
from qgis.PyQt.QtCore import (pyqtSignal, QObject, QCoreApplication, QFile,
QDir, QDirIterator, QSettings, QDate, QUrl,
QFileInfo, QLocale, QByteArray)
from qgis.PyQt.QtXml import QDomDocument
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
import sys
@@ -77,6 +79,7 @@
"error_details" unicode, # error description
"experimental" boolean, # true if experimental, false if stable
"deprecated" boolean, # true if deprected, false if actual
"trusted" boolean, # true if trusted, false if not trusted
"version_available" unicode, # available version
"zip_repository" unicode, # the remote repository id
"download_url" unicode, # url for downloading the plugin
@@ -408,6 +411,9 @@ def xmlDownloaded(self):
deprecated = False
if pluginNodes.item(i).firstChildElement("deprecated").text().strip().upper() in ["TRUE", "YES"]:
deprecated = True
trusted = False
if pluginNodes.item(i).firstChildElement("trusted").text().strip().upper() in ["TRUE", "YES"]:
trusted = True
icon = pluginNodes.item(i).firstChildElement("icon").text().strip()
if icon and not icon.startswith("http"):
icon = "http://%s/%s" % (QUrl(self.mRepositories[reposName]["url"]).host(), icon)
@@ -439,6 +445,7 @@ def xmlDownloaded(self):
"icon": icon,
"experimental": experimental,
"deprecated": deprecated,
"trusted": trusted,
"filename": fileName,
"installed": False,
"available": True,
@@ -667,6 +674,7 @@ def pluginMetadata(fct):
"pythonic": True,
"experimental": pluginMetadata("experimental").strip().upper() in ["TRUE", "YES"],
"deprecated": pluginMetadata("deprecated").strip().upper() in ["TRUE", "YES"],
"trusted": False,
"version_available": "",
"zip_repository": "",
"download_url": path, # warning: local path as url!
@@ -82,6 +82,11 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
painter->setPen( option.palette.text().color() );
}

if ( index.data( PLUGIN_TRUSTED_ROLE ).toBool() )
{
painter->setPen( Qt::darkGreen );
}

if ( ! index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() )
{
painter->setPen( Qt::red );
@@ -99,6 +104,3 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem

painter->restore();
}



@@ -502,6 +502,7 @@ void QgsPluginManager::reloadModelData()
mypDetailItem->setData( it->value( "downloads" ).rightJustified( 10, '0' ), PLUGIN_DOWNLOADS_ROLE );
mypDetailItem->setData( it->value( "zip_repository" ), PLUGIN_REPOSITORY_ROLE );
mypDetailItem->setData( it->value( "average_vote" ), PLUGIN_VOTE_ROLE );
mypDetailItem->setData( it->value( "trusted" ), PLUGIN_TRUSTED_ROLE );

if ( QFileInfo( iconPath ).isFile() )
{
@@ -729,6 +730,15 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
"</table>" ).arg( tr( "This plugin is deprecated" ) );
}

if ( metadata->value( "trusted" ) == "true" )
{
html += QString( "<table bgcolor=\"#90EE90\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
" <tr><td width=\"100%\" style=\"color:#660000\">"
" <img src=\"qrc:/images/themes/default/mIconSuccess.png\" width=\"32\"><b>%1</b>"
" </td></tr>"
"</table>" ).arg( tr( "This plugin is trusted" ) );
}

// Now the metadata

html += "<table cellspacing=\"4\" width=\"100%\"><tr><td>";
@@ -30,6 +30,7 @@ const int PLUGIN_STATUS_ROLE = Qt::UserRole + 6; // for filtering and sort
const int PLUGIN_DOWNLOADS_ROLE = Qt::UserRole + 7; // for sorting
const int PLUGIN_VOTE_ROLE = Qt::UserRole + 8; // for sorting
const int PLUGIN_REPOSITORY_ROLE = Qt::UserRole + 9; // for sorting
const int PLUGIN_TRUSTED_ROLE = Qt::UserRole + 10; // for highlighting
const int SPACER_ROLE = Qt::UserRole + 20; // for sorting


0 comments on commit 6e13020

Please sign in to comment.
You can’t perform that action at this time.