diff --git a/python/gui/auto_generated/qgsfeatureselectiondlg.sip.in b/python/gui/auto_generated/qgsfeatureselectiondlg.sip.in index 342cef348f3..f59827949dc 100644 --- a/python/gui/auto_generated/qgsfeatureselectiondlg.sip.in +++ b/python/gui/auto_generated/qgsfeatureselectiondlg.sip.in @@ -48,6 +48,13 @@ Set the selected features :param ids: The feature ids to select %End + protected: + + virtual void showEvent( QShowEvent *event ); + +%Docstring +Make sure the dialog does not grow too much +%End }; /************************************************************************ diff --git a/src/gui/qgsfeatureselectiondlg.cpp b/src/gui/qgsfeatureselectiondlg.cpp index dc9689ddf89..d63ad3e452c 100644 --- a/src/gui/qgsfeatureselectiondlg.cpp +++ b/src/gui/qgsfeatureselectiondlg.cpp @@ -20,6 +20,7 @@ #include "qgsfeaturerequest.h" #include "qgsattributeeditorcontext.h" +#include QgsFeatureSelectionDlg::QgsFeatureSelectionDlg( QgsVectorLayer *vl, QgsAttributeEditorContext &context, QWidget *parent ) : QDialog( parent ) @@ -45,4 +46,30 @@ void QgsFeatureSelectionDlg::setSelectedFeatures( const QgsFeatureIds &ids ) mFeatureSelection->setSelectedFeatures( ids ); } +void QgsFeatureSelectionDlg::showEvent( QShowEvent *event ) +{ + + QWindow *mainWindow = nullptr; + for ( const auto &w : QgsApplication::instance()->topLevelWindows() ) + { + if ( w->objectName() == QStringLiteral( "QgisAppWindow" ) ) + { + mainWindow = w; + break; + } + } + + if ( mainWindow ) + { + QSize margins( size() - scrollAreaWidgetContents->size() ); + QSize innerWinSize( mainWindow->width(), mainWindow->height() ); + setMaximumSize( innerWinSize ); + QSize minSize( scrollAreaWidgetContents->sizeHint() ); + setMinimumSize( std::min( minSize.width() + margins.width( ), innerWinSize.width() ), + std::min( minSize.height() + margins.width( ), innerWinSize.height() ) ); + } + + QDialog::showEvent( event ); +} + diff --git a/src/gui/qgsfeatureselectiondlg.h b/src/gui/qgsfeatureselectiondlg.h index 4fc8aeba47e..55cca3fb9a7 100644 --- a/src/gui/qgsfeatureselectiondlg.h +++ b/src/gui/qgsfeatureselectiondlg.h @@ -69,6 +69,12 @@ class GUI_EXPORT QgsFeatureSelectionDlg : public QDialog, private Ui::QgsFeature private: QgsGenericFeatureSelectionManager *mFeatureSelection = nullptr; QgsVectorLayer *mVectorLayer = nullptr; + + // QWidget interface + protected: + + //! Make sure the dialog does not grow too much + void showEvent( QShowEvent *event ) override; }; #endif // QGSFEATURESELECTIONDLG_H diff --git a/src/ui/qgsfeatureselectiondlg.ui b/src/ui/qgsfeatureselectiondlg.ui index 38e8ce5818f..28bd145857d 100644 --- a/src/ui/qgsfeatureselectiondlg.ui +++ b/src/ui/qgsfeatureselectiondlg.ui @@ -15,9 +15,28 @@ - - - + + + true + + + + + 0 + 0 + 448 + 444 + + + + + + + + + + +