Skip to content

Commit 62598af

Browse files
committed
[Plugin Manage] Include tab title pages to i18n. Don't clutter the resources dir.
1 parent 0fd7435 commit 62598af

File tree

10 files changed

+124
-93
lines changed

10 files changed

+124
-93
lines changed

resources/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ INSTALL(FILES srs.db qgis.db symbology-ng-style.db spatialite.db customization.x
22
DESTINATION ${QGIS_DATA_DIR}/resources)
33
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
44
INSTALL(DIRECTORY jQuery DESTINATION ${QGIS_DATA_DIR}/resources)
5-
INSTALL(DIRECTORY plugin_manager DESTINATION ${QGIS_DATA_DIR}/resources)
65

76
ADD_SUBDIRECTORY(context_help)
87
ADD_SUBDIRECTORY(function_help)

resources/plugin_manager/get_more_plugins

Lines changed: 0 additions & 17 deletions
This file was deleted.

resources/plugin_manager/installed_plugins

Lines changed: 0 additions & 18 deletions
This file was deleted.

resources/plugin_manager/invalid_plugins

Lines changed: 0 additions & 20 deletions
This file was deleted.

resources/plugin_manager/new_plugins

Lines changed: 0 additions & 7 deletions
This file was deleted.

resources/plugin_manager/upgradeable_plugins

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ SET(QGIS_APP_SRCS
149149
openstreetmap/qgsosmexportdialog.cpp
150150

151151
pluginmanager/qgspluginmanager.cpp
152+
pluginmanager/qgspluginmanager_texts.cpp
152153
pluginmanager/qgsapppluginmanagerinterface.cpp
153154
pluginmanager/qgspluginsortfilterproxymodel.cpp
154155

src/app/pluginmanager/qgspluginmanager.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ QgsPluginManager::QgsPluginManager( QWidget * parent, Qt::WFlags fl )
7272
QSettings settings;
7373
mPluginsDetailsSplitter->restoreState( settings.value( QString( "/Windows/PluginManager/secondSplitterState" ) ).toByteArray() );
7474

75+
// load translated description strings from qgspluginmanager_texts
76+
initTabDescriptions();
77+
7578
// Init models
7679
mModelPlugins = new QStandardItemModel( 0, 1 );
7780
mModelProxy = new QgsPluginSortFilterProxyModel( this );
@@ -896,60 +899,54 @@ void QgsPluginManager::setCurrentTab( int idx )
896899
mOptionsStackedWidget->setCurrentIndex( 0 );
897900

898901
QStringList acceptedStatuses;
899-
QString welcomePage;
902+
QString tabTitle;
900903
switch ( idx )
901904
{
902905
case 0:
903906
// installed (statuses ends with Z are for spacers to always sort properly)
904907
acceptedStatuses << "installed" << "orphan" << "newer" << "upgradeable" << "installedZ" << "upgradeableZ" << "orphanZ" << "newerZZ" << "" ;
905-
welcomePage = "installed_plugins";
908+
tabTitle = "installed_plugins";
906909
break;
907910
case 1:
908911
// not installed (get more)
909912
acceptedStatuses << "not installed" << "new" ;
910-
welcomePage = "get_more_plugins";
913+
tabTitle = "get_more_plugins";
911914
break;
912915
case 2:
913916
// upgradeable
914917
acceptedStatuses << "upgradeable" ;
915-
welcomePage = "upgradeable_plugins";
918+
tabTitle = "upgradeable_plugins";
916919
break;
917920
case 3:
918921
// new
919922
acceptedStatuses << "new" ;
920-
welcomePage = "new_plugins";
923+
tabTitle = "new_plugins";
921924
break;
922925
case 4:
923926
// invalid
924927
acceptedStatuses << "invalid" ;
925-
welcomePage = "invalid_plugins";
928+
tabTitle = "invalid_plugins";
926929
break;
927930
}
928931
mModelProxy->setAcceptedStatuses( acceptedStatuses );
929932

930933
updateTabTitle();
931934

932-
// load welcome HTML to the detail browser
933-
// // // // // // // TODO: after texts are done, read from translations instead.
934-
QString welcomeHTML = "";
935-
QFile welcomeFile( QgsApplication::pkgDataPath() + "/resources/plugin_manager/" + welcomePage );
936-
if ( welcomeFile.open( QIODevice::ReadOnly ) )
935+
// load tab description HTML to the detail browser
936+
QString tabInfoHTML = "";
937+
QMap<QString, QString>::iterator it = mTabDescriptions.find( tabTitle );
938+
if ( it != mTabDescriptions.end() )
937939
{
938-
QTextStream welcomeStream( &welcomeFile ); // Remove from includes too.
939-
welcomeStream.setCodec( "UTF-8" );
940940
QString myStyle = QgsApplication::reportStyleSheet();
941-
welcomeHTML += "<style>" + myStyle + "</style>";
942-
while ( !welcomeStream.atEnd() )
943-
{
944-
welcomeHTML += welcomeStream.readLine();
945-
}
941+
tabInfoHTML += "<style>" + myStyle + "</style>";
942+
tabInfoHTML = it.value();
946943
}
947-
tbDetails->setHtml( welcomeHTML );
948-
}
944+
tbDetails->setHtml( tabInfoHTML );
949945

