Skip to content

Commit c8dd587

Browse files
committed
Show composer picture preview icons on demand
1 parent d6cb997 commit c8dd587

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/app/composer/qgscomposerpicturewidget.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <QSettings>
3131
#include <QSvgRenderer>
3232

33-
QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture ): QWidget(), mPicture( picture )
33+
QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture ): QWidget(), mPicture( picture ), mPreviewInitialized( false )
3434
{
3535
setupUi( this );
3636

@@ -44,8 +44,8 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture
4444

4545
mPreviewListWidget->setIconSize( QSize( 30, 30 ) );
4646

47-
//add preview icons
48-
addStandardDirectoriesToPreview();
47+
//add preview icons on demand in showEvent()
48+
4949
connect( mPicture, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
5050
connect( mPicture, SIGNAL( rotationChanged( double ) ), this, SLOT( setGuiElementValues() ) );
5151
}
@@ -263,6 +263,11 @@ void QgsComposerPictureWidget::on_mRotationFromComposerMapCheckBox_stateChanged(
263263
void QgsComposerPictureWidget::showEvent( QShowEvent * event )
264264
{
265265
refreshMapComboBox();
266+
if ( !mPreviewInitialized )
267+
{
268+
addStandardDirectoriesToPreview();
269+
mPreviewInitialized = true;
270+
}
266271
QWidget::showEvent( event );
267272
}
268273

src/app/composer/qgscomposerpicturewidget.h

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class QgsComposerPictureWidget: public QWidget, private Ui::QgsComposerPictureWi
5454

5555
private:
5656
QgsComposerPicture* mPicture;
57+
bool mPreviewInitialized;
58+
5759
/**Add the icons of a directory to the preview. Returns 0 in case of success*/
5860
int addDirectoryToPreview( const QString& path );
5961
/**Add the icons of the standard directories to the preview*/

0 commit comments

Comments
 (0)