diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-25 18:27:52 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-25 18:27:52 -0400 |
commit | c52596a4d90e681b394e4c212592f26275d74bae (patch) | |
tree | 6264e2caf978da7e09d749c923821e3d8132bd10 /src-qt5/core/libLumina/LVideoLabel.cpp | |
parent | Re-enable the "Root Mode" warning at the top of lumina-fm, and setup the root... (diff) | |
parent | Fixed issues with previews and LVideoWidget sizing (diff) | |
download | lumina-c52596a4d90e681b394e4c212592f26275d74bae.tar.gz lumina-c52596a4d90e681b394e4c212592f26275d74bae.tar.bz2 lumina-c52596a4d90e681b394e4c212592f26275d74bae.zip |
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/core/libLumina/LVideoLabel.cpp')
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index af23330c..bddb1cba 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -1,11 +1,13 @@ #include "LVideoLabel.h" +#include <LuminaXDG.h> #include <QCoreApplication> -LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { +LVideoLabel::LVideoLabel(QString file, bool icons, QWidget *parent) : QLabel(parent) { thumbnail = QPixmap(); entered = false; - shrink = true; + this->icons = icons; filepath = file; + defaultThumbnail = LXDG::findIcon("unknown", "").pixmap(256,256); QTimer::singleShot(0, this, SLOT(initializeBackend()) ); } @@ -15,10 +17,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); @@ -26,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(); @@ -35,16 +34,27 @@ 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(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + icons = false; +} void LVideoLabel::stopVideo(QPixmap pix) { if(!entered) { 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)); } } @@ -78,24 +88,33 @@ 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); } //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); } |