Skip to content
Permalink
Browse files

Merge pull request #36238 from alexbruy/qlr-path

store last used QLR path and re-use it when opening another QLR (fix #27392)
  • Loading branch information
alexbruy committed May 6, 2020
2 parents 8e2a9d5 + 59d182d commit 8bb55536fd568d9b839e7032883b4180ba44e967
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/app/qgisapp.cpp
@@ -5212,10 +5212,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 );
}

@@ -8683,7 +8689,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;
@@ -8694,6 +8703,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 8bb5553

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