From 76eb44f51faee92476ed509b700be9bc30be08a7 Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Wed, 25 Oct 2017 17:09:02 -0400 Subject: Fixed image previews with video thumbnails --- src-qt5/core/libLumina/LVideoLabel.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src-qt5/core/libLumina/LVideoLabel.cpp') diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index af23330c..bc70a292 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -1,10 +1,11 @@ #include "LVideoLabel.h" +#include #include LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { thumbnail = QPixmap(); entered = false; - shrink = true; + icons = true; filepath = file; QTimer::singleShot(0, this, SLOT(initializeBackend()) ); @@ -15,10 +16,6 @@ LVideoLabel::~LVideoLabel() { surface->deleteLater(); } -void LVideoLabel::setShrinkPixmap(bool shrink) { - this->shrink = shrink; -} - void LVideoLabel::initializeBackend(){ mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); surface = new LVideoSurface(this); @@ -35,6 +32,15 @@ void LVideoLabel::initializeBackend(){ this->connect(this, SIGNAL(rollOver()), surface, SLOT(switchRollOver())); } +void LVideoLabel::enableIcons() { + this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + icons = true; +} + +void LVideoLabel::disableIcons() { + this->setPixmap(LXDG::findIcon("unknown", "").pixmap(this->size())); + icons = false; +} void LVideoLabel::stopVideo(QPixmap pix) { if(!entered) { @@ -85,17 +91,21 @@ void LVideoLabel::resizeEvent(QResizeEvent *event) { //Start playing the video from the beginning when the mouse enters the label void LVideoLabel::enterEvent(QEvent *event) { - entered=true; - emit rollOver(); - mediaPlayer->setPosition(0); - mediaPlayer->play(); + if(icons) { + entered=true; + emit rollOver(); + mediaPlayer->setPosition(0); + mediaPlayer->play(); + } QWidget::enterEvent(event); } //Stop the video and set the thumbnail back to the middle of the video when the mouse leaves the label void LVideoLabel::leaveEvent(QEvent *event) { - entered=false; - mediaPlayer->setPosition(mediaPlayer->duration() / 2); - emit rollOver(); + if(icons) { + entered=false; + mediaPlayer->setPosition(mediaPlayer->duration() / 2); + emit rollOver(); + } QWidget::leaveEvent(event); } -- cgit From 1e4bb99764f6012260adb4192604a392bd62bf0a Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Wed, 25 Oct 2017 18:23:38 -0400 Subject: Fixed issues with previews and LVideoWidget sizing --- src-qt5/core/libLumina/LVideoLabel.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src-qt5/core/libLumina/LVideoLabel.cpp') diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index bc70a292..bddb1cba 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -2,11 +2,12 @@ #include #include -LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { +LVideoLabel::LVideoLabel(QString file, bool icons, QWidget *parent) : QLabel(parent) { thumbnail = QPixmap(); entered = false; - icons = true; + this->icons = icons; filepath = file; + defaultThumbnail = LXDG::findIcon("unknown", "").pixmap(256,256); QTimer::singleShot(0, this, SLOT(initializeBackend()) ); } @@ -23,6 +24,7 @@ void LVideoLabel::initializeBackend(){ mediaPlayer->setPlaybackRate(3); mediaPlayer->setMuted(true); + this->setPixmap(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); mediaPlayer->setMedia(QUrl::fromLocalFile(filepath)); mediaPlayer->play(); @@ -38,7 +40,7 @@ void LVideoLabel::enableIcons() { } void LVideoLabel::disableIcons() { - this->setPixmap(LXDG::findIcon("unknown", "").pixmap(this->size())); + this->setPixmap(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); icons = false; } @@ -47,10 +49,12 @@ void LVideoLabel::stopVideo(QPixmap pix) { emit frameReceived(pix); if(thumbnail.isNull()) thumbnail = pix; - this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + if(icons) + this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); mediaPlayer->pause(); }else { - this->setPixmap(pix.scaled(this->size(),Qt::IgnoreAspectRatio)); + if(icons) + this->setPixmap(pix.scaled(this->size(),Qt::IgnoreAspectRatio)); } } @@ -84,8 +88,13 @@ void LVideoLabel::setDuration(QMediaPlayer::MediaStatus status) { } void LVideoLabel::resizeEvent(QResizeEvent *event) { - if(!thumbnail.isNull()) //Resize the current pixmap to match the new size - this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + //Resize the current pixmap to match the new size + if(!thumbnail.isNull()){ + if(icons) + this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + else + this->setPixmap(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + } QLabel::resizeEvent(event); } -- cgit