summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-04-20 13:50:17 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-04-21 06:18:30 +0000
commita24b9567929f5f38cefea77c6f2d05d7a54d7986 (patch)
tree997982578c46c4432a7be36273ea048b96f3b105 /src/libs
parentf983a4f2f447b27e233211814884b8d0d6bfc126 (diff)
AspectRatioLabel: prevent setting non-scaled pixmaps
The function signature for setting a pixmap for the label changed from 'setPixmap(const QPixmap &pixmap)' to 'setPixmapAndUrl(const QPixmap &pixmap, const QString &url)' when we enabled support for click URLs. Redefine (again) the base class QLabel::setPixmap() slot to make it harder for callers to set non-scaled pixmaps accidentally. This is still a bit bad however as it is possible to get different client-visible results by calling the method with a base class pointer. Task-number: QTIFW-2612 Change-Id: Ic79b3d71ffd5baf2108768ad3b867ddbcb33833b Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/aspectratiolabel.cpp15
-rw-r--r--src/libs/installer/aspectratiolabel.h3
2 files changed, 16 insertions, 2 deletions
diff --git a/src/libs/installer/aspectratiolabel.cpp b/src/libs/installer/aspectratiolabel.cpp
index b2cf2f7e8..7dea33cd5 100644
--- a/src/libs/installer/aspectratiolabel.cpp
+++ b/src/libs/installer/aspectratiolabel.cpp
@@ -52,7 +52,20 @@ AspectRatioLabel::AspectRatioLabel(QWidget *parent)
}
/*!
- Sets the \a pixmap shown on the label and an optional \a url. Setting a new
+ Sets the \a pixmap shown on the label. Setting a new pixmap clears
+ the previous content.
+
+ \note This redefines the non-virtual slot of the same signature from the
+ QLabel base class, which results in non polymorphic behavior when
+ called via a base class pointer.
+*/
+void AspectRatioLabel::setPixmap(const QPixmap &pixmap)
+{
+ setPixmapAndUrl(pixmap, QString());
+}
+
+/*!
+ Sets the \a pixmap shown on the label and an \a url. Setting a new
pixmap clears the previous content. When clicking the \a pixmap, \a url
is opened in a browser. If the \a url is a reference to a file, it will
be opened with a suitable application instead of a Web browser.
diff --git a/src/libs/installer/aspectratiolabel.h b/src/libs/installer/aspectratiolabel.h
index 5ce9593fa..bbe54d3a1 100644
--- a/src/libs/installer/aspectratiolabel.h
+++ b/src/libs/installer/aspectratiolabel.h
@@ -48,7 +48,8 @@ public:
QSize sizeHint() const override;
public slots:
- void setPixmapAndUrl (const QPixmap &pixmap, const QString &url = QString());
+ void setPixmap(const QPixmap &pixmap);
+ void setPixmapAndUrl (const QPixmap &pixmap, const QString &url);
void resizeEvent(QResizeEvent *event) override;
protected: