Skip to content

Commit

Permalink
[addlayerbutton] Fix order of signals when open page called
Browse files Browse the repository at this point in the history
The problem was with raster "tab" (that is not a real page
but a forwarded signal to the app), when openPage
was called before the show() call.

Moving the activation inside the unique currentPage call,
the implementation is much simpler (got rid of the lambda
with the second currentRowChanged connection).
  • Loading branch information
elpaso committed Jun 2, 2017
1 parent 463fd03 commit 25b959c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/app/qgsdatasourcemanagerdialog.cpp
Expand Up @@ -66,18 +66,8 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
QListWidgetItem *rasterItem = new QListWidgetItem( tr( "Raster" ), ui->mOptionsListWidget );
rasterItem->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) );
rasterItem->setToolTip( tr( "Open a GDAL Supported Raster Data Source" ) );
connect( ui->mOptionsListWidget, &QListWidget::currentRowChanged, this, [ = ]( int idx )
{
Q_UNUSED( idx );
if ( rasterItem->isSelected() )
{
emit addRasterLayer();
QTimer::singleShot( 0, this, &QgsDataSourceManagerDialog::setPreviousPage );
}
} );
mPageNames.append( QStringLiteral( "raster" ) );


// Add data provider dialogs
QDialog *dlg = nullptr;

Expand Down Expand Up @@ -158,6 +148,11 @@ void QgsDataSourceManagerDialog::setCurrentPage( int index )
mPreviousRow = ui->mOptionsStackedWidget->currentIndex( );
ui->mOptionsStackedWidget->setCurrentIndex( index );
setWindowTitle( tr( "Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text( ) ) );
if ( 0 <= index && index < mPageNames.size() && mPageNames.at( index ) == QStringLiteral( "raster" ) )
{
emit addRasterLayer();
QTimer::singleShot( 0, this, &QgsDataSourceManagerDialog::setPreviousPage );
}
}

void QgsDataSourceManagerDialog::setPreviousPage()
Expand Down

0 comments on commit 25b959c

Please sign in to comment.