Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Plugin Manage] Include tab title pages to i18n. Don't clutter the re…
…sources dir.
  • Loading branch information
borysiasty committed Jun 11, 2013
1 parent 0fd7435 commit 62598af
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 93 deletions.
1 change: 0 additions & 1 deletion resources/CMakeLists.txt
Expand Up @@ -2,7 +2,6 @@ INSTALL(FILES srs.db qgis.db symbology-ng-style.db spatialite.db customization.x
DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY jQuery DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY plugin_manager DESTINATION ${QGIS_DATA_DIR}/resources)

ADD_SUBDIRECTORY(context_help)
ADD_SUBDIRECTORY(function_help)
17 changes: 0 additions & 17 deletions resources/plugin_manager/get_more_plugins

This file was deleted.

18 changes: 0 additions & 18 deletions resources/plugin_manager/installed_plugins

This file was deleted.

20 changes: 0 additions & 20 deletions resources/plugin_manager/invalid_plugins

This file was deleted.

7 changes: 0 additions & 7 deletions resources/plugin_manager/new_plugins

This file was deleted.

7 changes: 0 additions & 7 deletions resources/plugin_manager/upgradeable_plugins

This file was deleted.

1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -149,6 +149,7 @@ SET(QGIS_APP_SRCS
openstreetmap/qgsosmexportdialog.cpp

pluginmanager/qgspluginmanager.cpp
pluginmanager/qgspluginmanager_texts.cpp
pluginmanager/qgsapppluginmanagerinterface.cpp
pluginmanager/qgspluginsortfilterproxymodel.cpp

Expand Down
43 changes: 20 additions & 23 deletions src/app/pluginmanager/qgspluginmanager.cpp
Expand Up @@ -72,6 +72,9 @@ QgsPluginManager::QgsPluginManager( QWidget * parent, Qt::WFlags fl )
QSettings settings;
mPluginsDetailsSplitter->restoreState( settings.value( QString( "/Windows/PluginManager/secondSplitterState" ) ).toByteArray() );

// load translated description strings from qgspluginmanager_texts
initTabDescriptions();

// Init models
mModelPlugins = new QStandardItemModel( 0, 1 );
mModelProxy = new QgsPluginSortFilterProxyModel( this );
Expand Down Expand Up @@ -896,60 +899,54 @@ void QgsPluginManager::setCurrentTab( int idx )
mOptionsStackedWidget->setCurrentIndex( 0 );

QStringList acceptedStatuses;
QString welcomePage;
QString tabTitle;
switch ( idx )
{
case 0:
// installed (statuses ends with Z are for spacers to always sort properly)
acceptedStatuses << "installed" << "orphan" << "newer" << "upgradeable" << "installedZ" << "upgradeableZ" << "orphanZ" << "newerZZ" << "" ;
welcomePage = "installed_plugins";
tabTitle = "installed_plugins";
break;
case 1:
// not installed (get more)
acceptedStatuses << "not installed" << "new" ;
welcomePage = "get_more_plugins";
tabTitle = "get_more_plugins";
break;
case 2:
// upgradeable
acceptedStatuses << "upgradeable" ;
welcomePage = "upgradeable_plugins";
tabTitle = "upgradeable_plugins";
break;
case 3:
// new
acceptedStatuses << "new" ;
welcomePage = "new_plugins";
tabTitle = "new_plugins";
break;
case 4:
// invalid
acceptedStatuses << "invalid" ;
welcomePage = "invalid_plugins";
tabTitle = "invalid_plugins";
break;
}
mModelProxy->setAcceptedStatuses( acceptedStatuses );

updateTabTitle();

// load welcome HTML to the detail browser
// // // // // // // TODO: after texts are done, read from translations instead.
QString welcomeHTML = "";
QFile welcomeFile( QgsApplication::pkgDataPath() + "/resources/plugin_manager/" + welcomePage );
if ( welcomeFile.open( QIODevice::ReadOnly ) )
// load tab description HTML to the detail browser
QString tabInfoHTML = "";
QMap<QString, QString>::iterator it = mTabDescriptions.find( tabTitle );
if ( it != mTabDescriptions.end() )
{
QTextStream welcomeStream( &welcomeFile ); // Remove from includes too.
welcomeStream.setCodec( "UTF-8" );
QString myStyle = QgsApplication::reportStyleSheet();
welcomeHTML += "<style>" + myStyle + "</style>";
while ( !welcomeStream.atEnd() )
{
welcomeHTML += welcomeStream.readLine();
}
tabInfoHTML += "<style>" + myStyle + "</style>";
tabInfoHTML = it.value();
}
tbDetails->setHtml( welcomeHTML );
}
tbDetails->setHtml( tabInfoHTML );

