27
27
#include < QMessageBox>
28
28
#include < QPainter>
29
29
#include < QProgressDialog>
30
+ #include < QSettings>
30
31
#include < QSvgRenderer>
31
32
32
33
QgsComposerPictureWidget::QgsComposerPictureWidget ( QgsComposerPicture* picture ): QWidget(), mPicture( picture )
@@ -180,11 +181,24 @@ void QgsComposerPictureWidget::on_mAddDirectoryButton_clicked()
180
181
181
182
// and add icons to the preview
182
183
addDirectoryToPreview ( directory );
184
+
185
+ // update the image directory list in the settings
186
+ QSettings s;
187
+ QStringList userDirList = s.value ( " /Composer/PictureWidgetDirectories" ).toStringList ();
188
+ if ( !userDirList.contains ( directory ) )
189
+ {
190
+ userDirList.append ( directory );
191
+ }
192
+ s.setValue ( " /Composer/PictureWidgetDirectories" , userDirList );
183
193
}
184
194
185
195
void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked ()
186
196
{
187
197
QString directoryToRemove = mSearchDirectoriesComboBox ->currentText ();
198
+ if ( directoryToRemove.isEmpty () )
199
+ {
200
+ return ;
201
+ }
188
202
mSearchDirectoriesComboBox ->removeItem ( mSearchDirectoriesComboBox ->currentIndex () );
189
203
190
204
// remove entries from back to front (to have the indices of existing items constant)
@@ -196,6 +210,12 @@ void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked()
196
210
delete ( mPreviewListWidget ->takeItem ( i ) );
197
211
}
198
212
}
213
+
214
+ // update the image directory list in the settings
215
+ QSettings s;
216
+ QStringList userDirList = s.value ( " /Composer/PictureWidgetDirectories" ).toStringList ();
217
+ userDirList.removeOne ( directoryToRemove );
218
+ s.setValue ( " /Composer/PictureWidgetDirectories" , userDirList );
199
219
}
200
220
201
221
void QgsComposerPictureWidget::on_mRotationFromComposerMapCheckBox_stateChanged ( int state )
@@ -463,6 +483,16 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
463
483
}
464
484
}
465
485
}
486
+
487
+ // include additional user-defined directories for images
488
+ QSettings s;
489
+ QStringList userDirList = s.value ( " /Composer/PictureWidgetDirectories" ).toStringList ();
490
+ QStringList::const_iterator userDirIt = userDirList.constBegin ();
491
+ for ( ; userDirIt != userDirList.constEnd (); ++userDirIt )
492
+ {
493
+ addDirectoryToPreview ( *userDirIt );
494
+ mSearchDirectoriesComboBox ->addItem ( *userDirIt );
495
+ }
466
496
}
467
497
468
498
bool QgsComposerPictureWidget::testSvgFile ( const QString& filename ) const
0 commit comments