mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Make pixmap resizing label work
This commit is contained in:
parent
68e6ad4880
commit
69a2933590
@ -51,38 +51,15 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<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">
|
||||
<widget class="AspectRatioPixmapLabel" name="photoLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
@ -207,9 +184,13 @@
|
||||
<header>gui/common/AvatarWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AspectRatioPixmapLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>util/aspectratiopixmaplabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="Posted_images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
|
@ -19,6 +19,7 @@
|
||||
*******************************************************************************/
|
||||
|
||||
#include "AspectRatioPixmapLabel.h"
|
||||
#include <iostream>
|
||||
|
||||
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
|
||||
QLabel(parent)
|
||||
@ -53,4 +54,6 @@ void AspectRatioPixmapLabel::resizeEvent(QResizeEvent * e)
|
||||
{
|
||||
if(!pix.isNull())
|
||||
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,15 +29,16 @@ class AspectRatioPixmapLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AspectRatioPixmapLabel(QWidget *parent = 0);
|
||||
virtual int heightForWidth( int width ) const;
|
||||
virtual QSize sizeHint() const;
|
||||
explicit AspectRatioPixmapLabel(QWidget *parent = nullptr);
|
||||
virtual int heightForWidth( int width ) const override;
|
||||
virtual QSize sizeHint() const override;
|
||||
QPixmap scaledPixmap() const;
|
||||
public slots:
|
||||
void setPixmap ( const QPixmap & );
|
||||
void resizeEvent(QResizeEvent *);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
private:
|
||||
QPixmap pix;
|
||||
};
|
||||
|
||||
#endif // ASPECTRATIOPIXMAPLABEL_H
|
||||
#endif // ASPECTRATIOPIXMAPLABEL_H
|
||||
|
Loading…
Reference in New Issue
Block a user