aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-10-11 20:51:56 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-10-11 20:51:56 -0400
commitf649d4976e64cfdf9b32022d55bfd08f39d00a8f (patch)
tree0678b4028230aaab341ad9d1cf6976b89931cffb
parentUpdate lumina-checkpass with 2 additional options: (diff)
downloadlumina-f649d4976e64cfdf9b32022d55bfd08f39d00a8f.tar.gz
lumina-f649d4976e64cfdf9b32022d55bfd08f39d00a8f.tar.bz2
lumina-f649d4976e64cfdf9b32022d55bfd08f39d00a8f.zip
Added framework to play video when the mouse is put over them. Breaks
picture and video preview for lumina-fileinfo currently
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.cpp61
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.h30
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.pri8
-rw-r--r--src-qt5/core/libLumina/LVideoSurface.cpp23
-rw-r--r--src-qt5/core/libLumina/LVideoSurface.h11
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp39
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.h3
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro2
8 files changed, 123 insertions, 54 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp
new file mode 100644
index 00000000..20b2cad4
--- /dev/null
+++ b/src-qt5/core/libLumina/LVideoLabel.cpp
@@ -0,0 +1,61 @@
+#include "LVideoLabel.h"
+
+LVideoLabel::LVideoLabel(QString file, bool video) : QLabel(){
+ this->setScaledContents(true);
+ if(video) {
+ mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
+ thumbnail = QPixmap();
+ entered = false;
+ surface = new LVideoSurface(this);
+ mediaPlayer->setVideoOutput(surface);
+ mediaPlayer->setMedia(QUrl("file://" + file));
+ mediaPlayer->setPlaybackRate(3);
+ mediaPlayer->setMuted(true);
+ mediaPlayer->play();
+ mediaPlayer->pause();
+ this->connect(surface, SIGNAL(frameReceived(QPixmap)), this, SLOT(stopVideo(QPixmap)));
+ this->connect(mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration(QMediaPlayer::MediaStatus)));
+ this->connect(this, SIGNAL(rollOver()), surface, SLOT(switchRollOver()));
+ }else{
+ thumbnail = QPixmap(file);
+ this->setPixmap(thumbnail);
+ }
+}
+
+LVideoLabel::~LVideoLabel() {
+ mediaPlayer->deleteLater();
+ surface->deleteLater();
+}
+
+void LVideoLabel::stopVideo(QPixmap pix) {
+ if(!entered) {
+ if(thumbnail.isNull())
+ thumbnail = QPixmap(pix.scaledToHeight(64));
+ this->setPixmap(thumbnail);
+ mediaPlayer->pause();
+ }else {
+ this->setPixmap(QPixmap(pix.scaledToHeight(64)));
+ }
+}
+
+void LVideoLabel::setDuration(QMediaPlayer::MediaStatus status) {
+ if(status == QMediaPlayer::BufferedMedia) {
+ mediaPlayer->setPosition(mediaPlayer->duration() / 2);
+ mediaPlayer->play();
+ }
+}
+
+void LVideoLabel::enterEvent(QEvent *event) {
+ entered=true;
+ emit rollOver();
+ mediaPlayer->setPosition(0);
+ mediaPlayer->play();
+ QLabel::enterEvent(event);
+}
+
+void LVideoLabel::leaveEvent(QEvent *event) {
+ entered=false;
+ mediaPlayer->setPosition(mediaPlayer->duration() / 2);
+ emit rollOver();
+ QLabel::leaveEvent(event);
+}
diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h
new file mode 100644
index 00000000..fd293200
--- /dev/null
+++ b/src-qt5/core/libLumina/LVideoLabel.h
@@ -0,0 +1,30 @@
+#ifndef LVIDEOLABEL_H
+#define LVIDEOLABEL_H
+
+#include <QLabel>
+#include <QMediaPlayer>
+#include "LVideoSurface.h"
+
+//class LVideoSurface;
+
+class LVideoLabel : public QLabel {
+ Q_OBJECT
+ public:
+ LVideoLabel(QString, bool);
+ ~LVideoLabel();
+ protected:
+ void enterEvent(QEvent*);
+ void leaveEvent(QEvent*);
+ signals:
+ void rollOver();
+ public slots:
+ void stopVideo(QPixmap);
+ void setDuration(QMediaPlayer::MediaStatus);
+ private:
+ QMediaPlayer *mediaPlayer;
+ LVideoSurface *surface;
+ QVideoWidget *videoPlayer;
+ QPixmap thumbnail;
+ bool entered;
+};
+#endif
diff --git a/src-qt5/core/libLumina/LVideoLabel.pri b/src-qt5/core/libLumina/LVideoLabel.pri
new file mode 100644
index 00000000..f609df08
--- /dev/null
+++ b/src-qt5/core/libLumina/LVideoLabel.pri
@@ -0,0 +1,8 @@
+QT *= multimedia
+
+HEADERS *= $${PWD}/LVideoLabel.h
+SOURCES *= $${PWD}/LVideoLabel.cpp
+
+INCLUDEPATH *= ${PWD}
+
+include(LVideoSurface.pri)
diff --git a/src-qt5/core/libLumina/LVideoSurface.cpp b/src-qt5/core/libLumina/LVideoSurface.cpp
index bd6b2c95..e3e87667 100644
--- a/src-qt5/core/libLumina/LVideoSurface.cpp
+++ b/src-qt5/core/libLumina/LVideoSurface.cpp
@@ -3,10 +3,12 @@
LVideoSurface::LVideoSurface(QObject *parent) : QAbstractVideoSurface(parent) {
frameImage = QPixmap();
+ entered = false;
}
bool LVideoSurface::present(const QVideoFrame &frame) {
- if(!frameImage.isNull()) {
+ //qDebug() << surfaceFormat().pixelFormat() << frame.pixelFormat() << surfaceFormat().frameSize() << frame.size();
+ if(!frameImage.isNull() && !entered) {
emit frameReceived(frameImage);
return true;
}
@@ -15,9 +17,10 @@ bool LVideoSurface::present(const QVideoFrame &frame) {
//qDebug() << "Recording Frame" << frame.pixelFormat();
QVideoFrame icon(frame);
icon.map(QAbstractVideoBuffer::ReadOnly);
+ //qDebug() << icon.width() << icon.height();
QImage img(icon.bits(), icon.width(), icon.height(), icon.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat()));
- if(frameImage.isNull())
+ if((frameImage.isNull() && !entered) or entered)
frameImage = QPixmap::fromImage(img.copy(img.rect()));
icon.unmap();
@@ -33,26 +36,22 @@ QList<QVideoFrame::PixelFormat> LVideoSurface::supportedPixelFormats(QAbstractVi
<< QVideoFrame::Format_RGB565 << QVideoFrame::Format_RGB555 << QVideoFrame::Format_BGRA32 << QVideoFrame::Format_BGR32;
}
-/*bool VideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const {
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
-
- return imageFormat != QImage::Format_Invalid && !size.isEmpty() && format.handleType() == QAbstractVideoBuffer::NoHandle;
+void LVideoSurface::stop() {
+ QAbstractVideoSurface::stop();
}
-void VideoSurface::stop() {
- QAbstractVideoSurface::stop();
+void LVideoSurface::switchRollOver() {
+ entered = !entered;
}
-bool VideoSurface::start(const QVideoSurfaceFormat &format) {
+bool LVideoSurface::start(const QVideoSurfaceFormat &format) {
const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
const QSize size = format.frameSize();
if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
- this->imageFormat = imageFormat;
QAbstractVideoSurface::start(format);
return true;
} else {
return false;
}
-}*/
+}
diff --git a/src-qt5/core/libLumina/LVideoSurface.h b/src-qt5/core/libLumina/LVideoSurface.h
index 42a140d9..7a3dcaad 100644
--- a/src-qt5/core/libLumina/LVideoSurface.h
+++ b/src-qt5/core/libLumina/LVideoSurface.h
@@ -1,3 +1,6 @@
+#ifndef LVIDEOSURFACE_H
+#define LVIDEOSURFACE_H
+
#include <QAbstractVideoSurface>
#include <QVideoSurfaceFormat>
#include <QPixmap>
@@ -10,12 +13,14 @@ class LVideoSurface : public QAbstractVideoSurface {
LVideoSurface(QObject *parent=0);
virtual bool present(const QVideoFrame&);
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const;
- /*virtual QList<QVidebool isFormatSupported(const QVideoSurfaceFormat &format) const;
bool start(const QVideoSurfaceFormat &format);
- void stop();*/
+ void stop();
signals:
void frameReceived(QPixmap);
+ public slots:
+ void switchRollOver();
private:
QPixmap frameImage;
- //QImage::Format imageFormat;
+ bool entered;
};
+#endif
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index 0fb736d3..4ec8fae7 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -23,20 +23,11 @@ MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){
terminate_thread = false;
UpdateIcons(); //Set all the icons in the dialog
SetupConnections();
- player = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
- surface = new LVideoSurface(this);
- qDebug() << surface->surfaceFormat();
- player->setVideoOutput(surface);
- player->setMuted(true);
- connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration(QMediaPlayer::MediaStatus)));
- connect(surface, SIGNAL(frameReceived(QPixmap)), this, SLOT(stopVideo(QPixmap)));
INFO = 0;
}
MainUI::~MainUI(){
terminate_thread = true;
- surface->deleteLater();
- player->deleteLater();
this->close();
}
@@ -91,20 +82,10 @@ void MainUI::LoadFile(QString path, QString type){
ui->label_file_type->setText(ftype);
//Now load the icon for the file
if(INFO->isImage()){
- //qDebug() << "Set Image:";
- QPixmap pix(INFO->absoluteFilePath());
- ui->label_file_icon->setPixmap( pix.scaledToHeight(64) );
- ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
- //qDebug() << " - done with image";
+ ui->label_file_icon = new LVideoLabel(INFO->absoluteFilePath(), false);
+ //ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
}else if(INFO->isVideo()){
- timer.start();
- QMediaResource video = QMediaResource(QUrl("file://"+INFO->absoluteFilePath()));
- video.setResolution(64,64);
- player->setMedia(video);
- //player->setMedia(QUrl("file://"+INFO->absoluteFilePath()));
- player->play();
- player->pause();
- //Pixmap set when video is loaded in stopVideo
+ ui->label_file_icon = new LVideoLabel(INFO->absoluteFilePath(), true);
}else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
@@ -315,20 +296,6 @@ void MainUI::getXdgCommand(QString prev){
xdgvaluechanged();
}
-void MainUI::stopVideo(QPixmap img) {
- ui->label_file_icon->setPixmap( img.scaledToHeight(64) );
- player->pause();
- qDebug() << timer.elapsed();
- qDebug() << player->media().canonicalResource().resolution();
-}
-
-void MainUI::setDuration(QMediaPlayer::MediaStatus status) {
- if(status == QMediaPlayer::BufferedMedia) {
- player->setPosition(player->duration() / 2);
- player->play();
- }
-}
-
void MainUI::on_tool_xdg_getDir_clicked(){
//Find a directory
QString dir = ui->line_xdg_wdir->text();
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
index 3bc85aae..8cac813c 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
@@ -17,6 +17,7 @@
#include <QMediaPlayer>
#include <LuminaXDG.h>
#include <LVideoSurface.h>
+#include <LVideoLabel.h>
#include <QElapsedTimer>
namespace Ui{ class MainUI;
@@ -56,8 +57,6 @@ private slots:
//UI Buttons
void on_push_close_clicked();
void on_push_save_clicked();
- void stopVideo(QPixmap);
- void setDuration(QMediaPlayer::MediaStatus);
void getXdgCommand(QString prev = "");
//void on_tool_xdg_getCommand_clicked(QString prev = "");
void on_tool_xdg_getDir_clicked();
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro
index b53d8cba..14345f50 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro
+++ b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro
@@ -13,7 +13,7 @@ target.path = $${L_BINDIR}
include(../../core/libLumina/LUtils.pri) #includes LUtils
include(../../core/libLumina/LuminaXDG.pri)
#include(../../core/libLumina/LuminaSingleApplication.pri)
-include(../../core/libLumina/LVideoSurface.pri)
+include(../../core/libLumina/LVideoLabel.pri)
include(../../core/libLumina/LuminaThemes.pri)
SOURCES += main.cpp\
bgstack15