diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 21 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 6 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 14 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 4 |
4 files changed, 24 insertions, 21 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index dfe402e1..34205880 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -27,7 +27,7 @@ Browser::Browser(QObject *parent) : QObject(parent){ imageFormats = LUtils::imageExtensions(false); //lowercase suffixes //connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(captureFrame(QImage))); //connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); }); - connect(this, SIGNAL(threadDone(QString, QImage)), this, SLOT(futureFinished(QString, QImage))); //will always be between different threads + connect(this, SIGNAL(threadDone(QString, const QImage*)), this, SLOT(futureFinished(QString, const QImage*))); //will always be between different threads } Browser::~Browser(){ @@ -61,15 +61,15 @@ bool Browser::showingThumbnails(){ // PRIVATE void Browser::loadItem(QString info, Browser *obj){ - QImage pix; + QImage* pix = new QImage(); if(imageFormats.contains(info.section(".",-1).toLower()) ){ QFile file(info); if(file.open(QIODevice::ReadOnly)){ QByteArray bytes = file.readAll(); file.close(); - pix.loadFromData(bytes); - if(pix.width() > 256 || pix.height() > 256 ){ - pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::FastTransformation); + pix->loadFromData(bytes); + if(pix->width() > 256 || pix->height() > 256 ){ + *pix = pix->scaled(256,256, Qt::KeepAspectRatio, Qt::FastTransformation); } } } @@ -109,15 +109,15 @@ void Browser::dirChanged(QString dir){ //else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); } } -void Browser::futureFinished(QString name, QImage icon){ +void Browser::futureFinished(QString name, const 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() << "Finished:" << name; QIcon *ico = new QIcon(); LFileInfo *info = new LFileInfo(name); - if(!icon.isNull() && showThumbs){ - QPixmap pix = QPixmap::fromImage(icon); + if(icon != nullptr && showThumbs){ + QPixmap pix = QPixmap::fromImage(*icon); ico->addPixmap(pix); /*}else if(info->isVideo() && showThumbs) { if(videoImages.find(name) == videoImages.end()) { @@ -132,7 +132,10 @@ void Browser::futureFinished(QString name, QImage icon){ }else{ ico = loadIcon(info->iconfile()); } - this->emit itemDataAvailable( *ico, info); + this->emit itemDataAvailable( ico, info); + // We are done with processing received image (copied to pixmap above) so now clean it up + delete icon; + icon = nullptr; //qDebug() << " -- done:" << name; } diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index c6a15218..4eb9b6fb 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -50,7 +50,7 @@ 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 futureFinished(QString, QImage); + void futureFinished(QString, const QImage* ); void updateRequested(); public slots: @@ -60,13 +60,13 @@ signals: //Main Signals void itemRemoved(QString item); //emitted if a file was removed from the underlying void clearItems(); //emitted when dirs change for example - void itemDataAvailable(QIcon, LFileInfo*); + void itemDataAvailable(const QIcon*, LFileInfo*); //Start/Stop signals for loading of data void itemsLoading(int); //number of items which are getting loaded //Internal signal for the alternate threads - void threadDone(QString, QImage); + void threadDone(QString, const QImage*); }; #endif diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index e7788445..6fa9da94 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -28,7 +28,7 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ bThread->start(); connect(BROWSER, SIGNAL(clearItems()), this, SLOT(clearItems()) ); connect(BROWSER, SIGNAL(itemRemoved(QString)), this, SLOT(itemRemoved(QString)) ); - connect(BROWSER, SIGNAL(itemDataAvailable(QIcon, LFileInfo*)), this, SLOT(itemDataAvailable(QIcon, LFileInfo*)) ); + connect(BROWSER, SIGNAL(itemDataAvailable(const QIcon *, LFileInfo*)), this, SLOT(itemDataAvailable(const QIcon *, LFileInfo*)) ); connect(BROWSER, SIGNAL(itemsLoading(int)), this, SLOT(itemsLoading(int)) ); connect(this, SIGNAL(dirChange(QString, bool)), BROWSER, SLOT(loadDirectory(QString, bool)) ); listWidget = 0; @@ -99,7 +99,7 @@ void BrowserWidget::showDetails(bool show){ connect(treeWidget, SIGNAL(DataDropped(QString, QStringList)), this, SIGNAL(DataDropped(QString, QStringList)) ); connect(treeWidget, SIGNAL(GotFocus()), this, SLOT(selectionChanged()) ); connect(treeWidget, SIGNAL(sortColumnChanged(int)), this, SIGNAL(treeWidgetSortColumn(int)) ); - connect(treeWidget, SIGNAL(sortColumnChanged(int)), this, SIGNAL(setTreeWidgetSortColumn(int)) ); + connect(treeWidget, SIGNAL(sortColumnChanged(int)), this, SIGNAL(setTreeWidgetSortColumn(int, bool)) ); retranslate(); treeWidget->sortItems(treeSortColumn, Qt::AscendingOrder); treeWidget->setColumnWidth(0, treeWidget->fontMetrics().width("W")*20); @@ -320,7 +320,7 @@ void BrowserWidget::itemRemoved(QString item){ } } -void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ +void BrowserWidget::itemDataAvailable(const QIcon* ico, LFileInfo *info){ if(info==0){ return; } if(listWidget!=0){ listWidget->setWhatsThis( BROWSER->currentDirectory() ); } if(treeWidget!=0){ treeWidget->setWhatsThis(BROWSER->currentDirectory() ); } @@ -347,7 +347,7 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ } //No existing item - make a new one if(it==0){ - it = new CQListWidgetItem(ico, info->fileName(), listWidget); + it = new CQListWidgetItem(*ico, info->fileName(), listWidget); it->setWhatsThis(info->absoluteFilePath()); it->setData(Qt::UserRole, (info->isDir() ? "dir" : "file")); //used for sorting listWidget->addItem(it); @@ -356,9 +356,9 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ //Now update the information for the item if(info->isDesktopFile() && info->XDG()->isValid()){ it->setText(info->XDG()->name); - it->setIcon(ico); + it->setIcon(*ico); }else{ - it->setIcon(ico); + it->setIcon(*ico); it->setText(info->fileName()); } @@ -397,7 +397,7 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ } } //Now set/update all the data - if(!info->isVideo() || !hasThumbnails() || !USE_VIDEO_LABEL){ it->setIcon(0, ico); } + if(!info->isVideo() || !hasThumbnails() || !USE_VIDEO_LABEL){ it->setIcon(0, *ico); } it->setText(1, info->isDir() ? "" : LUtils::BytesToDisplaySize(info->size()) ); //size (1) it->setText(2, info->mimetype() ); //type (2) it->setText(3, DTtoString(info->lastModified() )); //modification date (3) diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h index fbabd9c7..46165242 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -61,7 +61,7 @@ public: QStringList history(); void setShowActive(bool show); //used for accenting if the widget is "active" - + void setTreeWidgetSortColumn(int col, bool now = false); QString status(){ return statustip; } @@ -80,7 +80,7 @@ private slots: //Browser connections void clearItems(); void itemRemoved(QString); - void itemDataAvailable(QIcon, LFileInfo*); + void itemDataAvailable(const QIcon*, LFileInfo*); void itemsLoading(int total); void selectionChanged(); void loadStatistics(BrowserWidget *bw); //designed to be run in a background thread |