Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
store last used QLR path and re-use it when opening another QLR file (f…
…ix #27392)
  • Loading branch information
alexbruy committed May 6, 2020
1 parent 1e0b890 commit 59d182d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -5209,10 +5209,16 @@ void QgisApp::about()

void QgisApp::addLayerDefinition()
{
QString path = QFileDialog::getOpenFileName( this, QStringLiteral( "Add Layer Definition File" ), QDir::home().path(), QStringLiteral( "*.qlr" ) );
QgsSettings settings;
QString lastUsedDir = settings.value( QStringLiteral( "UI/lastQLRDir" ), QDir::homePath() ).toString();

QString path = QFileDialog::getOpenFileName( this, QStringLiteral( "Add Layer Definition File" ), lastUsedDir, QStringLiteral( "*.qlr" ) );
if ( path.isEmpty() )
return;

QFileInfo fi( path );
settings.setValue( QStringLiteral( "UI/lastQLRDir" ), fi.path() );

openLayerDefinition( path );
}

Expand Down Expand Up @@ -8680,7 +8686,10 @@ void QgisApp::makeMemoryLayerPermanent( QgsVectorLayer *layer )

void QgisApp::saveAsLayerDefinition()
{
QString path = QFileDialog::getSaveFileName( this, QStringLiteral( "Save as Layer Definition File" ), QDir::home().path(), QStringLiteral( "*.qlr" ) );
QgsSettings settings;
QString lastUsedDir = settings.value( QStringLiteral( "UI/lastQLRDir" ), QDir::homePath() ).toString();

QString path = QFileDialog::getSaveFileName( this, QStringLiteral( "Save as Layer Definition File" ), lastUsedDir, QStringLiteral( "*.qlr" ) );
QgsDebugMsg( path );
if ( path.isEmpty() )
return;
Expand All @@ -8691,6 +8700,9 @@ void QgisApp::saveAsLayerDefinition()
{
visibleMessageBar()->pushMessage( tr( "Error saving layer definition file" ), errorMessage, Qgis::Warning );
}

QFileInfo fi( path );
settings.setValue( QStringLiteral( "UI/lastQLRDir" ), fi.path() );
}

void QgisApp::saveStyleFile( QgsMapLayer *layer )
Expand Down

0 comments on commit 59d182d

Please sign in to comment.