Skip to content

Commit

Permalink
Merge pull request #5547 from borysiasty/stickytabs2
Browse files Browse the repository at this point in the history
Make some QgsOptionsDialogBase's slots virtual
  • Loading branch information
borysiasty committed Nov 7, 2017
2 parents 4677026 + c315eb3 commit 61a155c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 28 deletions.
16 changes: 13 additions & 3 deletions python/gui/qgsoptionsdialogbase.sip
Expand Up @@ -127,9 +127,19 @@ class QgsOptionsDialogBase : QDialog
%End

protected slots:
void updateOptionsListVerticalTabs();
void optionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_WidgetRemoved( int indx );
virtual void updateOptionsListVerticalTabs();
%Docstring
Update tabs on the splitter move
%End
virtual void optionsStackedWidget_CurrentChanged( int index );
%Docstring
Select relevant tab on current page change
%End
virtual void optionsStackedWidget_WidgetRemoved( int index );
%Docstring
Remove tab and unregister widgets on page remove
%End

void warnAboutMissingObjects();

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/app/pluginmanager/qgspluginmanager.h
Expand Up @@ -172,7 +172,7 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
void showHelp();

//! Reimplement QgsOptionsDialogBase method to prevent modifying the tab list by signals from the stacked widget
void optionsStackedWidget_CurrentChanged( int indx ) { Q_UNUSED( indx ) }
void optionsStackedWidget_CurrentChanged( int index ) override { Q_UNUSED( index ) };

//! Only show plugins from selected repository (e.g. for inspection)
void setRepositoryFilter();
Expand Down
7 changes: 4 additions & 3 deletions src/app/qgsoptions.cpp
Expand Up @@ -95,7 +95,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( mProxyTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsOptions::mProxyTypeComboBox_currentIndexChanged );
connect( mCustomVariablesChkBx, &QCheckBox::toggled, this, &QgsOptions::mCustomVariablesChkBx_toggled );
connect( mCurrentVariablesQGISChxBx, &QCheckBox::toggled, this, &QgsOptions::mCurrentVariablesQGISChxBx_toggled );
connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsOptions::mOptionsStackedWidget_currentChanged );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOptions::showHelp );

// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
Expand Down Expand Up @@ -1998,9 +1997,11 @@ void QgsOptions::clearAccessCache()
QMessageBox::information( this, tr( "Cache cleared" ), tr( "Connection authentication cache has been cleared" ) );
}

void QgsOptions::mOptionsStackedWidget_currentChanged( int indx )
void QgsOptions::optionsStackedWidget_CurrentChanged( int index )
{
Q_UNUSED( indx );
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

Q_UNUSED( index );
// load gdal driver list when gdal tab is first opened
if ( mOptionsStackedWidget->currentWidget()->objectName() == QLatin1String( "mOptionsPageGDAL" )
&& ! mLoadedGdalDriverList )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.h
Expand Up @@ -216,7 +216,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void exportScales();

//! Auto slot executed when the active page in the option section widget is changed
void mOptionsStackedWidget_currentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;

//! A scale in the list of predefined scales changed
void scaleItemChanged( QListWidgetItem *changedScaleItem );
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -122,8 +122,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv

connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsRasterLayerProperties::apply );

connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged );

// brightness/contrast controls
connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
connect( mBrightnessSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
Expand Down Expand Up @@ -1483,21 +1481,23 @@ void QgsRasterLayerProperties::setTransparencyToEdited( int row )
mTransparencyToEdited[row] = true;
}

void QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
void QgsRasterLayerProperties::optionsStackedWidget_CurrentChanged( int index )
{
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

if ( !mHistogramWidget )
return;

if ( indx == 5 )
if ( index == 5 )
{
mHistogramWidget->setActive( true );
mHistogramWidget->setActive( false );
}
else
{
mHistogramWidget->setActive( false );
}

if ( indx == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
if ( index == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
//set the metadata contents (which can be expensive)
teMetadataViewer->clear();
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.h
Expand Up @@ -79,7 +79,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
//! \brief slot executed when user wishes to export transparency values
void pbnExportTransparentPixelValues_clicked();
//! \brief auto slot executed when the active page in the main widget stack is changed
void mOptionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;
//! \brief slow executed when user wishes to import transparency values
void pbnImportTransparentPixelValues_clicked();
//! \brief slot executed when user presses "Remove Selected Row" button on the transparency page
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -122,8 +122,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
connect( this, &QDialog::accepted, this, &QgsVectorLayerProperties::apply );
connect( this, &QDialog::rejected, this, &QgsVectorLayerProperties::onCancel );

connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsVectorLayerProperties::mOptionsStackedWidget_CurrentChanged );

mContext << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope( QgsProject::instance() )
<< QgsExpressionContextUtils::atlasScope( nullptr )
Expand Down Expand Up @@ -1447,9 +1445,11 @@ void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
mMetadataFilled = false;
}

void QgsVectorLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
void QgsVectorLayerProperties::optionsStackedWidget_CurrentChanged( int index )
{
if ( indx != mOptStackedWidget->indexOf( mOptsPage_Information ) || mMetadataFilled )
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

if ( index != mOptStackedWidget->indexOf( mOptsPage_Information ) || mMetadataFilled )
return;

//set the metadata contents (which can be expensive)
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.h
Expand Up @@ -116,7 +116,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
void saveDefaultStyle_clicked();
void loadStyle_clicked();
void saveStyleAs_clicked();
void mOptionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;
void pbnUpdateExtents_clicked();

void mButtonAddJoin_clicked();
Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgsoptionsdialogbase.cpp
Expand Up @@ -356,24 +356,24 @@ void QgsOptionsDialogBase::updateOptionsListVerticalTabs()
mOptListWidget->setWordWrap( true );
}

void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( int indx )
void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( int index )
{
mOptListWidget->blockSignals( true );
mOptListWidget->setCurrentRow( indx );
mOptListWidget->setCurrentRow( index );
mOptListWidget->blockSignals( false );

updateWindowTitle();
}

void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved( int indx )
void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved( int index )
{
// will need to take item first, if widgets are set for item in future
delete mOptListWidget->item( indx );
delete mOptListWidget->item( index );

QList<QPair< QgsSearchHighlightOptionWidget *, int > >::iterator it = mRegisteredSearchWidgets.begin();
while ( it != mRegisteredSearchWidgets.end() )
{
if ( ( *it ).second == indx )
if ( ( *it ).second == index )
it = mRegisteredSearchWidgets.erase( it );
else
++it;
Expand Down
10 changes: 7 additions & 3 deletions src/gui/qgsoptionsdialogbase.h
Expand Up @@ -158,9 +158,13 @@ class GUI_EXPORT QgsOptionsDialogBase : public QDialog
void searchText( const QString &text );

protected slots:
void updateOptionsListVerticalTabs();
void optionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_WidgetRemoved( int indx );
//! Update tabs on the splitter move
virtual void updateOptionsListVerticalTabs();
//! Select relevant tab on current page change
virtual void optionsStackedWidget_CurrentChanged( int index );
//! Remove tab and unregister widgets on page remove
virtual void optionsStackedWidget_WidgetRemoved( int index );

void warnAboutMissingObjects();

protected:
Expand Down

0 comments on commit 61a155c

Please sign in to comment.