aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
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
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')
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.cpp25
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.h11
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.pri2
-rw-r--r--src-qt5/core/libLumina/LVideoWidget.cpp28
-rw-r--r--src-qt5/core/libLumina/LVideoWidget.h21
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp7
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp31
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h1
9 files changed, 106 insertions, 22 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
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index 58ef8cbd..fb55ad99 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -89,7 +89,7 @@ void MainUI::LoadFile(QString path, QString type){
}else if(INFO->isVideo()){
ui->label_file_icon->hide();
LVideoLabel *mediaLabel = new LVideoLabel(INFO->absoluteFilePath(), ui->tab_file);
- mediaLabel->setShrinkPixmap(true);
+ mediaLabel->setFixedSize(64,64);
ui->formLayout->replaceWidget(ui->label_file_icon, mediaLabel);
}else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index a68b8580..10c2567b 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -20,7 +20,6 @@ Browser::Browser(QObject *parent) : QObject(parent){
showHidden = false;
showThumbs = false;
imageFormats = LUtils::imageExtensions(false); //lowercase suffixes
- videoFormats = LUtils::videoExtensions(); //lowercase suffixes
//connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(captureFrame(QImage)));
//connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); });
connect(this, SIGNAL(threadDone(QString, QImage)), this, SLOT(futureFinished(QString, QImage))); //will always be between different threads
@@ -109,7 +108,7 @@ void Browser::futureFinished(QString name, QImage icon){
if(!icon.isNull() && showThumbs){
QPixmap pix = QPixmap::fromImage(icon);
ico->addPixmap(pix);
- }else if(info->isVideo() && showThumbs) {
+ /*}else if(info->isVideo() && showThumbs) {
if(videoImages.find(name) == videoImages.end()) {
LVideoLabel *mediaLabel = new LVideoLabel(name);
while(mediaLabel->pixmap()->isNull()) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); }
@@ -118,7 +117,7 @@ void Browser::futureFinished(QString name, QImage icon){
delete mediaLabel;
}else{
ico->addPixmap(videoImages[name]);
- }
+ }*/
}else{
ico = loadIcon(info->iconfile());
}
@@ -134,7 +133,7 @@ void Browser::loadDirectory(QString dir, bool force){
//qDebug() << "Load Directory" << dir;
bool dirupdate = true;
if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir)
- videoImages.clear();
+ //videoImages.clear();
oldFiles.clear();
lastcheck = QDateTime(); //null time
emit clearItems();
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
index d2c07648..a7b07b47 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
@@ -12,6 +12,7 @@
#include <LUtils.h>
#include <LuminaOS.h>
+#include <LVideoWidget.h>
BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
//Setup the Widget/UI
@@ -38,6 +39,7 @@ BrowserWidget::~BrowserWidget(){
}
void BrowserWidget::changeDirectory(QString dir){
+ videoMap.clear();
if(BROWSER->currentDirectory()==dir){ return; } //already on this directory
//qDebug() << "Change Directory:" << dir << historyList;
@@ -125,6 +127,12 @@ void BrowserWidget::setThumbnailSize(int px){
larger = treeWidget->iconSize().height() < px;
treeWidget->setIconSize(QSize(px,px));
}
+ for(QString file : videoMap.uniqueKeys()) {
+ QTreeWidgetItem *it = videoMap[file];
+ LVideoWidget *widget = (LVideoWidget*)treeWidget->itemWidget(it, 0);
+ widget->setIconSize(treeWidget->iconSize());
+ treeWidget->setItemWidget(it, 0, widget);
+ }
//qDebug() << "Changing Icon Size:" << px << larger;
if(BROWSER->currentDirectory().isEmpty() || !larger ){ return; } //don't need to reload icons unless the new size is larger
emit dirChange("", larger);
@@ -326,15 +334,30 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){
treeWidget->addTopLevelItem(it);
}
}else{
- if( ! treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).isEmpty() ){ it = treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).first(); }
- else{
+ if( ! treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).isEmpty() ) {
+ it = treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).first();
+ }else if(info->isVideo() && videoMap.find(info->absoluteFilePath()) == videoMap.end()){
it = new CQTreeWidgetItem(treeWidget);
- it->setText(0, info->fileName() ); //name (0)
treeWidget->addTopLevelItem(it);
+ LVideoWidget *widget = new LVideoWidget(info->absoluteFilePath(), treeWidget->iconSize(), treeWidget);
+ videoMap.insert(info->absoluteFilePath(), it);
+ treeWidget->setItemWidget(it, 0, widget);
+ }else if(info->isVideo()){
+ it = videoMap[info->absoluteFilePath()];
+ if(treeWidget->itemWidget(it, 0) != 0) {
+ LVideoWidget *widget = (LVideoWidget*)treeWidget->itemWidget(it, 0);
+ widget->setIconSize(treeWidget->iconSize());
+ treeWidget->setItemWidget(it, 0, widget);
+ }
+ }else{
+ it = new CQTreeWidgetItem(treeWidget);
+ treeWidget->addTopLevelItem(it);
+ it->setText(0, info->fileName() ); //name (0)
}
}
//Now set/update all the data
- it->setIcon(0, ico);
+ if(!info->isVideo())
+ it->setIcon(0, ico);
it->setText(1, info->isDir() ? "" : LUtils::BytesToDisplaySize(info->size()) ); //size (1)
it->setText(2, info->mimetype() ); //type (2)
it->setText(3, DTtoString(info->lastModified() )); //modification date (3)
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
index 02fd910d..585aaa82 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -23,6 +23,7 @@ private:
int numItems; //used for checking if all the items have loaded yet
QString ID, statustip;
QStringList date_format, historyList;
+ QMap<QString,QTreeWidgetItem*> videoMap;
bool freshload;
//The drag and drop brower widgets
bgstack15