aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp26
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.h11
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro3
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp70
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h13
-rw-r--r--src-qt5/desktop-utils/lumina-fm/lumina-fm.pro1
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp72
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h38
8 files changed, 161 insertions, 73 deletions
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index d82f09ce..40d2d544 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,11 +23,19 @@ 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);
+ 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();
}
@@ -86,6 +95,11 @@ 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 if(INFO->isVideo()){
+ player->setMedia(QUrl("file://"+INFO->absoluteFilePath()));
+ player->play();
+ player->pause();
+ //Pixmap set when video is loaded in stopVideo
}else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
@@ -296,6 +310,18 @@ void MainUI::getXdgCommand(QString prev){
xdgvaluechanged();
}
+void MainUI::stopVideo(QPixmap img) {
+ ui->label_file_icon->setPixmap( img.scaledToHeight(64) );
+ player->pause();
+}
+
+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 cbe23d9e..5ce7b01a 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,9 @@ public slots:
private:
Ui::MainUI *ui;
LFileInfo *INFO;
+ LVideoSurface *surface;
+ QMediaPlayer *player;
+ bool flag;
bool canwrite;
bool terminate_thread; //flag for terminating the GetDirSize task
@@ -51,6 +54,8 @@ 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 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..211ef8d0 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,21 +63,20 @@ 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);
}
-QIcon Browser::loadIcon(QString icon){
+QIcon* Browser::loadIcon(QString icon){
if(!mimeIcons.contains(icon)){
mimeIcons.insert(icon, LXDG::findIcon(icon, "unknown"));
}
- return mimeIcons[icon];
+ return &mimeIcons[icon];
}
@@ -92,24 +94,58 @@ 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(QPixmap pix, QIcon *ico) {
+ qDebug() << "grabbing frame";
+ *ico = 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);
+ QIcon *ico = new QIcon();
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");
+ ico->addPixmap(pix);
}
- if(ico.isNull()){
- //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype();
- ico = loadIcon(info->iconfile());
+ if(ico->isNull()){
+ if(videoFormats.contains(name.section(".",-1).toLower())) {
+ qDebug() << "Loading Video for" << name;
+ //qDebug() << "VIDEO" << info;
+ QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
+ qDebug() << " - created player";
+ LVideoSurface *surface = new LVideoSurface();
+ qDebug() << " - Create objects";
+ connect(surface, &LVideoSurface::frameReceived, this, [&] (QPixmap pix) { captureFrame(pix, ico); });
+ connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); });
+ player->setVideoOutput(surface);
+ player->setMuted(true);
+ player->setMedia(QUrl("file://"+info->absoluteFilePath()));
+ player->play();
+ player->pause();
+
+ QEventLoop loop;
+ connect(this, SIGNAL(frameChanged()), &loop, SLOT(quit()));
+ loop.exec();
+
+ ico->addPixmap(videoFrame);
+ //ico = loadIcon(info->iconfile());
+ delete player;
+ delete surface;
+ }else {
+ ico = loadIcon(info->iconfile());
+ }
}
- this->emit itemDataAvailable( ico, info);
+ 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..379753ab 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,22 +45,23 @@ public:
private:
QString currentDir;
QFileSystemWatcher *watcher;
+ QPixmap 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
- QIcon loadIcon(QString icon); //simplification for using/populating the mimIcons cache
+ QIcon* loadIcon(QString icon); //simplification for using/populating the mimIcons cache
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(QPixmap, QIcon*);
+ void stopVideo(QMediaPlayer*, QMediaPlayer::MediaStatus);
void futureFinished(QString, QImage);
public slots:
void loadDirectory(QString dir = "");
-
signals:
//Main Signals
void itemRemoved(QString item); //emitted if a file was removed from the underlying
@@ -70,6 +73,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 \
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
index ee7fb9e3..d0ecdecf 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
@@ -1,33 +1,59 @@
-#include "vidnail.h"
-vidnail::vidnail(QWidget *parent) : QMainWindow(parent), mplayer(parent, QMediaPlayer::VideoSurface){ //there is no UI, so not sure how to alter the constructor
+#ifndef VIDNAIL_H
+#define VIDNAIL_H
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
}
-vidnail::~vidnail()
-{
+class VidNail;
-vidnail::grabvideothumbnail(){
- vsurface = new QAbstractVideoSurface();
- mplayer.setVideoOutput(vsurface);
- mplayer.setMedia($file); // video file to get thumbnail of
- imageCaptured = QPixmap();
- mplayer.setPosition(2000); // time in milliseconds
- mplayer.setMuted(true); // just to make sure no sound is emited
- mplayer.play();
+struct vFrame {
+ vFrame() : *width(0), *height(0) {}
+ vFrame(int *width, int *height : width(width), height(height) {}
+ int *width;
+ int *height;
+};
- currentFrame = frame;
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
+public:
- this->imageFormat = imageFormat;
- QAbstractVideoSurface::start(format);
- QImage image( currentFrame.bits(), currentFrame.width(), currentFrame.height(), currentFrame.bytesPerLine(), imageFormat);
- imageCaptured = QPixmap::fromImage(image.copy(image.rect()));
+ QString getCodec();
+ void skipTo(int timeInSeconds);
+ void readVideoFrame();
+ void getScaledVideoFrame(int scaledSize, vFrame& vFrame);
-// Now do scaling with regular thumbnail process to make proper size
+ int getWidth();
+ int getHeight();
+ int getLength();
+
+ void makeThumbnail(const QString& videoFile, QImage &image);
+ void setThumbnailSize(int size);
+ void setPercentage(int percent);
+ void setTime(const QString& Time);
+
+ void writeVidNail(vFrame& frame, QImage& image);
+
+
+ private:
+ bool readVideoPacket();
+ bool getVideoPacket();
+ void scaleVideo(int scaledSize, int& scaledWidth, int& scaledHeight);
+ void createVFrame(AVFrame *vFrame, quint8 *frameBuffer, int width, int height);
+ void calculateDimensions(int size);
+ void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& image);
+ QString getMimeType(const QString& videoFile);
+ QString getExtension(const QString& videoFilename);
- mplayer.stop();
- vsurface.stop();
-}
+ private:
+ int videoStream;
+ AVFormatContext *inputVideoFormatContext;
+ AVCodecContext *inputvideoCodecContext;
+ AVCodec *inputVideoCodec;
+ AVStream *inputVideoStream;
+ AVFrame *inputVideoFrame;
+ quint8 *inputFrameBuffer;
+ AVPacket *videoPacket;
+#endif // VIDNAIL_H
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
index ad565749..e13894e1 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
@@ -1,25 +1,13 @@
-#ifndef VIDNAIL_H
-#define VIDNAIL_H
-
-#include <QMediaPlayer>
-#include <QtMultimediaWidgets>
-#include "videowidgetsurface.h"
-#include <QPixmap>
-#include <QAbstractVideoSurface>
-#include <QImage>
-#include <QRect>
-#include <QVideoFrame>
-
-public:
-
- void grabvideothumbnail();
-
-private:
-
- QAbstractVideoSurface *vsurface;
- QImage::Format imageFormat;
- QPixmap imageCaptured;
-
-
-#endif // VIDNAIL_H
-
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2017, q5sys
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "vidnail.h"
+
+VidNail::VidNail(QObject *parent) : QObject(parent){
+}
+
+VidNail::~VidNail(){
+}
bgstack15