Skip to content
Permalink
Browse files

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 59d182d582919a7e448d7370adfecf9cdc038da6
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/app/qgisapp.cpp
@@ -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 );
}

@@ -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;
@@ -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 )

0 comments on commit 59d182d

Please sign in to comment.
You can’t perform that action at this time.