Skip to content

Commit b0f27c5

Browse files
authoredSep 24, 2017
Merge pull request #5245 from nyalldawson/conditionalHelpLink
Set the most accurate User Manual page to Options tabs
2 parents 8902d5f + 99def10 commit b0f27c5

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed
 

‎python/gui/qgsoptionswidgetfactory.sip

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ class QgsOptionsPageWidget : QWidget
2525
Constructor for QgsOptionsPageWidget.
2626
%End
2727

28+
virtual QString helpKey() const;
29+
%Docstring
30+
Returns the optional help key for the options page. The default implementation
31+
returns an empty string.
32+
33+
If a non-empty string is returned by this method, it will be used as the help key
34+
retrieved when the "help" button is clicked while this options page is active.
35+
36+
If an empty string is returned by this method the default QGIS options
37+
help will be retrieved.
38+
:rtype: str
39+
%End
40+
2841
public slots:
2942

3043
virtual void apply() = 0;

‎python/plugins/processing/gui/ConfigDialog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def __init__(self, parent):
8181
def apply(self):
8282
self.config_widget.accept()
8383

84+
def helpKey(self):
85+
return 'processing/index.html'
86+
8487

8588
class ConfigDialog(BASE, WIDGET):
8689

‎src/app/qgsoptions.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,5 +2354,35 @@ void QgsOptions::setZoomFactorValue()
23542354

23552355
void QgsOptions::showHelp()
23562356
{
2357-
QgsHelp::openHelp( QStringLiteral( "introduction/qgis_configuration.html#options" ) );
2357+
QWidget *activeTab = mOptionsStackedWidget->currentWidget();
2358+
QString link;
2359+
2360+
// give first priority to created pages which have specified a help key
2361+
for ( const QgsOptionsPageWidget *widget : qgsAsConst( mAdditionalOptionWidgets ) )
2362+
{
2363+
if ( widget == activeTab )
2364+
{
2365+
link = widget->helpKey();
2366+
break;
2367+
}
2368+
}
2369+
2370+
if ( link.isEmpty() )
2371+
{
2372+
link = QStringLiteral( "introduction/qgis_configuration.html" );
2373+
2374+
if ( activeTab == mOptionsPageAuth )
2375+
{
2376+
link = QStringLiteral( "auth_system/index.html" );
2377+
}
2378+
else if ( activeTab == mOptionsPageVariables )
2379+
{
2380+
link = QStringLiteral( "introduction/general_tools.html#variables" );
2381+
}
2382+
else if ( activeTab == mOptionsPageCRS )
2383+
{
2384+
link = QStringLiteral( "working_with_projections/working_with_projections.html" );
2385+
}
2386+
}
2387+
QgsHelp::openHelp( link );
23582388
}

‎src/gui/qgsoptionswidgetfactory.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ class GUI_EXPORT QgsOptionsPageWidget : public QWidget
3838
: QWidget( parent )
3939
{}
4040

41+
/**
42+
* Returns the optional help key for the options page. The default implementation
43+
* returns an empty string.
44+
*
45+
* If a non-empty string is returned by this method, it will be used as the help key
46+
* retrieved when the "help" button is clicked while this options page is active.
47+
*
48+
* If an empty string is returned by this method the default QGIS options
49+
* help will be retrieved.
50+
*/
51+
virtual QString helpKey() const { return QString(); }
52+
4153
public slots:
4254

4355
/**

0 commit comments

Comments
 (0)
Please sign in to comment.