diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-21 17:48:29 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-21 17:48:29 -0400 |
commit | 3a38773ce20620610e87c84c40ebfd6d2f478203 (patch) | |
tree | ae1ab2c3aaf3f1fb69aebb901ae2895cba109a07 /src-qt5/core | |
parent | Add a semi-functional "VideoItemWidget" class to lumina-fm sources (not tied ... (diff) | |
download | lumina-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')
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.cpp | 25 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.h | 11 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.pri | 2 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoWidget.cpp | 28 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoWidget.h | 21 |
5 files changed, 74 insertions, 13 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); } diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h index 110e3305..8c544b16 100644 --- a/src-qt5/core/libLumina/LVideoLabel.h +++ b/src-qt5/core/libLumina/LVideoLabel.h @@ -3,11 +3,11 @@ #include <QLabel> #include <QMediaPlayer> +#include <QTimer> +#include <QResizeEvent> #include "LVideoSurface.h" -//class LVideoSurface; - -class LVideoLabel : public QLabel { +class LVideoLabel : public QLabel{ Q_OBJECT public: LVideoLabel(QString, QWidget* parent=NULL); @@ -17,13 +17,14 @@ class LVideoLabel : public QLabel { protected: void enterEvent(QEvent*); void leaveEvent(QEvent*); + void resizeEvent(QResizeEvent*); signals: void rollOver(); void frameReceived(QPixmap); private slots: - void initializeBackend(); + void initializeBackend(); void stopVideo(QPixmap); void setDuration(QMediaPlayer::MediaStatus); @@ -33,6 +34,6 @@ class LVideoLabel : public QLabel { QPixmap thumbnail; bool entered; bool shrink; - QString filepath; + QString filepath; }; #endif diff --git a/src-qt5/core/libLumina/LVideoLabel.pri b/src-qt5/core/libLumina/LVideoLabel.pri index 384b3aae..06395c8d 100644 --- a/src-qt5/core/libLumina/LVideoLabel.pri +++ b/src-qt5/core/libLumina/LVideoLabel.pri @@ -2,8 +2,10 @@ QT *= multimedia HEADERS *= $${PWD}/LVideoLabel.h HEADERS *= $${PWD}/LVideoSurface.h +HEADERS *= $${PWD}/LVideoWidget.h SOURCES *= $${PWD}/LVideoLabel.cpp SOURCES *= $${PWD}/LVideoSurface.cpp +SOURCES *= $${PWD}/LVideoWidget.cpp INCLUDEPATH *= ${PWD} diff --git a/src-qt5/core/libLumina/LVideoWidget.cpp b/src-qt5/core/libLumina/LVideoWidget.cpp new file mode 100644 index 00000000..14490484 --- /dev/null +++ b/src-qt5/core/libLumina/LVideoWidget.cpp @@ -0,0 +1,28 @@ +#include "LVideoWidget.h" + +LVideoWidget::LVideoWidget(QString file, QSize iconSize, QWidget *parent) : QWidget(parent) { + flag = false; + iconLabel = new LVideoLabel(file, parent); + textLabel = new QLabel(parent); + + layout = new QHBoxLayout(this); + layout->setAlignment(Qt::AlignLeft | Qt::AlignCenter); + layout->addWidget(iconLabel); + layout->addWidget(textLabel); + layout->setStretchFactor(textLabel, 1); //make sure this always occupies all extra space + + textLabel->setText(file.section("/", -1)); + iconLabel->setFixedSize(iconSize); + iconLabel->setVisible(true); + textLabel->setVisible(true); +} + +LVideoWidget::~LVideoWidget() { + delete iconLabel; + delete textLabel; + delete layout; +} + +void LVideoWidget::setIconSize(QSize iconSize) { + iconLabel->setFixedSize(iconSize); +} diff --git a/src-qt5/core/libLumina/LVideoWidget.h b/src-qt5/core/libLumina/LVideoWidget.h new file mode 100644 index 00000000..c239a697 --- /dev/null +++ b/src-qt5/core/libLumina/LVideoWidget.h @@ -0,0 +1,21 @@ +#ifndef LVIDEOWIDGET_H +#define LVIDEOWIDGET_H + +#include "LVideoLabel.h" +#include <QHBoxLayout> +#include <QResizeEvent> + +class LVideoWidget : public QWidget { + Q_OBJECT + public: + LVideoWidget(QString, QSize, QWidget* parent=NULL); + ~LVideoWidget(); + void setIconSize(QSize); + + private: + bool flag; + LVideoLabel *iconLabel; + QLabel *textLabel; + QHBoxLayout *layout; +}; +#endif |