diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.cpp | 34 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.h | 5 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoWidget.cpp | 8 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoWidget.h | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 42 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 4 |
6 files changed, 60 insertions, 35 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index af23330c..bc70a292 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -1,10 +1,11 @@ #include "LVideoLabel.h" +#include <LuminaXDG.h> #include <QCoreApplication> LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { thumbnail = QPixmap(); entered = false; - shrink = true; + icons = true; filepath = file; QTimer::singleShot(0, this, SLOT(initializeBackend()) ); @@ -15,10 +16,6 @@ LVideoLabel::~LVideoLabel() { surface->deleteLater(); } -void LVideoLabel::setShrinkPixmap(bool shrink) { - this->shrink = shrink; -} - void LVideoLabel::initializeBackend(){ mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); surface = new LVideoSurface(this); @@ -35,6 +32,15 @@ void LVideoLabel::initializeBackend(){ this->connect(this, SIGNAL(rollOver()), surface, SLOT(switchRollOver())); } +void LVideoLabel::enableIcons() { + this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio)); + icons = true; +} + +void LVideoLabel::disableIcons() { + this->setPixmap(LXDG::findIcon("unknown", "").pixmap(this->size())); + icons = false; +} void LVideoLabel::stopVideo(QPixmap pix) { if(!entered) { @@ -85,17 +91,21 @@ void LVideoLabel::resizeEvent(QResizeEvent *event) { //Start playing the video from the beginning when the mouse enters the label void LVideoLabel::enterEvent(QEvent *event) { - entered=true; - emit rollOver(); - mediaPlayer->setPosition(0); - mediaPlayer->play(); + if(icons) { + entered=true; + emit rollOver(); + mediaPlayer->setPosition(0); + mediaPlayer->play(); + } QWidget::enterEvent(event); } //Stop the video and set the thumbnail back to the middle of the video when the mouse leaves the label void LVideoLabel::leaveEvent(QEvent *event) { - entered=false; - mediaPlayer->setPosition(mediaPlayer->duration() / 2); - emit rollOver(); + if(icons) { + entered=false; + mediaPlayer->setPosition(mediaPlayer->duration() / 2); + emit rollOver(); + } QWidget::leaveEvent(event); } diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h index f368c1a8..3c6b304c 100644 --- a/src-qt5/core/libLumina/LVideoLabel.h +++ b/src-qt5/core/libLumina/LVideoLabel.h @@ -12,7 +12,8 @@ class LVideoLabel : public QLabel{ public: LVideoLabel(QString, QWidget* parent=NULL); ~LVideoLabel(); - void setShrinkPixmap(bool); + void enableIcons(); + void disableIcons(); protected: void enterEvent(QEvent*); @@ -34,7 +35,7 @@ class LVideoLabel : public QLabel{ LVideoSurface *surface; QPixmap thumbnail; bool entered; - bool shrink; + bool icons; QString filepath; }; #endif diff --git a/src-qt5/core/libLumina/LVideoWidget.cpp b/src-qt5/core/libLumina/LVideoWidget.cpp index 14490484..b9660b10 100644 --- a/src-qt5/core/libLumina/LVideoWidget.cpp +++ b/src-qt5/core/libLumina/LVideoWidget.cpp @@ -26,3 +26,11 @@ LVideoWidget::~LVideoWidget() { void LVideoWidget::setIconSize(QSize iconSize) { iconLabel->setFixedSize(iconSize); } + +void LVideoWidget::enableIcons() { + iconLabel->enableIcons(); +} + +void LVideoWidget::disableIcons() { + iconLabel->disableIcons(); +} diff --git a/src-qt5/core/libLumina/LVideoWidget.h b/src-qt5/core/libLumina/LVideoWidget.h index c239a697..6743acb6 100644 --- a/src-qt5/core/libLumina/LVideoWidget.h +++ b/src-qt5/core/libLumina/LVideoWidget.h @@ -11,6 +11,8 @@ class LVideoWidget : public QWidget { LVideoWidget(QString, QSize, QWidget* parent=NULL); ~LVideoWidget(); void setIconSize(QSize); + void disableIcons(); + void enableIcons(); private: bool flag; diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index dc00e92f..0384d892 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -12,7 +12,6 @@ #include <LUtils.h> #include <LuminaOS.h> -#include <LVideoWidget.h> BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ //Setup the Widget/UI @@ -39,6 +38,7 @@ BrowserWidget::~BrowserWidget(){ } void BrowserWidget::changeDirectory(QString dir){ + qDebug() << "changing"; videoMap.clear(); if(BROWSER->currentDirectory()==dir){ return; } //already on this directory //qDebug() << "Change Directory:" << dir << historyList; @@ -111,6 +111,18 @@ bool BrowserWidget::hasHiddenFiles(){ } void BrowserWidget::showThumbnails(bool show){ + qDebug() << show << videoMap.size(); + for(QString file : videoMap.uniqueKeys()) { + QTreeWidgetItem *it = videoMap[file].first; + LVideoWidget *widget = videoMap[file].second; + if(show) { + widget->disableIcons(); + treeWidget->setItemWidget(it, 0, widget); + }else{ + widget->enableIcons(); + treeWidget->setItemWidget(it, 0, widget); + } + } BROWSER->showThumbnails(show); } @@ -128,8 +140,8 @@ void BrowserWidget::setThumbnailSize(int px){ treeWidget->setIconSize(QSize(px,px)); } for(QString file : videoMap.uniqueKeys()) { - QTreeWidgetItem *it = videoMap[file]; - LVideoWidget *widget = (LVideoWidget*)treeWidget->itemWidget(it, 0); + QTreeWidgetItem *it = videoMap[file].first; + LVideoWidget *widget = videoMap[file].second; widget->setIconSize(treeWidget->iconSize()); treeWidget->setItemWidget(it, 0, widget); } @@ -334,28 +346,18 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ treeWidget->addTopLevelItem(it); } }else{ - if(!BROWSER->showingThumbnails() && videoMap.size() !=0) { - for(QString file : videoMap.keys()) { - QTreeWidgetItem *it = videoMap[file]; - treeWidget->removeItemWidget(it, 0); - } - videoMap.clear(); - } 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() && BROWSER->showingThumbnails()){ + }else if(info->isVideo() && videoMap.find(info->absoluteFilePath()) == videoMap.end()) { it = new CQTreeWidgetItem(treeWidget); treeWidget->addTopLevelItem(it); LVideoWidget *widget = new LVideoWidget(info->absoluteFilePath(), treeWidget->iconSize(), treeWidget); - videoMap.insert(info->absoluteFilePath(), it); + videoMap.insert(info->absoluteFilePath(), QPair<QTreeWidgetItem*,LVideoWidget*>(it, widget)); treeWidget->setItemWidget(it, 0, widget); - }else if(info->isVideo() && BROWSER->showingThumbnails()){ - 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 if(info->isVideo()) { + it = videoMap[info->absoluteFilePath()].first; + LVideoWidget *widget = videoMap[info->absoluteFilePath()].second; + widget->setIconSize(treeWidget->iconSize()); }else{ it = new CQTreeWidgetItem(treeWidget); treeWidget->addTopLevelItem(it); @@ -363,7 +365,7 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ } } //Now set/update all the data - if(!info->isVideo() || (info->isVideo() && !BROWSER->showingThumbnails())) + 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) diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h index 585aaa82..f041280c 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -12,6 +12,8 @@ #include <QWidget> #include <QThread> +#include <LVideoWidget.h> + #include "Browser.h" #include "widgets/DDListWidgets.h" @@ -23,7 +25,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; + QMap<QString,QPair<QTreeWidgetItem*, LVideoWidget*>> videoMap; bool freshload; //The drag and drop brower widgets |