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 17, 2015
1 parent 2e97ceb commit 44fec0e
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
Expand Up @@ -5022,6 +5022,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
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 44fec0e

Please sign in to comment.