diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.cpp | 50 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.h | 9 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.pri | 5 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaThemes.cpp | 6 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp | 12 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 77 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 7 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 3 |
9 files changed, 71 insertions, 99 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index 20b2cad4..3b2ce468 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -1,40 +1,42 @@ #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(QString file, QWidget *parent) : QLabel(parent) { + this->setScaledContents(true); + mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); + thumbnail = QPixmap(); + this->setPixmap(thumbnail); + entered = false; + surface = new LVideoSurface(this); + mediaPlayer->setVideoOutput(surface); + mediaPlayer->setPlaybackRate(3); + mediaPlayer->setMuted(true); + mediaPlayer->setMedia(QUrl("file://" + file)); + 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())); } LVideoLabel::~LVideoLabel() { mediaPlayer->deleteLater(); - surface->deleteLater(); + delete surface; +} + +void LVideoLabel::setShrinkPixmap(bool shrink) { + this->shrink = shrink; } void LVideoLabel::stopVideo(QPixmap pix) { if(!entered) { + emit frameReceived(pix); if(thumbnail.isNull()) - thumbnail = QPixmap(pix.scaledToHeight(64)); - this->setPixmap(thumbnail); + thumbnail = pix; + this->setPixmap((shrink) ? thumbnail.scaledToHeight(64) : thumbnail); mediaPlayer->pause(); }else { - this->setPixmap(QPixmap(pix.scaledToHeight(64))); + this->setPixmap((shrink) ? pix.scaledToHeight(64) : pix); } } diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h index fd293200..fa590e5a 100644 --- a/src-qt5/core/libLumina/LVideoLabel.h +++ b/src-qt5/core/libLumina/LVideoLabel.h @@ -10,21 +10,24 @@ class LVideoLabel : public QLabel { Q_OBJECT public: - LVideoLabel(QString, bool); + LVideoLabel(QString, QWidget* parent=NULL); ~LVideoLabel(); + void setShrinkPixmap(bool); + protected: void enterEvent(QEvent*); void leaveEvent(QEvent*); signals: void rollOver(); - public slots: + void frameReceived(QPixmap); + private slots: void stopVideo(QPixmap); void setDuration(QMediaPlayer::MediaStatus); private: QMediaPlayer *mediaPlayer; LVideoSurface *surface; - QVideoWidget *videoPlayer; QPixmap thumbnail; bool entered; + bool shrink; }; #endif diff --git a/src-qt5/core/libLumina/LVideoLabel.pri b/src-qt5/core/libLumina/LVideoLabel.pri index f609df08..384b3aae 100644 --- a/src-qt5/core/libLumina/LVideoLabel.pri +++ b/src-qt5/core/libLumina/LVideoLabel.pri @@ -1,8 +1,11 @@ QT *= multimedia HEADERS *= $${PWD}/LVideoLabel.h +HEADERS *= $${PWD}/LVideoSurface.h SOURCES *= $${PWD}/LVideoLabel.cpp +SOURCES *= $${PWD}/LVideoSurface.cpp INCLUDEPATH *= ${PWD} -include(LVideoSurface.pri) +#Now the other dependendies of it +#include(LUtils.pri) diff --git a/src-qt5/core/libLumina/LuminaThemes.cpp b/src-qt5/core/libLumina/LuminaThemes.cpp index f6868651..857e604b 100644 --- a/src-qt5/core/libLumina/LuminaThemes.cpp +++ b/src-qt5/core/libLumina/LuminaThemes.cpp @@ -122,6 +122,8 @@ QStringList LTHEME::availableSystemCursors(){ //returns: [name] for each item //Save a new theme/color file bool LTHEME::saveLocalTheme(QString name, QStringList contents){ + Q_UNUSED(name); + Q_UNUSED(contents); return false; //old format - do not use!! //QString localdir = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/themes/"; //if(!QFile::exists(localdir)){ QDir dir; dir.mkpath(localdir); } @@ -129,6 +131,8 @@ bool LTHEME::saveLocalTheme(QString name, QStringList contents){ } bool LTHEME::saveLocalColors(QString name, QStringList contents){ + Q_UNUSED(name); + Q_UNUSED(contents); return false; //old format - do not use!! // QString localdir = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/colors/"; //if(!QFile::exists(localdir)){ QDir dir; dir.mkpath(localdir); } @@ -182,6 +186,8 @@ QString LTHEME::currentCursor(){ //Change the current Theme/Colors/Icons bool LTHEME::setCurrentSettings(QString themepath, QString colorpath, QString iconname, QString font, QString fontsize){ + Q_UNUSED(font); + Q_UNUSED(fontsize); //QIcon::setThemeName(iconname); //Save these settings into the theme engine settings QSettings engineset("lthemeengine","lthemeengine"); 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 \ |