Skip to content

Commit

Permalink
[pluginmanager] show trusted plugins (fix #14916)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jun 1, 2016
1 parent 479ceb3 commit 6e13020
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
7 changes: 5 additions & 2 deletions python/pyplugin_installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"],
Expand Down
10 changes: 9 additions & 1 deletion python/pyplugin_installer/installer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -439,6 +445,7 @@ def xmlDownloaded(self):
"icon": icon,
"experimental": experimental,
"deprecated": deprecated,
"trusted": trusted,
"filename": fileName,
"installed": False,
"available": True,
Expand Down Expand Up @@ -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!
Expand Down
8 changes: 5 additions & 3 deletions src/app/pluginmanager/qgspluginitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -99,6 +104,3 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem

painter->restore();
}



10 changes: 10 additions & 0 deletions src/app/pluginmanager/qgspluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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>";
Expand Down
1 change: 1 addition & 0 deletions src/app/pluginmanager/qgspluginsortfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 6e13020

Please sign in to comment.