mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 17:51:26 -05:00
Make pixmap resizing label work
This commit is contained in:
parent
68e6ad4880
commit
69a2933590
@ -51,38 +51,15 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="AspectRatioPixmapLabel" name="photoLabel">
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="photoLabel">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -207,9 +184,13 @@
|
|||||||
<header>gui/common/AvatarWidget.h</header>
|
<header>gui/common/AvatarWidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AspectRatioPixmapLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header>util/aspectratiopixmaplabel.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
<include location="Posted_images.qrc"/>
|
<include location="Posted_images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "AspectRatioPixmapLabel.h"
|
#include "AspectRatioPixmapLabel.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
|
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
|
||||||
QLabel(parent)
|
QLabel(parent)
|
||||||
@ -53,4 +54,6 @@ void AspectRatioPixmapLabel::resizeEvent(QResizeEvent * e)
|
|||||||
{
|
{
|
||||||
if(!pix.isNull())
|
if(!pix.isNull())
|
||||||
QLabel::setPixmap(scaledPixmap());
|
QLabel::setPixmap(scaledPixmap());
|
||||||
|
QLabel::resizeEvent(e);
|
||||||
|
//std::cout << "Information resized: " << e->oldSize().width() << 'x' << e->oldSize().height() << " to " << e->size().width() << 'x' << e->size().height() << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,14 @@ class AspectRatioPixmapLabel : public QLabel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AspectRatioPixmapLabel(QWidget *parent = 0);
|
explicit AspectRatioPixmapLabel(QWidget *parent = nullptr);
|
||||||
virtual int heightForWidth( int width ) const;
|
virtual int heightForWidth( int width ) const override;
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const override;
|
||||||
QPixmap scaledPixmap() const;
|
QPixmap scaledPixmap() const;
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmap ( const QPixmap & );
|
void setPixmap ( const QPixmap & );
|
||||||
void resizeEvent(QResizeEvent *);
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
private:
|
private:
|
||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user