aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.cpp53
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.h8
-rw-r--r--src-qt5/core/libLumina/LVideoWidget.cpp20
-rw-r--r--src-qt5/core/libLumina/LVideoWidget.h5
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp44
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h4
7 files changed, 86 insertions, 50 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp
index af23330c..bddb1cba 100644
--- a/src-qt5/core/libLumina/LVideoLabel.cpp
+++ b/src-qt5/core/libLumina/LVideoLabel.cpp
@@ -1,11 +1,13 @@
#include "LVideoLabel.h"
+#include <LuminaXDG.h>
#include <QCoreApplication>
-LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) {
+LVideoLabel::LVideoLabel(QString file, bool icons, QWidget *parent) : QLabel(parent) {
thumbnail = QPixmap();
entered = false;
- shrink = true;
+ this->icons = icons;
filepath = file;
+ defaultThumbnail = LXDG::findIcon("unknown", "").pixmap(256,256);
QTimer::singleShot(0, this, SLOT(initializeBackend()) );
}
@@ -15,10 +17,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);
@@ -26,6 +24,7 @@ void LVideoLabel::initializeBackend(){
mediaPlayer->setPlaybackRate(3);
mediaPlayer->setMuted(true);
+ this->setPixmap(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
mediaPlayer->setMedia(QUrl::fromLocalFile(filepath));
mediaPlayer->play();
@@ -35,16 +34,27 @@ 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(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ icons = false;
+}
void LVideoLabel::stopVideo(QPixmap pix) {
if(!entered) {
emit frameReceived(pix);
if(thumbnail.isNull())
thumbnail = pix;
- this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ if(icons)
+ this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
mediaPlayer->pause();
}else {
- this->setPixmap(pix.scaled(this->size(),Qt::IgnoreAspectRatio));
+ if(icons)
+ this->setPixmap(pix.scaled(this->size(),Qt::IgnoreAspectRatio));
}
}
@@ -78,24 +88,33 @@ void LVideoLabel::setDuration(QMediaPlayer::MediaStatus status) {
}
void LVideoLabel::resizeEvent(QResizeEvent *event) {
- if(!thumbnail.isNull()) //Resize the current pixmap to match the new size
- this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ //Resize the current pixmap to match the new size
+ if(!thumbnail.isNull()){
+ if(icons)
+ this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ else
+ this->setPixmap(defaultThumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
+ }
QLabel::resizeEvent(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..56defb6a 100644
--- a/src-qt5/core/libLumina/LVideoLabel.h
+++ b/src-qt5/core/libLumina/LVideoLabel.h
@@ -10,9 +10,10 @@
class LVideoLabel : public QLabel{
Q_OBJECT
public:
- LVideoLabel(QString, QWidget* parent=NULL);
+ LVideoLabel(QString, bool, QWidget* parent=NULL);
~LVideoLabel();
- void setShrinkPixmap(bool);
+ void enableIcons();
+ void disableIcons();
protected:
void enterEvent(QEvent*);
@@ -33,8 +34,9 @@ class LVideoLabel : public QLabel{
QMediaPlayer *mediaPlayer;
LVideoSurface *surface;
QPixmap thumbnail;
+ QPixmap defaultThumbnail;
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..f1f74414 100644
--- a/src-qt5/core/libLumina/LVideoWidget.cpp
+++ b/src-qt5/core/libLumina/LVideoWidget.cpp
@@ -1,20 +1,22 @@
#include "LVideoWidget.h"
-LVideoWidget::LVideoWidget(QString file, QSize iconSize, QWidget *parent) : QWidget(parent) {
- flag = false;
- iconLabel = new LVideoLabel(file, parent);
+LVideoWidget::LVideoWidget(QString file, QSize iconSize, bool icons, QWidget *parent) : QWidget(parent) {
+ iconLabel = new LVideoLabel(file, icons, parent);
textLabel = new QLabel(parent);
layout = new QHBoxLayout(this);
layout->setAlignment(Qt::AlignLeft | Qt::AlignCenter);
- layout->addWidget(iconLabel);
- layout->addWidget(textLabel);
+ layout->setContentsMargins(5,5,5,5);
layout->setStretchFactor(textLabel, 1); //make sure this always occupies all extra space
textLabel->setText(file.section("/", -1));
+ iconLabel->setGeometry(QRect(QPoint(0,0), iconSize));
iconLabel->setFixedSize(iconSize);
iconLabel->setVisible(true);
textLabel->setVisible(true);
+
+ layout->addWidget(iconLabel);
+ layout->addWidget(textLabel);
}
LVideoWidget::~LVideoWidget() {
@@ -26,3 +28,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..610fd9e5 100644
--- a/src-qt5/core/libLumina/LVideoWidget.h
+++ b/src-qt5/core/libLumina/LVideoWidget.h
@@ -8,12 +8,13 @@
class LVideoWidget : public QWidget {
Q_OBJECT
public:
- LVideoWidget(QString, QSize, QWidget* parent=NULL);
+ LVideoWidget(QString, QSize, bool icons, QWidget* parent=NULL);
~LVideoWidget();
void setIconSize(QSize);
+ void disableIcons();
+ void enableIcons();
private:
- bool flag;
LVideoLabel *iconLabel;
QLabel *textLabel;
QHBoxLayout *layout;
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index fb55ad99..c712afed 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -88,7 +88,7 @@ void MainUI::LoadFile(QString path, QString type){
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->hide();
- LVideoLabel *mediaLabel = new LVideoLabel(INFO->absoluteFilePath(), ui->tab_file);
+ LVideoLabel *mediaLabel = new LVideoLabel(INFO->absoluteFilePath(), true, ui->tab_file);
mediaLabel->setFixedSize(64,64);
ui->formLayout->replaceWidget(ui->label_file_icon, mediaLabel);
}else{
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
index dc00e92f..0983a7b4 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
@@ -111,6 +110,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->enableIcons();
+ treeWidget->setItemWidget(it, 0, widget);
+ }else{
+ widget->disableIcons();
+ treeWidget->setItemWidget(it, 0, widget);
+ }
+ }
BROWSER->showThumbnails(show);
}
@@ -128,8 +139,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 +345,19 @@ 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);
+ LVideoWidget *widget = new LVideoWidget(info->absoluteFilePath(), treeWidget->iconSize(), hasThumbnails(), treeWidget);
+ videoMap.insert(info->absoluteFilePath(), QPair<QTreeWidgetItem*,LVideoWidget*>(it, widget));
+ treeWidget->setItemWidget(it, 0, widget);
+ }else if(info->isVideo()) {
+ it = videoMap[info->absoluteFilePath()].first;
+ LVideoWidget *widget = videoMap[info->absoluteFilePath()].second;
+ widget->setIconSize(treeWidget->iconSize());
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{
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
bgstack15