Skip to content
Permalink
Browse files
[composer] Remember last used folder for picture and marker dialogs (fix
  • Loading branch information
nyalldawson committed Jun 23, 2014
1 parent a2c13ec commit c1e3c7ad4ab3d3a71a3f68fc65adee724752ab28
Showing with 42 additions and 5 deletions.
  1. +35 −5 src/app/composer/qgscomposerarrowwidget.cpp
  2. +7 −0 src/app/composer/qgscomposerpicturewidget.cpp
@@ -219,10 +219,25 @@ void QgsComposerArrowWidget::on_mEndMarkerLineEdit_textChanged( const QString &

void QgsComposerArrowWidget::on_mStartMarkerToolButton_clicked()
{
QFileInfo fi( mStartMarkerLineEdit->text() );
QString svgFileName = QFileDialog::getOpenFileName( 0, tr( "Start marker svg file" ), fi.dir().absolutePath() );
QSettings s;
QString openDir;

if ( !mStartMarkerLineEdit->text().isEmpty() )
{
QFileInfo fi( mStartMarkerLineEdit->text() );
openDir = fi.dir().absolutePath();
}

if ( openDir.isEmpty() )
{
openDir = s.value( "/UI/lastComposerMarkerDir", "" ).toString();
}

QString svgFileName = QFileDialog::getOpenFileName( 0, tr( "Start marker svg file" ), openDir );
if ( !svgFileName.isNull() )
{
QFileInfo fileInfo( svgFileName );
s.setValue( "/UI/lastComposerMarkerDir", fileInfo.absolutePath() );
mArrow->beginCommand( tr( "Arrow start marker" ) );
mStartMarkerLineEdit->setText( svgFileName );
mArrow->endCommand();
@@ -231,12 +246,27 @@ void QgsComposerArrowWidget::on_mStartMarkerToolButton_clicked()

void QgsComposerArrowWidget::on_mEndMarkerToolButton_clicked()
{
QFileInfo fi( mEndMarkerLineEdit->text() );
QString svgFileName = QFileDialog::getOpenFileName( 0, tr( "End marker svg file" ), fi.dir().absolutePath() );
QSettings s;
QString openDir;

if ( !mEndMarkerLineEdit->text().isEmpty() )
{
QFileInfo fi( mEndMarkerLineEdit->text() );
openDir = fi.dir().absolutePath();
}

if ( openDir.isEmpty() )
{
openDir = s.value( "/UI/lastComposerMarkerDir", "" ).toString();
}

QString svgFileName = QFileDialog::getOpenFileName( 0, tr( "End marker svg file" ), openDir );
if ( !svgFileName.isNull() )
{
QFileInfo fileInfo( svgFileName );
s.setValue( "/UI/lastComposerMarkerDir", fileInfo.absolutePath() );
mArrow->beginCommand( tr( "Arrow end marker" ) );
mEndMarkerLineEdit ->setText( svgFileName );
mEndMarkerLineEdit->setText( svgFileName );
mArrow->endCommand();
}
}
@@ -63,6 +63,7 @@ QgsComposerPictureWidget::~QgsComposerPictureWidget()

void QgsComposerPictureWidget::on_mPictureBrowseButton_clicked()
{
QSettings s;
QString openDir;
QString lineEditText = mPictureLineEdit->text();
if ( !lineEditText.isEmpty() )
@@ -71,6 +72,10 @@ void QgsComposerPictureWidget::on_mPictureBrowseButton_clicked()
openDir = openDirFileInfo.path();
}

if ( openDir.isEmpty() )
{
openDir = s.value( "/UI/lastComposerPictureDir", "" ).toString();
}

//show file dialog
QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select svg or image file" ), openDir );
@@ -87,6 +92,8 @@ void QgsComposerPictureWidget::on_mPictureBrowseButton_clicked()
return;
}

s.setValue( "/UI/lastComposerPictureDir", fileInfo.absolutePath() );

mPictureLineEdit->blockSignals( true );
mPictureLineEdit->setText( filePath );
mPictureLineEdit->blockSignals( false );

0 comments on commit c1e3c7a

Please sign in to comment.