Skip to content

Commit 8dffa33

Browse files
committed
Allow QgsOptionsPageWidget to set a specific help key to view
when clicking help in the options dialog
1 parent 34b9ae2 commit 8dffa33

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

python/gui/qgsoptionswidgetfactory.sip

+13
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;

src/app/qgsoptions.cpp

+24-9
Original file line numberDiff line numberDiff line change
@@ -2355,19 +2355,34 @@ void QgsOptions::setZoomFactorValue()
23552355
void QgsOptions::showHelp()
23562356
{
23572357
QWidget *activeTab = mOptionsStackedWidget->currentWidget();
2358-
QString link = QStringLiteral( "introduction/qgis_configuration.html" );
2358+
QString link;
23592359

2360-
if ( activeTab == mOptionsPageAuth )
2360+
// give first priority to created pages which have specified a help key
2361+
for ( const QgsOptionsPageWidget *widget : qgsAsConst( mAdditionalOptionWidgets ) )
23612362
{
2362-
link = QStringLiteral( "auth_system/index.html" );
2363-
}
2364-
else if ( activeTab == mOptionsPageVariables )
2365-
{
2366-
link = QStringLiteral( "introduction/general_tools.html#variables" );
2363+
if ( widget == activeTab )
2364+
{
2365+
link = widget->helpKey();
2366+
break;
2367+
}
23672368
}
2368-
else if ( activeTab == mOptionsPageCRS )
2369+
2370+
if ( link.isEmpty() )
23692371
{
2370-
link = QStringLiteral( "working_with_projections/working_with_projections.html" );
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+
}
23712386
}
23722387
QgsHelp::openHelp( link );
23732388
}

src/gui/qgsoptionswidgetfactory.h

+12
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)