diff --git a/src/app/qgsprovidersublayersdialog.cpp b/src/app/qgsprovidersublayersdialog.cpp index 58f606f403f..3d4077ccf31 100644 --- a/src/app/qgsprovidersublayersdialog.cpp +++ b/src/app/qgsprovidersublayersdialog.cpp @@ -99,14 +99,14 @@ QgsProviderSublayersDialog::QgsProviderSublayersDialog( const QString &uri, cons QgsGui::enableAutoGeometryRestore( this ); const QFileInfo fileInfo( filePath ); - mFilePath = fileInfo.isFile() && fileInfo.exists() ? filePath : QString(); - mFileName = !mFilePath.isEmpty() ? fileInfo.fileName() : QString(); + mFilePath = ( fileInfo.isFile() || fileInfo.isDir() ) && fileInfo.exists() ? filePath : QString(); + const QString fileName = !mFilePath.isEmpty() ? QgsProviderUtils::suggestLayerNameFromFilePath( mFilePath ) : QString(); - setWindowTitle( mFileName.isEmpty() ? tr( "Select Items to Add" ) : QStringLiteral( "%1 | %2" ).arg( tr( "Select Items to Add" ), mFileName ) ); + setWindowTitle( fileName.isEmpty() ? tr( "Select Items to Add" ) : QStringLiteral( "%1 | %2" ).arg( tr( "Select Items to Add" ), fileName ) ); mLblFilePath->setText( QStringLiteral( "%2" ) .arg( QUrl::fromLocalFile( mFilePath ).toString(), QDir::toNativeSeparators( QFileInfo( mFilePath ).canonicalFilePath() ) ) ); - mLblFilePath->setVisible( !mFileName.isEmpty() ); + mLblFilePath->setVisible( !mFilePath.isEmpty() ); mLblFilePath->setWordWrap( true ); mLblFilePath->setTextInteractionFlags( Qt::TextBrowserInteraction ); connect( mLblFilePath, &QLabel::linkActivated, this, [ = ]( const QString & link ) diff --git a/src/app/qgsprovidersublayersdialog.h b/src/app/qgsprovidersublayersdialog.h index 2aeb23d8a9f..4efafc4507b 100644 --- a/src/app/qgsprovidersublayersdialog.h +++ b/src/app/qgsprovidersublayersdialog.h @@ -78,7 +78,6 @@ class QgsProviderSublayersDialog : public QDialog, private Ui::QgsProviderSublay QgsProviderSublayerProxyModel *mProxyModel = nullptr; QPointer< QgsProviderSublayerTask > mTask; QString mFilePath; - QString mFileName; bool mBlockSelectionChanges = false; };