Resize not-focused tabs for datasource and options dlgs

Moved logic into base class. I did not find any other
suclass affected.
This commit is contained in:
Alessandro Pasotti 2019-09-13 12:38:48 +02:00
parent 4f9e4f121a
commit 81985a9ca4
5 changed files with 35 additions and 13 deletions

View File

@ -64,6 +64,15 @@ Restore the base ui.
Sometimes useful to do at end of subclass's constructor.
:param title: the window title (it does not need to be defined if previously given to initOptionsBase();
%End
void resizeAlltabs( int index );
%Docstring
Resizes all tabs when the dialog is resized
:param index: current tab index
.. versionadded:: 3.10
%End
bool iconOnly();

View File

@ -1648,19 +1648,7 @@ void QgsVectorLayerProperties::optionsStackedWidget_CurrentChanged( int index )
mMetadataFilled = true;
}
// Adjust size (GH issue #31449)
// make the stacked widget size to the current page only
for ( int i = 0; i < mOptStackedWidget->count(); ++i )
{
// determine the vertical size policy
QSizePolicy::Policy policy = QSizePolicy::Ignored;
if ( i == index )
policy = QSizePolicy::MinimumExpanding;
// update the size policy
mOptStackedWidget->widget( i )->setSizePolicy( policy, policy );
}
mOptStackedWidget->adjustSize();
resizeAlltabs( index );
}
void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled( bool checked )

View File

@ -104,6 +104,7 @@ void QgsDataSourceManagerDialog::setCurrentPage( int index )
mPreviousRow = ui->mOptionsStackedWidget->currentIndex();
ui->mOptionsStackedWidget->setCurrentIndex( index );
setWindowTitle( tr( "Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text() ) );
resizeAlltabs( index );
}
void QgsDataSourceManagerDialog::setPreviousPage()

View File

@ -205,6 +205,23 @@ void QgsOptionsDialogBase::restoreOptionsBaseUi( const QString &title )
mOptListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );
}
void QgsOptionsDialogBase::resizeAlltabs( int index )
{
// Adjust size (GH issue #31449)
// make the stacked widget size to the current page only
for ( int i = 0; i < mOptStackedWidget->count(); ++i )
{
// determine the vertical size policy
QSizePolicy::Policy policy = QSizePolicy::Ignored;
if ( i == index )
policy = QSizePolicy::MinimumExpanding;
// update the size policy
mOptStackedWidget->widget( i )->setSizePolicy( policy, policy );
}
mOptStackedWidget->adjustSize();
}
void QgsOptionsDialogBase::searchText( const QString &text )
{
const int minimumTextLength = 3;

View File

@ -91,6 +91,13 @@ class GUI_EXPORT QgsOptionsDialogBase : public QDialog
*/
void restoreOptionsBaseUi( const QString &title = QString() );
/**
* Resizes all tabs when the dialog is resized
* \param index current tab index
* \since QGIS 3.10
*/
void resizeAlltabs( int index );
/**
* Determine if the options list is in icon only mode
*/