Skip to content

Commit 34f3d50

Browse files
committed
Fix missing SVG previews for existing composer picture item
- Previews now load when picture is first selected and its properties are shown (unless already loaded) - NOTE: the loading of SVGs per QListWidget per picture should be replaced with a model/view per composer, or something cached - Combobox no longer over-expands width of dock widget when it contains long paths
1 parent 0141acd commit 34f3d50

File tree

3 files changed

+52
-19
lines changed

3 files changed

+52
-19
lines changed

src/app/composer/qgscomposerpicturewidget.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture
3939
mainLayout->addWidget( itemPropertiesWidget );
4040

4141
setGuiElementValues();
42+
mPreviewsLoadingLabel->hide();
4243

4344
mPreviewListWidget->setIconSize( QSize( 30, 30 ) );
4445

@@ -487,5 +488,20 @@ void QgsComposerPictureWidget::showEvent( QShowEvent * event )
487488
{
488489
Q_UNUSED( event );
489490
refreshMapComboBox();
491+
492+
if ( mPreviewListWidget->count() == 0 )
493+
{
494+
mPreviewListWidget->hide();
495+
mPreviewsLoadingLabel->show();
496+
addStandardDirectoriesToPreview();
497+
mPreviewsLoadingLabel->hide();
498+
mPreviewListWidget->show();
499+
}
500+
}
501+
502+
void QgsComposerPictureWidget::resizeEvent( QResizeEvent * event )
503+
{
504+
Q_UNUSED( event );
505+
mSearchDirectoriesComboBox->setMinimumWidth( mPreviewListWidget->sizeHint().width() );
490506
}
491507

src/app/composer/qgscomposerpicturewidget.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class QgsComposerPictureWidget: public QWidget, private Ui::QgsComposerPictureWi
4848

4949
protected:
5050
void showEvent( QShowEvent * event );
51+
void resizeEvent( QResizeEvent * event );
5152

5253
private slots:
5354
/**Sets the GUI elements to the values of mPicture*/

src/ui/qgscomposerpicturewidgetbase.ui

+35-19
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,19 @@
6868
<property name="collapsed" stdset="0">
6969
<bool>false</bool>
7070
</property>
71-
<layout class="QFormLayout" name="formLayout_2">
72-
<property name="fieldGrowthPolicy">
73-
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
74-
</property>
75-
<property name="labelAlignment">
76-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
77-
</property>
78-
<item row="1" column="0">
79-
<widget class="QLabel" name="label">
80-
<property name="text">
81-
<string>Path</string>
82-
</property>
83-
<property name="buddy">
84-
<cstring>mPictureLineEdit</cstring>
85-
</property>
86-
</widget>
87-
</item>
88-
<item row="1" column="1">
71+
<layout class="QVBoxLayout" name="verticalLayout_3">
72+
<item>
8973
<layout class="QHBoxLayout" name="horizontalLayout_2">
74+
<item>
75+
<widget class="QLabel" name="label">
76+
<property name="text">
77+
<string>Path</string>
78+
</property>
79+
<property name="buddy">
80+
<cstring>mPictureLineEdit</cstring>
81+
</property>
82+
</widget>
83+
</item>
9084
<item>
9185
<widget class="QLineEdit" name="mPictureLineEdit"/>
9286
</item>
@@ -132,6 +126,24 @@
132126
<bool>false</bool>
133127
</property>
134128
<layout class="QVBoxLayout" name="verticalLayout">
129+
<item>
130+
<widget class="QLabel" name="mPreviewsLoadingLabel">
131+
<property name="font">
132+
<font>
133+
<italic>true</italic>
134+
</font>
135+
</property>
136+
<property name="styleSheet">
137+
<string notr="true">color: rgb(19, 133, 54);</string>
138+
</property>
139+
<property name="text">
140+
<string>Loading SVG previews...</string>
141+
</property>
142+
<property name="alignment">
143+
<set>Qt::AlignCenter</set>
144+
</property>
145+
</widget>
146+
</item>
135147
<item>
136148
<widget class="QListWidget" name="mPreviewListWidget">
137149
<property name="showDropIndicator" stdset="0">
@@ -167,7 +179,11 @@
167179
</widget>
168180
</item>
169181
<item>
170-
<widget class="QComboBox" name="mSearchDirectoriesComboBox"/>
182+
<widget class="QComboBox" name="mSearchDirectoriesComboBox">
183+
<property name="sizeAdjustPolicy">
184+
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
185+
</property>
186+
</widget>
171187
</item>
172188
<item>
173189
<layout class="QHBoxLayout" name="horizontalLayout">

0 commit comments

Comments
 (0)