Skip to content

Commit

Permalink
Allow QgsOptionsPageWidget to set a specific help key to view
Browse files Browse the repository at this point in the history
when clicking help in the options dialog
  • Loading branch information
nyalldawson committed Sep 23, 2017
1 parent 34b9ae2 commit 8dffa33
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
13 changes: 13 additions & 0 deletions python/gui/qgsoptionswidgetfactory.sip
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ class QgsOptionsPageWidget : QWidget
Constructor for QgsOptionsPageWidget. Constructor for QgsOptionsPageWidget.
%End %End


virtual QString helpKey() const;
%Docstring
Returns the optional help key for the options page. The default implementation
returns an empty string.

If a non-empty string is returned by this method, it will be used as the help key
retrieved when the "help" button is clicked while this options page is active.

If an empty string is returned by this method the default QGIS options
help will be retrieved.
:rtype: str
%End

public slots: public slots:


virtual void apply() = 0; virtual void apply() = 0;
Expand Down
33 changes: 24 additions & 9 deletions src/app/qgsoptions.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2355,19 +2355,34 @@ void QgsOptions::setZoomFactorValue()
void QgsOptions::showHelp() void QgsOptions::showHelp()
{ {
QWidget *activeTab = mOptionsStackedWidget->currentWidget(); QWidget *activeTab = mOptionsStackedWidget->currentWidget();
QString link = QStringLiteral( "introduction/qgis_configuration.html" ); QString link;


if ( activeTab == mOptionsPageAuth ) // give first priority to created pages which have specified a help key
for ( const QgsOptionsPageWidget *widget : qgsAsConst( mAdditionalOptionWidgets ) )
{ {
link = QStringLiteral( "auth_system/index.html" ); if ( widget == activeTab )
} {
else if ( activeTab == mOptionsPageVariables ) link = widget->helpKey();
{ break;
link = QStringLiteral( "introduction/general_tools.html#variables" ); }
} }
else if ( activeTab == mOptionsPageCRS )
if ( link.isEmpty() )
{ {
link = QStringLiteral( "working_with_projections/working_with_projections.html" ); link = QStringLiteral( "introduction/qgis_configuration.html" );

if ( activeTab == mOptionsPageAuth )
{
link = QStringLiteral( "auth_system/index.html" );
}
else if ( activeTab == mOptionsPageVariables )
{
link = QStringLiteral( "introduction/general_tools.html#variables" );
}
else if ( activeTab == mOptionsPageCRS )
{
link = QStringLiteral( "working_with_projections/working_with_projections.html" );
}
} }
QgsHelp::openHelp( link ); QgsHelp::openHelp( link );
} }
12 changes: 12 additions & 0 deletions src/gui/qgsoptionswidgetfactory.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class GUI_EXPORT QgsOptionsPageWidget : public QWidget
: QWidget( parent ) : QWidget( parent )
{} {}


/**
* Returns the optional help key for the options page. The default implementation
* returns an empty string.
*
* If a non-empty string is returned by this method, it will be used as the help key
* retrieved when the "help" button is clicked while this options page is active.
*
* If an empty string is returned by this method the default QGIS options
* help will be retrieved.
*/
virtual QString helpKey() const { return QString(); }

public slots: public slots:


/** /**
Expand Down

0 comments on commit 8dffa33

Please sign in to comment.