Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[editor widgets] Fix external resource's image not cleared when brows…
…ing from one feature to another
  • Loading branch information
nirvn authored and nyalldawson committed May 10, 2021
1 parent 1152322 commit 547abc8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions python/gui/auto_generated/qgspixmaplabel.sip.in
Expand Up @@ -45,9 +45,12 @@ determined from the width with the given aspect ratio.
%End

public slots:

void setPixmap( const QPixmap & );
virtual void resizeEvent( QResizeEvent * );

void clear();

};

/************************************************************************
Expand Down
1 change: 0 additions & 1 deletion src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp
Expand Up @@ -249,7 +249,6 @@ void QgsExternalResourceWidgetWrapper::updateValues( const QVariant &value, cons
mQgsWidget->setDocumentPath( value.toString() );
}
}

}

void QgsExternalResourceWidgetWrapper::setEnabled( bool enabled )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsexternalresourcewidget.cpp
Expand Up @@ -245,9 +245,13 @@ void QgsExternalResourceWidget::loadDocument( const QString &path )
ir.setAutoTransform( true );
QPixmap pm = QPixmap::fromImage( ir.read() );
if ( !pm.isNull() )
{
mPixmapLabel->setPixmap( pm );
}
else
{
mPixmapLabel->clear();
}
updateDocumentViewer();
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/gui/qgspixmaplabel.cpp
Expand Up @@ -56,6 +56,14 @@ QSize QgsPixmapLabel::sizeHint() const
void QgsPixmapLabel::resizeEvent( QResizeEvent *e )
{
QLabel::resizeEvent( e );
QLabel::setPixmap( mPixmap.scaled( this->size(),
Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
if ( !mPixmap.isNull() )
{
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
}

void QgsPixmapLabel::clear()
{
mPixmap = QPixmap();
QLabel::clear();
}
4 changes: 4 additions & 0 deletions src/gui/qgspixmaplabel.h
Expand Up @@ -50,9 +50,13 @@ class GUI_EXPORT QgsPixmapLabel : public QLabel
QSize sizeHint() const override;

public slots:

void setPixmap( const QPixmap & );
void resizeEvent( QResizeEvent * ) override;
void clear();

private:

QPixmap mPixmap;
};

Expand Down

0 comments on commit 547abc8

Please sign in to comment.