// disable buttons
buttonInstall->setEnabled( false );
buttonUninstall->setEnabled( false );
// disable buttons
buttonInstall->setEnabled( false );
buttonUninstall->setEnabled( false );
}
}


Expand Down
6 changes: 6 additions & 0 deletions src/app/pluginmanager/qgspluginmanager.h
Expand Up @@ -163,6 +163,10 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
void clearRepositoryFilter( );

private:

//! Load translated descriptions. Source strings implemented in external qgspluginmanager_texts.cpp
void initTabDescriptions();

//! Return true if given plugin is present in QgsPluginRegistry (c++ plugins) or is enabled in QSettings (Python plugins)
bool isPluginLoaded( QString key );

Expand Down Expand Up @@ -190,6 +194,8 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag

QgsPythonUtils* mPythonUtils;

QMap<QString, QString> mTabDescriptions;

QMap< QString, QMap< QString, QString > > mPlugins;

QString mCurrentlyDisplayedPlugin;
Expand Down
97 changes: 97 additions & 0 deletions src/app/pluginmanager/qgspluginmanager_texts.cpp
@@ -0,0 +1,97 @@
#include <QCoreApplication>
#include "qgspluginmanager.h"

// QMap<QString, QString> QgsPluginManager::mTabDescriptions;

void QgsPluginManager::initTabDescriptions()
{
if( !mTabDescriptions.isEmpty() )
return;

mTabDescriptions.insert( "installed_plugins", tr( "<h3>Installed Plugins</h3>\
<p>\
On the left you see the list of <b>installed plugins</b> on your system. Both python and cpp \
plugins are listed. Some plugins come with your QGIS installation while most of\
them are made available via the plugin repositories.\
</p>\
\
<p>\
You can temporarily enable or disable a plugin.\
To <i>enable</i> or <i>disable</i> a plugin,\
click its checkbox or doubleclick its name...\
</p>\
\
<p>\
Plugins showing in <span style='color:red'>red</span> are not loaded because there is a problem. Consult the \
'Invalid' tab to see more details, or to reinstall or uninstall this plugin.\
</p>\
") );



mTabDescriptions.insert( "upgradeable_plugins", tr( "<h3>Upgradable plugins</h3>\
\
<p>\
Here are <b>upgradeable plugins</b>. It means more recent versions of installed \
plugins are available in the repositories.\
</p>\
\
") );



mTabDescriptions.insert( "get_more_plugins", tr( "<h3>Get more plugins</h3>\
\
<p>\
Here you see the list of all plugins available in the repositories, but which are <b>not yet installed</b>.\
</p>\
<p>\
Click on the name to see details.\
</p>\
<p>\
You can change the sorting via the context menu (right click).\
</p>\
<p>\
A plugin can be downloaded and installed by clicking on it's name, and \
then click the 'Install plugin' button.\
</p>\
\
\
") );



mTabDescriptions.insert( "new_plugins", tr( "<h3>New plugins</h3>\
\
<p>\
Here you see hot <b>new</b> plugins which can be installed.\
</p>\
\
\
") );



mTabDescriptions.insert( "invalid_plugins", tr( "<h3>Invalid plugins</h3>\
\
<p>\
Plugins in this list here are <b>broken or incompatible</b> with your version of QGIS.\
</p>\
\
<p>\
Click on an individual plugin; if possible QGIS shows you more information.\
</p>\
\
<p>\
The main reasons to have invalid plugins is either that this plugin is not build \
for this version of QGIS. Maybe you can download an other version from <a href=\"http://plugins.qgis.org\">plugins.qgis.org</a>.\
</p>\
\
<p>\
Another common reason is that a python plugin needs some external python libraries (dependencies). \
You can install them yourself, depending on your operating system. After a correct \
install the plugin should work.\
</p>\
") );

}

0 comments on commit 62598af

Please sign in to comment.