Show composer picture preview icons on demand

This commit is contained in:
Marco Hugentobler 2011-05-31 12:03:45 +02:00
parent d6cb997c8e
commit c8dd58791f
2 changed files with 10 additions and 3 deletions

View File

@ -30,7 +30,7 @@
#include <QSettings>
#include <QSvgRenderer>
QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture ): QWidget(), mPicture( picture )
QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture ): QWidget(), mPicture( picture ), mPreviewInitialized( false )
{
setupUi( this );
@ -44,8 +44,8 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture
mPreviewListWidget->setIconSize( QSize( 30, 30 ) );
//add preview icons
addStandardDirectoriesToPreview();
//add preview icons on demand in showEvent()
connect( mPicture, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
connect( mPicture, SIGNAL( rotationChanged( double ) ), this, SLOT( setGuiElementValues() ) );
}
@ -263,6 +263,11 @@ void QgsComposerPictureWidget::on_mRotationFromComposerMapCheckBox_stateChanged(
void QgsComposerPictureWidget::showEvent( QShowEvent * event )
{
refreshMapComboBox();
if ( !mPreviewInitialized )
{
addStandardDirectoriesToPreview();
mPreviewInitialized = true;
}
QWidget::showEvent( event );
}

View File

@ -54,6 +54,8 @@ class QgsComposerPictureWidget: public QWidget, private Ui::QgsComposerPictureWi
private:
QgsComposerPicture* mPicture;
bool mPreviewInitialized;
/**Add the icons of a directory to the preview. Returns 0 in case of success*/
int addDirectoryToPreview( const QString& path );
/**Add the icons of the standard directories to the preview*/