Skip to content
Permalink
Browse files

correctly save and restore last used dir when saving/loagin color map…

… for singleband images (fix #12390)
  • Loading branch information
alexbruy committed Jan 18, 2016
1 parent aa417a1 commit 20bf738f1cc2e40ad4f0e6541d4fbee8fbcf7c2e
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
@@ -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 ) )
@@ -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 );
@@ -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() )
{
@@ -544,6 +547,9 @@ void QgsSingleBandPseudoColorRendererWidget::on_mExportToFileButton_clicked()
}
outputStream.flush();
outputFile.close();

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

0 comments on commit 20bf738

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