diff --git a/python/gui/auto_generated/qgsbrowserdockwidget.sip.in b/python/gui/auto_generated/qgsbrowserdockwidget.sip.in index 0cc95b488f1..32a95082a64 100644 --- a/python/gui/auto_generated/qgsbrowserdockwidget.sip.in +++ b/python/gui/auto_generated/qgsbrowserdockwidget.sip.in @@ -234,6 +234,17 @@ Splitter has been moved. no longer used. %End + void setButtonBoxVisibility( bool visible ); +%Docstring +Set button box visibility to ``visible``. + +.. note:: + + The button box is hidden by default. + +.. versionadded:: 3.34 +%End + signals: void openFile( const QString &fileName, const QString &fileTypeHint = QString() ); %Docstring @@ -246,6 +257,20 @@ Emitted when drop uri list needs to be handled void connectionsChanged(); %Docstring Connections changed in the browser +%End + + void helpRequested(); +%Docstring +Emitted when the help button in the button box is clicked + +.. versionadded:: 3.34 +%End + + void rejected(); +%Docstring +Emitted when the close button in the button box is clicked + +.. versionadded:: 3.34 %End }; diff --git a/src/gui/qgsbrowserdockwidget.cpp b/src/gui/qgsbrowserdockwidget.cpp index 5f971ccef78..5330b94fedd 100644 --- a/src/gui/qgsbrowserdockwidget.cpp +++ b/src/gui/qgsbrowserdockwidget.cpp @@ -23,6 +23,7 @@ #include #include +#include QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserGuiModel *browserModel, QWidget *parent ) : QgsDockWidget( parent ) @@ -39,6 +40,15 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserGuiMo mWidget = new QgsBrowserWidget( browserModel ); layout->addWidget( mWidget ); + mButtonBox = new QDialogButtonBox( QDialogButtonBox::StandardButton::Close | QDialogButtonBox::StandardButton::Help, this ); + mButtonBox->setVisible( false ); + layout->addWidget( mButtonBox ); + + // Forward signals from button box + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsBrowserDockWidget::helpRequested ); + connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsBrowserDockWidget::rejected ); + + // Connect action signals connect( mWidget, &QgsBrowserWidget::openFile, this, &QgsBrowserDockWidget::openFile ); connect( mWidget, &QgsBrowserWidget::handleDropUriList, this, &QgsBrowserDockWidget::handleDropUriList ); connect( mWidget, &QgsBrowserWidget::connectionsChanged, this, &QgsBrowserDockWidget::connectionsChanged ); @@ -226,3 +236,8 @@ void QgsBrowserDockWidget::setActiveIndex( const QModelIndex &index ) void QgsBrowserDockWidget::splitterMoved() { } + +void QgsBrowserDockWidget::setButtonBoxVisibility( bool visible ) +{ + mButtonBox->setVisible( visible ); +} diff --git a/src/gui/qgsbrowserdockwidget.h b/src/gui/qgsbrowserdockwidget.h index 5d4e11ad1d5..3f361af8e04 100644 --- a/src/gui/qgsbrowserdockwidget.h +++ b/src/gui/qgsbrowserdockwidget.h @@ -22,6 +22,8 @@ class QgsMessageBar; class QgsBrowserWidget; +class QDialogButtonBox; +class QAbstractButton; /** * \ingroup gui @@ -221,6 +223,13 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget */ Q_DECL_DEPRECATED void splitterMoved() SIP_DEPRECATED; + /** + * Set button box visibility to \a visible. + * \note The button box is hidden by default. + * \since QGIS 3.34 + */ + void setButtonBoxVisibility( bool visible ); + signals: //! Emitted when a file needs to be opened void openFile( const QString &fileName, const QString &fileTypeHint = QString() ); @@ -229,9 +238,22 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget //! Connections changed in the browser void connectionsChanged(); + /** + * Emitted when the help button in the button box is clicked + * \since QGIS 3.34 + */ + void helpRequested(); + + /** + * Emitted when the close button in the button box is clicked + * \since QGIS 3.34 + */ + void rejected(); + private: QgsBrowserWidget *mWidget = nullptr; + QDialogButtonBox *mButtonBox = nullptr; }; #endif // QGSBROWSERDOCKWIDGET_H diff --git a/src/gui/qgsdatasourcemanagerdialog.cpp b/src/gui/qgsdatasourcemanagerdialog.cpp index 89b54347a44..4bc0fb41053 100644 --- a/src/gui/qgsdatasourcemanagerdialog.cpp +++ b/src/gui/qgsdatasourcemanagerdialog.cpp @@ -67,6 +67,12 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsBrowserGuiModel *brow connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgsDataSourceManagerDialog::openFile ); connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgsDataSourceManagerDialog::connectionsChanged ); connect( this, &QgsDataSourceManagerDialog::updateProjectHome, mBrowserWidget->browserWidget(), &QgsBrowserWidget::updateProjectHome ); + connect( mBrowserWidget, &QgsBrowserDockWidget::helpRequested, this, [ = ]() + { + QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#the-browser-panel" ) ); + } ); + connect( mBrowserWidget, &QgsBrowserDockWidget::rejected, this, &QgsDataSourceManagerDialog::reject ); + mBrowserWidget->setButtonBoxVisibility( true ); // Add registered source select dialogs const QList sourceSelectProviders = QgsGui::sourceSelectProviderRegistry()->providers( );