aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/Browser.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-22 04:55:42 -0400
committerKen Moore <ken@ixsystems.com>2017-06-22 04:55:42 -0400
commit60b24de5be126f387e5bd4ea654c36e7f0bdd0d4 (patch)
tree9e9bd4b7865f46b0deae7619be296c8994fb8660 /src-qt5/desktop-utils/lumina-fm/Browser.cpp
parentOops - forgot to add the new test.xml file to the last commit. (diff)
parentStart a large update to LuminaRandR info retrieval routine. (diff)
downloadlumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.tar.gz
lumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.tar.bz2
lumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.zip
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/Browser.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index b7eb9709..010196a4 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -20,7 +20,7 @@ Browser::Browser(QObject *parent) : QObject(parent){
showHidden = false;
showThumbs = false;
imageFormats = LUtils::imageExtensions(false); //lowercase suffixes
- connect(this, SIGNAL(threadDone(QString, QByteArray)), this, SLOT(futureFinished(QString, QByteArray))); //will always be between different threads
+ connect(this, SIGNAL(threadDone(QString, QImage)), this, SLOT(futureFinished(QString, QImage))); //will always be between different threads
}
Browser::~Browser(){
@@ -53,20 +53,25 @@ bool Browser::showingThumbnails(){
// PRIVATE
void Browser::loadItem(QString info, Browser *obj){
//qDebug() << "LoadItem:" << info;
- QByteArray bytes;
+ QImage pix;
if(imageFormats.contains(info.section(".",-1).toLower()) ){
QFile file(info);
if(file.open(QIODevice::ReadOnly)){
- bytes = file.readAll();
+ QByteArray bytes = file.readAll();
file.close();
+ pix.loadFromData(bytes);
+ if(bytes.size() > (512*1024) ){ //more than 512 KB
+ pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
}
}
+
//qDebug() << " - done with item:" << info;
- obj->emit threadDone(info, bytes);
+ obj->emit threadDone(info, pix);
}
QIcon Browser::loadIcon(QString icon){
- if(!mimeIcons.contains(icon)){
+ if(!mimeIcons.contains(icon)){
mimeIcons.insert(icon, LXDG::findIcon(icon, "unknown"));
}
@@ -76,7 +81,7 @@ QIcon Browser::loadIcon(QString icon){
// PRIVATE SLOTS
void Browser::fileChanged(QString file){
- if(file.startsWith(currentDir+"/") ){
+ if(file.startsWith(currentDir+"/") ){
if(QFile::exists(file) ){ QtConcurrent::run(this, &Browser::loadItem, file, this); } //file modified but not removed
else{ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } //file removed - need to update entire dir
}else if(file==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); }
@@ -87,20 +92,20 @@ void Browser::dirChanged(QString dir){
else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); }
}
-void Browser::futureFinished(QString name, QByteArray icon){
+void Browser::futureFinished(QString name, QImage icon){
//Note: this will be called once for every item that loads
qDebug() << "Future Finished:" << name;
QIcon ico;
LFileInfo info(name);
- if(!icon.isEmpty()){
+ if(!icon.isNull()){
//qDebug() << " -- Data:";
- QPixmap pix;
- if(pix.loadFromData(icon) ){ ico.addPixmap(pix); }
+ QPixmap pix = QPixmap::fromImage(icon);
+ ico.addPixmap(pix);
}else if(info.isDir()){
//qDebug() << " -- Folder:";
- ico = loadIcon("folder");
+ ico = loadIcon("folder");
}
- if(ico.isNull()){
+ if(ico.isNull()){
//qDebug() << " -- MimeType:" << info.fileName() << info.mimetype();
ico = loadIcon(info.iconfile());
}
@@ -116,8 +121,8 @@ void Browser::loadDirectory(QString dir){
qDebug() << "Load Directory" << dir;
if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir)
oldFiles.clear();
- emit clearItems();
- }
+ emit clearItems();
+ }
currentDir = dir; //save this for later
//clean up the watcher first
QStringList watched; watched << watcher->files() << watcher->directories();
@@ -141,7 +146,7 @@ void Browser::loadDirectory(QString dir){
QtConcurrent::run(this, &Browser::loadItem, path, this);
}else{
//No special icon loading - just skip the file read step
- futureFinished(path, QByteArray()); //loadItem(path, this);
+ futureFinished(path, QImage()); //loadItem(path, this);
}
}
watcher->addPath(directory.absolutePath());
bgstack15