aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-10-16 21:00:07 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-10-16 21:00:07 -0400
commitcd928a79ff4bf6da55689bc100168355ec962b50 (patch)
tree0c06d52e780936d1fc9bc29ead53876837b94133 /src-qt5/desktop-utils
parentClean up the session file-init routine. (diff)
downloadlumina-cd928a79ff4bf6da55689bc100168355ec962b50.tar.gz
lumina-cd928a79ff4bf6da55689bc100168355ec962b50.tar.bz2
lumina-cd928a79ff4bf6da55689bc100168355ec962b50.zip
Updated how video thumbnails are loaded. Now cached to stop crash when
resizing.
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp12
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp77
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h7
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h1
-rw-r--r--src-qt5/desktop-utils/lumina-fm/lumina-fm.pro3
5 files changed, 29 insertions, 71 deletions
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index 4ec8fae7..58ef8cbd 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -80,12 +80,17 @@ void MainUI::LoadFile(QString path, QString type){
else{ ftype = INFO->suffix().toUpper(); }
if(INFO->isHidden()){ ftype = QString(tr("Hidden %1")).arg(type); }
ui->label_file_type->setText(ftype);
+
//Now load the icon for the file
if(INFO->isImage()){
- 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)" );
+ 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)" );
}else if(INFO->isVideo()){
- ui->label_file_icon = new LVideoLabel(INFO->absoluteFilePath(), true);
+ ui->label_file_icon->hide();
+ LVideoLabel *mediaLabel = new LVideoLabel(INFO->absoluteFilePath(), ui->tab_file);
+ mediaLabel->setShrinkPixmap(true);
+ ui->formLayout->replaceWidget(ui->label_file_icon, mediaLabel);
}else{
ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
@@ -101,6 +106,7 @@ void MainUI::LoadFile(QString path, QString type){
ui->tabWidget->removeTab( ui->tabWidget->indexOf(ui->tab_file) );
}
}
+
//Now load the special XDG desktop info
qDebug() << "Check XDG Info:" << type;
//qDebug() << INFO->isDesktopFile() << type;
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index 4665ccc4..d829fff0 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -68,8 +68,6 @@ void Browser::loadItem(QString info, Browser *obj){
pix = pix.scaled(256,256, Qt::KeepAspectRatio);
}
}
- }else if(videoFormats.contains(info.section(".",-1).toLower()) ){
- videoList.push_back(info);
}
//qDebug() << " - done with item:" << info;
obj->emit threadDone(info, pix);
@@ -79,7 +77,6 @@ QIcon* Browser::loadIcon(QString icon){
if(!mimeIcons.contains(icon)){
mimeIcons.insert(icon, LXDG::findIcon(icon, "unknown"));
}
-
return &mimeIcons[icon];
}
@@ -102,72 +99,28 @@ 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) {
- static int received = 0;
- //qDebug() << "grabbing frame" << received+1;
- *ico = pix/*.scaledToHeight(64)*/;
- if(++received == videoList.size()) {
- emit frameChanged();
- received = 0;
- }
-}
-
void Browser::futureFinished(QString name, QImage icon){
//Note: this will be called once for every item that loads
+ //Haven't added the extra files in a directory fix, but that should be easy to do
+ //Try to load a file with multiple videos and lots of other stuff before any other directory. It crashes for some reason
+ qDebug() << name << "here";
QIcon *ico = new QIcon();
LFileInfo *info = new LFileInfo(name);
if(!icon.isNull() && showThumbs){
QPixmap pix = QPixmap::fromImage(icon);
ico->addPixmap(pix);
- }
- if(ico->isNull()){
- if(videoFormats.contains(name.section(".",-1).toLower())) {
- QElapsedTimer loadingTime;
- //qDebug() << videoList;
- //videoList.add(name);
- //qDebug() << "Loading Video for" << name;
- //qDebug() << "VIDEO" << info;
- QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
- //qDebug() << " - created player" << 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);
- QMediaResource video = QMediaResource(QUrl("file://"+info->absoluteFilePath()));
- video.setResolution(QSize(64, 64));
- player->setMedia(video);
- //player->setMedia(QUrl("file://"+info->absoluteFilePath()));
- player->play();
- player->pause();
-
- //qDebug() << "Started loop";
- loadingTime.start();
- QTimer timeout;
- timeout.setSingleShot(true);
- timeout.setInterval(5000);
- QEventLoop loop;
- connect(this, SIGNAL(frameChanged()), &loop, SLOT(quit()), Qt::DirectConnection);
- connect(&timeout, SIGNAL(timeout()), &loop, SLOT(quit()));
- loop.exec();
- //qDebug() << "Exited loop";
-
- qDebug() << loadingTime.elapsed();
- delete player;
- delete surface;
- }else {
- ico = loadIcon(info->iconfile());
+ }else if(videoFormats.contains(name.section(".",-1).toLower())) {
+ if(videoImages.find(name) == videoImages.end()) {
+ LVideoLabel *mediaLabel = new LVideoLabel(name);
+ while(mediaLabel->pixmap()->isNull()) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); }
+ ico->addPixmap(*(mediaLabel->pixmap()));
+ videoImages.insert(name, *mediaLabel->pixmap());
+ delete mediaLabel;
+ }else{
+ ico->addPixmap(videoImages[name]);
}
+ }else{
+ ico = loadIcon(info->iconfile());
}
this->emit itemDataAvailable( *ico, info);
//qDebug() << " -- done:" << name;
@@ -176,12 +129,12 @@ void Browser::futureFinished(QString name, QImage icon){
// PUBLIC SLOTS
void Browser::loadDirectory(QString dir, bool force){
if(force){ lastcheck = QDateTime(); } //reset check time to force reloads
- videoList.clear();
if(dir.isEmpty()){ dir = currentDir; } //reload current directory
if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded
//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();
oldFiles.clear();
lastcheck = QDateTime(); //null time
emit clearItems();
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
index 3254db54..0f4a0abe 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.h
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -17,6 +17,7 @@
#include <QMediaPlayer>
#include <LVideoSurface.h>
+#include <LVideoLabel.h>
#include <LuminaXDG.h>
/*class FileItem{
public:
@@ -46,7 +47,7 @@ private:
QString currentDir;
QDateTime lastcheck;
QFileSystemWatcher *watcher;
- QList<QString> videoList;
+ QMap<QString, QPixmap> videoImages;
bool showHidden, showThumbs;
QStringList imageFormats, videoFormats, oldFiles;
QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons
@@ -57,8 +58,6 @@ 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(QPixmap, QIcon*);
- void stopVideo(QMediaPlayer*, QMediaPlayer::MediaStatus);
void futureFinished(QString, QImage);
public slots:
@@ -75,8 +74,6 @@ signals:
//Internal signal for the alternate threads
void threadDone(QString, QImage);
-
- void frameChanged();
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
index a9e58bf3..02fd910d 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -86,6 +86,7 @@ signals:
void contextMenuRequested();
void DataDropped(QString, QStringList);
void hasFocus(QString); //ID output
+ void stopLoop();
//Internal signal
void dirChange(QString, bool); //current dir path, force
diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
index 6cb4a537..e27dad25 100644
--- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
+++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
@@ -15,7 +15,8 @@ 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)
+#include(../../core/libLumina/LVideoSurface.pri)
+include(../../core/libLumina/LVideoLabel.pri)
SOURCES += main.cpp \
MainUI.cpp \
bgstack15