aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
authorq5sys <jt@ixsystems.com>2017-10-03 15:26:14 -0400
committerq5sys <jt@ixsystems.com>2017-10-03 15:26:14 -0400
commit31bcc76104f1b2bb6b392835d216e56dadc3a9c4 (patch)
treed994a0885195a8cf139c6304e8aceb5dcdd6a611 /src-qt5/desktop-utils
parentRevert "rework video thumbnail code" (diff)
parentAdded experimental video thumbnails in lumina-fm and fileinfo (diff)
downloadlumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.tar.gz
lumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.tar.bz2
lumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.zip
Merge branch 'master' of http://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp25
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.h9
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro3
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp62
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h10
-rw-r--r--src-qt5/desktop-utils/lumina-fm/lumina-fm.pro1
6 files changed, 91 insertions, 19 deletions
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index d82f09ce..4d695ab4 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -8,6 +8,7 @@
#include "MainUI.h"
#include "ui_MainUI.h"
+#include <QVideoFrame>
#include <QFileDialog>
#include <QMessageBox>
@@ -22,12 +23,17 @@ MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){
terminate_thread = false;
UpdateIcons(); //Set all the icons in the dialog
SetupConnections();
+ player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
+ surface = new LVideoSurface();
+ player->setVideoOutput(surface);
INFO = 0;
}
MainUI::~MainUI(){
terminate_thread = true;
this->close();
+ delete surface;
+ delete player;
}
//=============
@@ -86,7 +92,15 @@ void MainUI::LoadFile(QString path, QString type){
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";
- }else{
+ }/*else if(INFO->isVideo()){
+ player->setMedia(QUrl("file://"+INFO->absoluteFilePath()));
+ player->play();
+ player->setPosition(player->duration() / 2);
+ connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(stopVideo(QImage)));
+ //Pixmap set when video is loaded in stopVideo
+ //ui->label_file_icon->setPixmap( QPixmap::fromImage(surface->frameImage()).scaledToHeight(64) );
+ //ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
+ }*/else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
//Now verify the tab is available in the widget
@@ -103,7 +117,7 @@ void MainUI::LoadFile(QString path, QString type){
}
//Now load the special XDG desktop info
qDebug() << "Check XDG Info:" << type;
- //qDebug() << INFO->isDesktopFile() << type;
+ qDebug() << INFO->isDesktopFile() << type;
if(INFO->isDesktopFile() || !type.isEmpty()){
if(INFO->XDG()->type == XDGDesktop::APP){
@@ -296,6 +310,13 @@ void MainUI::getXdgCommand(QString prev){
xdgvaluechanged();
}
+/*void MainUI::stopVideo(QImage img) {
+ static bool flag = true;
+ if(flag) { player->setPosition(player->duration() / 2); flag = false;}
+ player->pause();
+ ui->label_file_icon->setPixmap( QPixmap::fromImage( img.scaledToHeight(64) ));
+}*/
+
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 cbe23d9e..e1f37425 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h
@@ -14,11 +14,11 @@
#define _LUMINA_FILE_INFO_MAIN_UI_H
#include <QDialog>
-
+#include <QMediaPlayer>
#include <LuminaXDG.h>
+#include <LVideoSurface.h>
-namespace Ui{
- class MainUI;
+namespace Ui{ class MainUI;
};
class MainUI : public QDialog{
@@ -35,6 +35,8 @@ public slots:
private:
Ui::MainUI *ui;
LFileInfo *INFO;
+ LVideoSurface *surface;
+ QMediaPlayer *player;
bool canwrite;
bool terminate_thread; //flag for terminating the GetDirSize task
@@ -51,6 +53,7 @@ private slots:
//UI Buttons
void on_push_close_clicked();
void on_push_save_clicked();
+ //void stopVideo(QImage);
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 bbaf842e..b53d8cba 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro
+++ b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro
@@ -1,7 +1,7 @@
include("$${PWD}/../../OS-detect.pri")
QT += core gui
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets concurrent
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets concurrent multimedia
TARGET = lumina-fileinfo
@@ -13,6 +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/LuminaThemes.pri)
SOURCES += main.cpp\
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index f2bdc178..e57b6aed 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -16,10 +16,13 @@
Browser::Browser(QObject *parent) : QObject(parent){
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) );
- connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
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
}
@@ -60,12 +63,11 @@ void Browser::loadItem(QString info, Browser *obj){
file.close();
pix.loadFromData(bytes);
if(pix.width() > 256 || pix.height() > 256 ){
- pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ pix = pix.scaled(256,256, Qt::KeepAspectRatio);
}
}
}
-
- //qDebug() << " - done with item:" << info;
+ qDebug() << " - done with item:" << info;
obj->emit threadDone(info, pix);
}
@@ -92,22 +94,60 @@ void Browser::dirChanged(QString dir){
else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); }
}
+/*void Browser::stopVideo(QMediaPlayer *player, QMediaPlayer::MediaStatus status) {
+ qDebug() << status;
+ if(status == QMediaPlayer::BufferedMedia) {
+ qDebug() << "stoppingVideo" << player << player->currentMedia().canonicalUrl();
+ player->setPosition(player->duration() / 2);
+ player->pause();
+ }
+}
+
+void Browser::captureFrame(QImage pix) {
+ qDebug() << "grabbing frame";
+ videoFrame = pix.scaledToHeight(64);
+ emit frameChanged();
+}*/
+
void Browser::futureFinished(QString name, QImage icon){
//Note: this will be called once for every item that loads
QIcon ico;
- //LFileInfo info(name);
LFileInfo *info = new LFileInfo(name);
if(!icon.isNull() && showThumbs){
- //qDebug() << " -- Data:";
QPixmap pix = QPixmap::fromImage(icon);
ico.addPixmap(pix);
- //}else if(info->isDir()){
- //qDebug() << " -- Folder:";
- //ico = loadIcon("folder");
}
if(ico.isNull()){
- //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype();
- ico = loadIcon(info->iconfile());
+ if(videoFormats.contains(name.section(".",-1).toLower())) {
+ qDebug() << "Loading Video for" << name;
+ qDebug() << "VIDEO" << info;
+ //qDebug() << obj << this << QThread::currentThread();
+ QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
+ qDebug() << " - created player";
+ LVideoSurface *surface = new LVideoSurface();
+ qDebug() << " - Create objects";
+ //connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(captureFrame(QImage)));
+ //connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); });
+ player->setVideoOutput(surface);
+ player->setVolume(0);
+ player->setMedia(QUrl("file://"+info->absoluteFilePath()));
+ player->play();
+ qDebug() << "Wait for buffer";
+ while(player->mediaStatus()!=QMediaPlayer::BufferedMedia){
+ QCoreApplication::processEvents();
+ }
+ player->pause();
+ player->setPosition(player->duration()/2);
+ while(!surface->frameReady()) {
+ QCoreApplication::processEvents();
+ }
+ qDebug() << "Load Frame";
+ ico.addPixmap(QPixmap::fromImage(surface->currentFrame()));
+ delete player;
+ delete surface;
+ }else {
+ ico = loadIcon(info->iconfile());
+ }
}
this->emit itemDataAvailable( ico, info);
//qDebug() << " -- done:" << name;
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
index 94f6ba3f..7ccb5199 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.h
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -15,6 +15,8 @@
#include <QIcon>
//#include <QFutureWatcher>
+#include <QMediaPlayer>
+#include <LVideoSurface.h>
#include <LuminaXDG.h>
/*class FileItem{
public:
@@ -43,8 +45,9 @@ public:
private:
QString currentDir;
QFileSystemWatcher *watcher;
+ //QImage videoFrame;
bool showHidden, showThumbs;
- QStringList imageFormats, oldFiles;
+ QStringList imageFormats, videoFormats, oldFiles;
QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons
void loadItem(QString info, Browser *obj); //this is the main loader class - multiple instances each run in a separate thread
@@ -53,7 +56,8 @@ private:
private slots:
void fileChanged(QString); //tied into the watcher - for file change notifications
void dirChanged(QString); // tied into the watcher - for new/removed files in the current dir
-
+ //void captureFrame(QImage);
+ //void stopVideo(QMediaPlayer*, QMediaPlayer::MediaStatus);
void futureFinished(QString, QImage);
public slots:
@@ -70,6 +74,8 @@ signals:
//Internal signal for the alternate threads
void threadDone(QString, QImage);
+
+ //void frameChanged();
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
index 6c340e14..6cb4a537 100644
--- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
+++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
@@ -15,6 +15,7 @@ include(../../core/libLumina/LuminaXDG.pri)
include(../../core/libLumina/LuminaSingleApplication.pri)
include(../../core/libLumina/LuminaThemes.pri)
include(../../core/libLumina/ExternalProcess.pri)
+include(../../core/libLumina/LVideoSurface.pri)
SOURCES += main.cpp \
MainUI.cpp \
bgstack15