950-
// disable buttons
951-
buttonInstall->setEnabled( false );
952-
buttonUninstall->setEnabled( false );
946+
// disable buttons
947+
buttonInstall->setEnabled( false );
948+
buttonUninstall->setEnabled( false );
949+
}
953950
}
954951

955952

src/app/pluginmanager/qgspluginmanager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
163163
void clearRepositoryFilter( );
164164

165165
private:
166+
167+
//! Load translated descriptions. Source strings implemented in external qgspluginmanager_texts.cpp
168+
void initTabDescriptions();
169+
166170
//! Return true if given plugin is present in QgsPluginRegistry (c++ plugins) or is enabled in QSettings (Python plugins)
167171
bool isPluginLoaded( QString key );
168172

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

191195
QgsPythonUtils* mPythonUtils;
192196

197+
QMap<QString, QString> mTabDescriptions;
198+
193199
QMap< QString, QMap< QString, QString > > mPlugins;
194200

195201
QString mCurrentlyDisplayedPlugin;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#include <QCoreApplication>
2+
#include "qgspluginmanager.h"
3+
4+
// QMap<QString, QString> QgsPluginManager::mTabDescriptions;
5+
6+
void QgsPluginManager::initTabDescriptions()
7+
{
8+
if( !mTabDescriptions.isEmpty() )
9+
return;
10+
11+
mTabDescriptions.insert( "installed_plugins", tr( "<h3>Installed Plugins</h3>\
12+
<p>\
13+
On the left you see the list of <b>installed plugins</b> on your system. Both python and cpp \
14+
plugins are listed. Some plugins come with your QGIS installation while most of\
15+
them are made available via the plugin repositories.\
16+
</p>\
17+
\
18+
<p>\
19+
You can temporarily enable or disable a plugin.\
20+
To <i>enable</i> or <i>disable</i> a plugin,\
21+
click its checkbox or doubleclick its name...\
22+
</p>\
23+
\
24+
<p>\
25+
Plugins showing in <span style='color:red'>red</span> are not loaded because there is a problem. Consult the \
26+
'Invalid' tab to see more details, or to reinstall or uninstall this plugin.\
27+
</p>\
28+
") );
29+
30+
31+
32+
mTabDescriptions.insert( "upgradeable_plugins", tr( "<h3>Upgradable plugins</h3>\
33+
\
34+
<p>\
35+
Here are <b>upgradeable plugins</b>. It means more recent versions of installed \
36+
plugins are available in the repositories.\
37+
</p>\
38+
\
39+
") );
40+
41+
42+
43+
mTabDescriptions.insert( "get_more_plugins", tr( "<h3>Get more plugins</h3>\
44+
\
45+
<p>\
46+
Here you see the list of all plugins available in the repositories, but which are <b>not yet installed</b>.\
47+
</p>\
48+
<p>\
49+
Click on the name to see details.\
50+
</p>\
51+
<p>\
52+
You can change the sorting via the context menu (right click).\
53+
</p>\
54+
<p>\
55+
A plugin can be downloaded and installed by clicking on it's name, and \
56+
then click the 'Install plugin' button.\
57+
</p>\
58+
\
59+
\
60+
") );
61+
62+
63+
64+
mTabDescriptions.insert( "new_plugins", tr( "<h3>New plugins</h3>\
65+
\
66+
<p>\
67+
Here you see hot <b>new</b> plugins which can be installed.\
68+
</p>\
69+
\
70+
\
71+
") );
72+
73+
74+
75+
mTabDescriptions.insert( "invalid_plugins", tr( "<h3>Invalid plugins</h3>\
76+
\
77+
<p>\
78+
Plugins in this list here are <b>broken or incompatible</b> with your version of QGIS.\
79+
</p>\
80+
\
81+
<p>\
82+
Click on an individual plugin; if possible QGIS shows you more information.\
83+
</p>\
84+
\
85+
<p>\
86+
The main reasons to have invalid plugins is either that this plugin is not build \
87+
for this version of QGIS. Maybe you can download an other version from <a href=\"http://plugins.qgis.org\">plugins.qgis.org</a>.\
88+
</p>\
89+
\
90+
<p>\
91+
Another common reason is that a python plugin needs some external python libraries (dependencies). \
92+
You can install them yourself, depending on your operating system. After a correct \
93+
install the plugin should work.\
94+
</p>\
95+
") );
96+
97+
}

0 commit comments

Comments
 (0)