Skip to content

Commit

Permalink
Remember last used directory for raster save as dialog (fix #6950)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 16, 2015
1 parent 897eb47 commit e151e2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5038,6 +5038,9 @@ void QgisApp::saveAsRasterFile()
this );
if ( d.exec() == QDialog::Accepted )
{
QSettings settings;
settings.setValue( "/UI/lastRasterFileDir", QFileInfo( d.outputFileName() ).absolutePath() );

QgsRasterFileWriter fileWriter( d.outputFileName() );
if ( d.tileMode() )
{
Expand Down
8 changes: 6 additions & 2 deletions src/gui/qgsrasterlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ QgsRasterLayerSaveAsDialog::~QgsRasterLayerSaveAsDialog()
void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked()
{
QString fileName;

QSettings settings;
QString dirName = mSaveAsLineEdit->text().isEmpty() ? settings.value( "/UI/lastRasterFileDir", "." ).toString() : mSaveAsLineEdit->text();

if ( mTileModeCheckBox->isChecked() )
{
while ( true )
{
// TODO: would not it be better to select .vrt file instead of directory?
fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ) );
fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ), dirName );
//fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "VRT" ) + " (*.vrt *.VRT)" );

if ( fileName.isEmpty() ) break; // canceled
Expand Down Expand Up @@ -194,7 +198,7 @@ void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked()
}
else
{
fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "GeoTIFF" ) + " (*.tif *.tiff *.TIF *.TIFF)" );
fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), dirName, tr( "GeoTIFF" ) + " (*.tif *.tiff *.TIF *.TIFF)" );
}

if ( !fileName.isEmpty() )
Expand Down

0 comments on commit e151e2f

Please sign in to comment.