Commit 6b2a7698 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

fix resize behaviour and initial background of VideoRaster class

parent 2f35c2fa
......@@ -28,8 +28,10 @@ public:
protected:
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *);
public:
QImage image;
QString title;
};
......@@ -43,6 +45,12 @@ QSize dtkVisualizationViewVideoRasterPrivate::sizeHint(void) const
return QSize(100, 100);
}
void dtkVisualizationViewVideoRasterPrivate::resizeEvent(QResizeEvent *event)
{
QLabel::resizeEvent(event);
this->setPixmap(QPixmap::fromImage(this->image.scaled(event->size().width(), event->size().height(), Qt::KeepAspectRatio)));
}
void dtkVisualizationViewVideoRasterPrivate::paintEvent(QPaintEvent *event)
{
QLabel::paintEvent(event);
......@@ -74,8 +82,15 @@ dtkVisualizationViewVideoRaster::dtkVisualizationViewVideoRaster(QWidget *parent
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(d);
QImage image(this->width(), this->height(), QImage::Format_RGBA8888);
image.fill(Qt::black);
QSize size = this->size();
QColor color = Qt::black;
if (parent) {
size = parent->size();
color = parent->palette().color(QWidget::backgroundRole());
}
QImage image(size.width(), size.height(), QImage::Format_RGBA8888);
image.fill(color);
d->setPixmap(QPixmap::fromImage(image));
QPalette p = palette();
......@@ -105,6 +120,7 @@ void dtkVisualizationViewVideoRaster::setTitle(const QString& title)
void dtkVisualizationViewVideoRaster::setImage(const QImage& image)
{
d->image = image;
d->setPixmap(QPixmap::fromImage(image.scaled(this->width(), this->height(), Qt::KeepAspectRatio)));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment