Skip to content

Commit

Permalink
correctly save and restore last used dir when saving/loagin color map…
Browse files Browse the repository at this point in the history
… for singleband images (fix #12390)
  • Loading branch information
alexbruy committed Jan 18, 2016
1 parent aa417a1 commit 20bf738
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
Expand Up @@ -409,7 +409,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromFileButton_clicked()
bool importError = false;
QString badLines;
QSettings settings;
QString lastDir = settings.value( "lastRasterFileFilterDir", QDir::homePath() ).toString();
QString lastDir = settings.value( "lastColorMapDir", QDir::homePath() ).toString();
QString fileName = QFileDialog::getOpenFileName( this, tr( "Open file" ), lastDir, tr( "Textfile (*.txt)" ) );
QFile inputFile( fileName );
if ( inputFile.open( QFile::ReadOnly ) )
Expand Down Expand Up @@ -478,6 +478,9 @@ void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromFileButton_clicked()
}
populateColormapTreeWidget( colorRampItems );

QFileInfo fileInfo( fileName );
settings.setValue( "lastColorMapDir", fileInfo.absoluteDir().absolutePath() );

if ( importError )
{
QMessageBox::warning( this, tr( "Import Error" ), tr( "The following lines contained errors\n\n" ) + badLines );
Expand All @@ -492,7 +495,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromFileButton_clicked()
void QgsSingleBandPseudoColorRendererWidget::on_mExportToFileButton_clicked()
{
QSettings settings;
QString lastDir = settings.value( "lastRasterFileFilterDir", QDir::homePath() ).toString();
QString lastDir = settings.value( "lastColorMapDir", QDir::homePath() ).toString();
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save file" ), lastDir, tr( "Textfile (*.txt)" ) );
if ( !fileName.isEmpty() )
{
Expand Down Expand Up @@ -544,6 +547,9 @@ void QgsSingleBandPseudoColorRendererWidget::on_mExportToFileButton_clicked()
}
outputStream.flush();
outputFile.close();

QFileInfo fileInfo( fileName );
settings.setValue( "lastColorMapDir", fileInfo.absoluteDir().absolutePath() );
}
else
{
Expand Down

0 comments on commit 20bf738

Please sign in to comment.