Skip to content
Permalink
Browse files
[Plugin Manager] Switch the plugin details browser from QTextBrowser …
…to QWebView
  • Loading branch information
borysiasty committed Apr 1, 2014
1 parent 1c3b5e4 commit 298b1d58829f1230343de54772cf54c5c818f3e2
Showing with 111 additions and 78 deletions.
  1. +78 −49 src/app/pluginmanager/qgspluginmanager.cpp
  2. +4 −1 src/app/pluginmanager/qgspluginmanager.h
  3. +29 −28 src/ui/qgspluginmanagerbase.ui
@@ -30,6 +30,8 @@
#include <QActionGroup>
#include <QTextStream>
#include <QTimer>
#include <QWebPage>
#include <QDesktopServices>

#include "qgis.h"
#include "qgisapp.h"
@@ -95,6 +97,7 @@ QgsPluginManager::QgsPluginManager( QWidget * parent, bool pluginsAreEnabled, Qt

// Preset widgets
leFilter->setFocus( Qt::MouseFocusReason );
wvDetails->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);

// Don't restore the last used tab from QSettings
mOptionsListWidget->setCurrentRow( 0 );
@@ -103,7 +106,6 @@ QgsPluginManager::QgsPluginManager( QWidget * parent, bool pluginsAreEnabled, Qt
connect( mOptionsListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( setCurrentTab( int ) ) );
connect( vwPlugins->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( currentPluginChanged( const QModelIndex & ) ) );
connect( mModelPlugins, SIGNAL( itemChanged( QStandardItem * ) ), this, SLOT( pluginItemChanged( QStandardItem * ) ) );

// Force setting the status filter (if the active tab was 0, the setCurrentRow( 0 ) above doesn't take any action)
setCurrentTab( 0 );

@@ -471,7 +473,7 @@ void QgsPluginManager::reloadModelData()

if ( !mCurrentlyDisplayedPlugin.isEmpty() )
{
tbDetails->setHtml( "" );
wvDetails->setHtml( "" );
buttonInstall->setEnabled( false );
buttonUninstall->setEnabled( false );
}
@@ -599,23 +601,34 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
if ( ! metadata ) return;

QString html = "";

// // A future mockup for install/uninstall html controls
// "<table bgcolor=\"#CCCCCC\" cellspacing=\"5\" cellpadding=\"10\" width=\"100%\" height=\"100px\">"
// "<tr><td colspan=\"3\"><b>This plugin is installed</b></td></tr>"
// "<tr>"
// " <td></td>"
// " <td bgcolor=\"#AAFFAA\" align=\"right\"><a href=\"foo\" style=\"text-decoration:none;\" ><b>REINSTALL</b></a></td>"
// " <td bgcolor=\"#FFFFAA\" align=\"right\"><a href=\"foo\" style=\"text-decoration:none;\" ><b>UNINSTALL</b></a></td>"
// "</tr>"
// "</table><br/>";
// // -----------------------------------------
// // Print all tags for debug purposes
// QList<QString> keys = metadata->keys();
// for ( int i=0; i < keys.size(); ++i )
// {
// html += QString( "%1: %2 <br/>" ).arg( keys.at( i ) ).arg( metadata->value( keys.at( i ) ) );
// }
html += "<style>"
" body, table {"
" padding:0px;"
" margin:0px;"
" font-family:verdana;"
" font-size: 12px;"
" }"
" div#votes {"
" width:360px;"
" margin-left:98px;"
" padding-top:3px;"
" }";

if ( ! metadata->value( "average_vote" ).isEmpty() )
{
html += QString(
" div#stars_bg {"
" background-image: url('file:///home/borys/Pobrane/stars_empty.png');"
" width:92px;"
" height:16px;"
" }"
" div#stars {"
" background-image: url('file:///home/borys/Pobrane/stars_full.png');"
" width:%1px;"
" height:16px;"
" }").arg( metadata->value( "average_vote" ).toFloat() / 5 * 92 );
}
html += "</style>";

// First prepare message box(es)
if ( ! metadata->value( "error" ).isEmpty() )
@@ -659,62 +672,65 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
{
html += QString( "<table bgcolor=\"#EEEEBB\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
" <tr><td width=\"100%\" style=\"color:#660000\">"
" <img src=\":/images/themes/default/pluginExperimental.png\" width=\"32\"><b>%1</b>"
" <img src=\"qrc:/images/themes/default/pluginExperimental.png\" width=\"32\"><b>%1</b>"
" </td></tr>"
"</table>" ).arg( tr( "This plugin is experimental" ) );
};
if ( metadata->value( "deprecated" ) == "true" )
{
html += QString( "<table bgcolor=\"#EEBBCC\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
" <tr><td width=\"100%\" style=\"color:#660000\">"
" <img src=\":/images/themes/default/pluginDeprecated.png\" width=\"32\"><b>%1</b>"
" <img src=\"qrc:/images/themes/default/pluginDeprecated.png\" width=\"32\"><b>%1</b>"
" </td></tr>"
"</table>" ).arg( tr( "This plugin is deprecated" ) );
};
// if ( metadata->value( "status" ) == t.b.d. )
// {
// html += QString( "<table bgcolor=\"#CCCCFF\" cellspacing=\"2\" cellpadding=\"6\" width=\"100%\">"
// " <tr><td width=\"100%\" style=\"color:#000088\"><b>%1</b></td></tr>"
// "</table>" ).arg( tr( "Installing..." ) );
// };

// Now the metadata
html += "<table cellspacing=\"10\" width=\"100%\"><tr><td>";
html += QString( "<h1>%1</h1>" ).arg( metadata->value( "name" ) );

if ( QFileInfo( metadata->value( "icon" ) ).isFile() )
html += "<table cellspacing=\"4\" width=\"100%\"><tr><td>";

QString iconPath = metadata->value( "icon" );
if ( QFileInfo( iconPath ).isFile() )
{
html += QString( "<img src=\"%1\" style=\"float:right;\">" ).arg( metadata->value( "icon" ) );
if ( iconPath.contains( ":/" ) )
{
iconPath = "qrc" + iconPath;
}
else
{
iconPath = "file://" + iconPath;
}
html += QString( "<img src=\"%1\" style=\"float:right;\">" ).arg( iconPath );
}

html += QString( "<h1>%1</h1>" ).arg( metadata->value( "name" ) );

html += QString( "<h3>%1</h3>" ).arg( metadata->value( "description" ) );

if ( ! metadata->value( "about" ).isEmpty() )
{
html += metadata->value( "about" );
}

html += "<table><tr><td align='right' width='100%'>";
if ( ! metadata->value( "average_vote" ).isEmpty() && metadata->value( "average_vote" ).toFloat() )
html += "<br/><br/>";
html += "<div id='stars_bg'><div/><div id='stars'><div/>";
html += "<div id='votes'>";
if ( ! metadata->value( "rating_votes" ).isEmpty() )
{
// draw stars
int stars = qRound( metadata->value( "average_vote" ).toFloat() );
for ( int i = 0; i < stars; i++ )
{
html += "<img src=\":/images/themes/default/mIconNew.png\">";
}
html += tr( "<br/>%1 rating vote(s)<br/>" ).arg( metadata->value( "rating_votes" ) );
html += tr( "%1 rating vote(s)" ).arg( metadata->value( "rating_votes" ) );
}
else if ( ! metadata->value( "downloads" ).isEmpty() )
if ( ! ( metadata->value( "rating_votes" ).isEmpty() || metadata->value( "downloads" ).isEmpty() ) )
{
// spacer between description and downloads
html += "<br/>";
html += ", ";
}
if ( ! metadata->value( "downloads" ).isEmpty() )
{
html += tr( "%1 downloads" ).arg( metadata->value( "downloads" ) );
}
html += "</td></tr></table><br/>";

html += "</div>";
html += "</td></tr><tr><td>";
html += "<br/>";

if ( ! metadata->value( "category" ).isEmpty() )
{
@@ -774,7 +790,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )

html += "</td></tr></table>";

tbDetails->setHtml( html );
wvDetails->setHtml( html );

// Set buttonInstall text (and sometimes focus)
buttonInstall->setDefault( false );
@@ -1009,11 +1025,17 @@ void QgsPluginManager::setCurrentTab( int idx )
QMap<QString, QString>::iterator it = mTabDescriptions.find( tabTitle );
if ( it != mTabDescriptions.end() )
{
QString myStyle = QgsApplication::reportStyleSheet();
tabInfoHTML += "<style>" + myStyle + "</style>";
tabInfoHTML = it.value();
tabInfoHTML += "<style>"
"body, table {"
"margin:4px;"
"font-family:verdana;"
"font-size: 12px;"
"}"
"</style>";
// tabInfoHTML += "<style>" + QgsApplication::reportStyleSheet() + "</style>";
tabInfoHTML += it.value();
}
tbDetails->setHtml( tabInfoHTML );
wvDetails->setHtml( tabInfoHTML );

// disable buttons
buttonInstall->setEnabled( false );
@@ -1081,6 +1103,13 @@ void QgsPluginManager::on_vwPlugins_doubleClicked( const QModelIndex & theIndex



void QgsPluginManager::on_wvDetails_linkClicked( const QUrl & url )
{
QDesktopServices::openUrl( url );
}



void QgsPluginManager::on_leFilter_textChanged( QString theText )
{
if ( theText.startsWith( "tag:", Qt::CaseInsensitive ) )
@@ -111,11 +111,14 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
void pluginItemChanged( QStandardItem * item );

//! Display details of inactive item too
void on_vwPlugins_clicked( const QModelIndex & );
void on_vwPlugins_clicked( const QModelIndex & index );

//! Load/unload plugin by double click
void on_vwPlugins_doubleClicked( const QModelIndex & index );

//! Handle click in the web wiew
void on_wvDetails_linkClicked( const QUrl & url );

//! Update the filter when user changes the filter expression
void on_leFilter_textChanged( QString theText );

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>812</width>
<height>610</height>
<width>936</width>
<height>565</height>
</rect>
</property>
<property name="minimumSize">
@@ -358,31 +358,27 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QTextBrowser" name="tbDetails">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>true</bool>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWebView" name="wvDetails">
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@@ -520,8 +516,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>582</width>
<height>653</height>
<width>355</width>
<height>695</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@@ -941,6 +937,11 @@ p, li { white-space: pre-wrap; }
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
@@ -957,7 +958,7 @@ p, li { white-space: pre-wrap; }
<tabstop>mOptionsListWidget</tabstop>
<tabstop>leFilter</tabstop>
<tabstop>vwPlugins</tabstop>
<tabstop>tbDetails</tabstop>
<tabstop>wvDetails</tabstop>
<tabstop>buttonUpgradeAll</tabstop>
<tabstop>buttonUninstall</tabstop>
<tabstop>buttonInstall</tabstop>

0 comments on commit 298b1d5

Please sign in to comment.