@@ -31,7 +31,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
31
31
QgsOptionsDialogBase( QStringLiteral( " Data Source Manager" ), parent, fl ),
32
32
ui( new Ui::QgsDataSourceManagerDialog ),
33
33
mMapCanvas( mapCanvas ),
34
- mPreviousCurrentRow ( -1 )
34
+ mPreviousRow ( -1 )
35
35
{
36
36
37
37
ui->setupUi ( this );
@@ -57,21 +57,20 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
57
57
connect ( ovl, &QgsOpenVectorLayerDialog::addVectorLayers, this , &QgsDataSourceManagerDialog::vectorLayersAdded );
58
58
59
59
// RASTER (forward to app)
60
+ // Note: the tricky solution here will not last long: the browser button is really the
61
+ // first that will disappear because its functionality can be replaced completely
62
+ // right now by the browser
60
63
ui->mOptionsStackedWidget ->addWidget ( new QWidget () );
61
64
QListWidgetItem *rasterItem = new QListWidgetItem ( tr ( " Raster" ), ui->mOptionsListWidget );
62
65
rasterItem->setIcon ( QgsApplication::getThemeIcon ( QStringLiteral ( " /mActionAddRasterLayer.svg" ) ) );
63
66
rasterItem->setToolTip ( tr ( " Open a GDAL Supported Raster Data Source" ) );
64
67
connect ( ui->mOptionsListWidget , &QListWidget::currentRowChanged, this , [ = ]( int idx )
65
68
{
66
69
Q_UNUSED ( idx );
67
- if ( rasterItem->isSelected ( ) )
70
+ if ( rasterItem->isSelected () )
68
71
{
69
72
emit addRasterLayer ();
70
- int prevPage = mPreviousCurrentRow != -1 ? mPreviousCurrentRow : 0 ;
71
- ui->mOptionsListWidget ->setCurrentRow ( prevPage );
72
- ui->mOptionsListWidget ->item ( prevPage )->setSelected ( true );
73
- ui->mOptionsListWidget ->setFocus ();
74
- setCurrentPage ( prevPage );
73
+ QTimer::singleShot ( 0 , this , &QgsDataSourceManagerDialog::setPreviousPage );
75
74
}
76
75
} );
77
76
@@ -135,7 +134,6 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
135
134
connect ( dlg, SIGNAL ( replaceVectorLayer ( QString, QString, QString, QString ) ), this , SIGNAL ( replaceSelectedVectorLayer ( QString, QString, QString, QString ) ) );
136
135
}
137
136
138
-
139
137
}
140
138
141
139
QgsDataSourceManagerDialog::~QgsDataSourceManagerDialog ()
@@ -145,11 +143,17 @@ QgsDataSourceManagerDialog::~QgsDataSourceManagerDialog()
145
143
146
144
void QgsDataSourceManagerDialog::setCurrentPage ( int index )
147
145
{
148
- mPreviousCurrentRow = ui->mOptionsStackedWidget ->currentIndex ( );
146
+ mPreviousRow = ui->mOptionsStackedWidget ->currentIndex ( );
149
147
ui->mOptionsStackedWidget ->setCurrentIndex ( index );
150
148
setWindowTitle ( tr ( " Data Source Manager | %1" ).arg ( ui->mOptionsListWidget ->currentItem ()->text ( ) ) );
151
149
}
152
150
151
+ void QgsDataSourceManagerDialog::setPreviousPage ()
152
+ {
153
+ int prevPage = mPreviousRow != -1 ? mPreviousRow : 0 ;
154
+ setCurrentPage ( prevPage );
155
+ }
156
+
153
157
void QgsDataSourceManagerDialog::rasterLayerAdded ( const QString &uri, const QString &baseName, const QString &providerKey )
154
158
{
155
159
emit ( addRasterLayer ( uri, baseName, providerKey ) );
0 commit comments