aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LVideoLabel.cpp
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-10-21 17:48:29 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-10-21 17:48:29 -0400
commit3a38773ce20620610e87c84c40ebfd6d2f478203 (patch)
treeae1ab2c3aaf3f1fb69aebb901ae2895cba109a07 /src-qt5/core/libLumina/LVideoLabel.cpp
parentAdd a semi-functional "VideoItemWidget" class to lumina-fm sources (not tied ... (diff)
downloadlumina-3a38773ce20620610e87c84c40ebfd6d2f478203.tar.gz
lumina-3a38773ce20620610e87c84c40ebfd6d2f478203.tar.bz2
lumina-3a38773ce20620610e87c84c40ebfd6d2f478203.zip
Finished video thumbnails and roll over playback for lumina-fm and
lumina-fileinfo
Diffstat (limited to 'src-qt5/core/libLumina/LVideoLabel.cpp')
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp
index dcc0ad58..b90cff66 100644
--- a/src-qt5/core/libLumina/LVideoLabel.cpp
+++ b/src-qt5/core/libLumina/LVideoLabel.cpp
@@ -1,15 +1,17 @@
#include "LVideoLabel.h"
-#include <QTimer>
+
LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) {
- this->setScaledContents(true);
- this->setPixmap(thumbnail); //blank pixmap by default
+ thumbnail = QPixmap();
entered = false;
+ shrink = true;
filepath = file;
+
QTimer::singleShot(0, this, SLOT(initializeBackend()) );
}
LVideoLabel::~LVideoLabel() {
-
+ mediaPlayer->deleteLater();
+ surface->deleteLater();
}
void LVideoLabel::setShrinkPixmap(bool shrink) {
@@ -22,6 +24,7 @@ void LVideoLabel::initializeBackend(){
mediaPlayer->setVideoOutput(surface);
mediaPlayer->setPlaybackRate(3);
mediaPlayer->setMuted(true);
+
mediaPlayer->setMedia(QUrl::fromLocalFile(filepath));
mediaPlayer->play();
mediaPlayer->pause();
@@ -36,10 +39,10 @@ void LVideoLabel::stopVideo(QPixmap pix) {
emit frameReceived(pix);
if(thumbnail.isNull())
thumbnail = pix;
- this->setPixmap((shrink) ? thumbnail.scaledToHeight(64) : thumbnail);
+ this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
mediaPlayer->pause();
}else {
- this->setPixmap((shrink) ? pix.scaledToHeight(64) : pix);
+ this->setPixmap(pix.scaled(this->size(),Qt::IgnoreAspectRatio));
}
}
@@ -50,17 +53,23 @@ void LVideoLabel::setDuration(QMediaPlayer::MediaStatus status) {
}
}
+void LVideoLabel::resizeEvent(QResizeEvent *event) {
+ if(!thumbnail.isNull())
+ this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ QLabel::resizeEvent(event);
+}
+
void LVideoLabel::enterEvent(QEvent *event) {
entered=true;
emit rollOver();
mediaPlayer->setPosition(0);
mediaPlayer->play();
- QLabel::enterEvent(event);
+ QWidget::enterEvent(event);
}
void LVideoLabel::leaveEvent(QEvent *event) {
entered=false;
mediaPlayer->setPosition(mediaPlayer->duration() / 2);
emit rollOver();
- QLabel::leaveEvent(event);
+ QWidget::leaveEvent(event);
}
bgstack15