mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
BROWSER add optional button box to dock widget
The button box holds Close and Help buttons and it is hidden by default. Signals are forwarded. Fix #54171
This commit is contained in:
parent
b9bfaf5c49
commit
3ecf3d5f61
@ -234,6 +234,17 @@ Splitter has been moved.
|
|||||||
no longer used.
|
no longer used.
|
||||||
%End
|
%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:
|
signals:
|
||||||
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
|
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
|
||||||
%Docstring
|
%Docstring
|
||||||
@ -246,6 +257,20 @@ Emitted when drop uri list needs to be handled
|
|||||||
void connectionsChanged();
|
void connectionsChanged();
|
||||||
%Docstring
|
%Docstring
|
||||||
Connections changed in the browser
|
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
|
%End
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserGuiModel *browserModel, QWidget *parent )
|
QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserGuiModel *browserModel, QWidget *parent )
|
||||||
: QgsDockWidget( parent )
|
: QgsDockWidget( parent )
|
||||||
@ -39,6 +40,15 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserGuiMo
|
|||||||
mWidget = new QgsBrowserWidget( browserModel );
|
mWidget = new QgsBrowserWidget( browserModel );
|
||||||
layout->addWidget( mWidget );
|
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::openFile, this, &QgsBrowserDockWidget::openFile );
|
||||||
connect( mWidget, &QgsBrowserWidget::handleDropUriList, this, &QgsBrowserDockWidget::handleDropUriList );
|
connect( mWidget, &QgsBrowserWidget::handleDropUriList, this, &QgsBrowserDockWidget::handleDropUriList );
|
||||||
connect( mWidget, &QgsBrowserWidget::connectionsChanged, this, &QgsBrowserDockWidget::connectionsChanged );
|
connect( mWidget, &QgsBrowserWidget::connectionsChanged, this, &QgsBrowserDockWidget::connectionsChanged );
|
||||||
@ -226,3 +236,8 @@ void QgsBrowserDockWidget::setActiveIndex( const QModelIndex &index )
|
|||||||
void QgsBrowserDockWidget::splitterMoved()
|
void QgsBrowserDockWidget::splitterMoved()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsBrowserDockWidget::setButtonBoxVisibility( bool visible )
|
||||||
|
{
|
||||||
|
mButtonBox->setVisible( visible );
|
||||||
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
class QgsMessageBar;
|
class QgsMessageBar;
|
||||||
class QgsBrowserWidget;
|
class QgsBrowserWidget;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QAbstractButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup gui
|
* \ingroup gui
|
||||||
@ -221,6 +223,13 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget
|
|||||||
*/
|
*/
|
||||||
Q_DECL_DEPRECATED void splitterMoved() SIP_DEPRECATED;
|
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:
|
signals:
|
||||||
//! Emitted when a file needs to be opened
|
//! Emitted when a file needs to be opened
|
||||||
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
|
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
|
||||||
@ -229,9 +238,22 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget
|
|||||||
//! Connections changed in the browser
|
//! Connections changed in the browser
|
||||||
void connectionsChanged();
|
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:
|
private:
|
||||||
|
|
||||||
QgsBrowserWidget *mWidget = nullptr;
|
QgsBrowserWidget *mWidget = nullptr;
|
||||||
|
QDialogButtonBox *mButtonBox = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSBROWSERDOCKWIDGET_H
|
#endif // QGSBROWSERDOCKWIDGET_H
|
||||||
|
@ -67,6 +67,12 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsBrowserGuiModel *brow
|
|||||||
connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgsDataSourceManagerDialog::openFile );
|
connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgsDataSourceManagerDialog::openFile );
|
||||||
connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgsDataSourceManagerDialog::connectionsChanged );
|
connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgsDataSourceManagerDialog::connectionsChanged );
|
||||||
connect( this, &QgsDataSourceManagerDialog::updateProjectHome, mBrowserWidget->browserWidget(), &QgsBrowserWidget::updateProjectHome );
|
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
|
// Add registered source select dialogs
|
||||||
const QList<QgsSourceSelectProvider *> sourceSelectProviders = QgsGui::sourceSelectProviderRegistry()->providers( );
|
const QList<QgsSourceSelectProvider *> sourceSelectProviders = QgsGui::sourceSelectProviderRegistry()->providers( );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user