Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
Executable
+48
@@ -0,0 +1,48 @@
|
||||
|
||||
|
||||
|
||||
#include "RatioAwareLabel.h"
|
||||
|
||||
|
||||
RatioAwareLabel::RatioAwareLabel(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
setScaledContents(false);
|
||||
}
|
||||
|
||||
|
||||
void RatioAwareLabel::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
scale();
|
||||
}
|
||||
|
||||
|
||||
int RatioAwareLabel::heightRatio(int width) const
|
||||
{
|
||||
if (m_pixmap.isNull())
|
||||
return height();
|
||||
return (m_pixmap.height() * width / m_pixmap.width());
|
||||
}
|
||||
|
||||
|
||||
QSize RatioAwareLabel::sizeHint() const
|
||||
{
|
||||
int w = width();
|
||||
return QSize(w, heightRatio(w));
|
||||
}
|
||||
|
||||
|
||||
void RatioAwareLabel::scale()
|
||||
{
|
||||
if (m_pixmap.isNull())
|
||||
return;
|
||||
QLabel::setPixmap(m_pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::FastTransformation));
|
||||
}
|
||||
|
||||
|
||||
void RatioAwareLabel::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QLabel::resizeEvent(event);
|
||||
scale();
|
||||
}
|
||||
Reference in new issue
Block a user