From 7792d26f2e91ef9cf160ba46b3915d7deb3d2177 Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Thu, 22 Jun 2017 10:02:42 -0400 Subject: Fixed nullReceiver error in Lumina-fm --- src-qt5/desktop-utils/lumina-fm/Browser.cpp | 19 ++++----- src-qt5/desktop-utils/lumina-fm/Browser.h | 2 +- src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 50 +++++++++++------------ src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 6 +-- 4 files changed, 38 insertions(+), 39 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-fm') diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 010196a4..1d57dd8c 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -16,7 +16,7 @@ Browser::Browser(QObject *parent) : QObject(parent){ watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) ); - connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) ); + connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) ); showHidden = false; showThumbs = false; imageFormats = LUtils::imageExtensions(false); //lowercase suffixes @@ -52,7 +52,6 @@ bool Browser::showingThumbnails(){ // PRIVATE void Browser::loadItem(QString info, Browser *obj){ - //qDebug() << "LoadItem:" << info; QImage pix; if(imageFormats.contains(info.section(".",-1).toLower()) ){ QFile file(info); @@ -88,30 +87,30 @@ void Browser::fileChanged(QString file){ } void Browser::dirChanged(QString dir){ + if(dir==currentDir){ QTimer::singleShot(500, this, SLOT(loadDirectory()) ); } else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); } } 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); + QIcon ico; + //LFileInfo info(name); + LFileInfo *info = new LFileInfo(name); if(!icon.isNull()){ //qDebug() << " -- Data:"; QPixmap pix = QPixmap::fromImage(icon); ico.addPixmap(pix); - }else if(info.isDir()){ + }else if(info->isDir()){ //qDebug() << " -- Folder:"; ico = loadIcon("folder"); } if(ico.isNull()){ //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype(); - ico = loadIcon(info.iconfile()); + ico = loadIcon(info->iconfile()); } - qDebug() << " -- emit signal"; - this->emit itemDataAvailable( ico, info ); - qDebug() << " -- done:" << name; + this->emit itemDataAvailable( ico, info); + //qDebug() << " -- done:" << name; } // PUBLIC SLOTS diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 40e98753..94f6ba3f 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -63,7 +63,7 @@ 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(QIcon, LFileInfo*); //Start/Stop signals for loading of data void itemsLoading(int); //number of items which are getting loaded diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index a64c03ca..b2ebd476 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -22,7 +22,7 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ BROWSER = new Browser(this); 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(QIcon, LFileInfo*)), this, SLOT(itemDataAvailable(QIcon, LFileInfo*)) ); connect(BROWSER, SIGNAL(itemsLoading(int)), this, SLOT(itemsLoading(int)) ); connect(this, SIGNAL(dirChange(QString)), BROWSER, SLOT(loadDirectory(QString)) ); listWidget = 0; @@ -118,7 +118,7 @@ bool BrowserWidget::hasThumbnails(){ void BrowserWidget::setThumbnailSize(int px){ bool larger = true; - if(listWidget!=0){ + if(listWidget!=0){ larger = listWidget->iconSize().height() < px; listWidget->setIconSize(QSize(px,px)); }else if(treeWidget!=0){ @@ -138,7 +138,7 @@ int BrowserWidget::thumbnailSize(){ void BrowserWidget::setHistory(QStringList paths){ //NOTE: later items are used first - historyList = paths; + historyList = paths; } QStringList BrowserWidget::history(){ @@ -192,7 +192,7 @@ QStringList BrowserWidget::currentItems(int type){ }else if(i==0){ //ALL paths << listWidget->item(i)->whatsThis(); } - } + } }else if(treeWidget!=0){ for(int i=0; itopLevelItemCount(); i++){ if(i<0 && !treeWidget->topLevelItem(i)->text(1).isEmpty()){ //FILES @@ -270,45 +270,46 @@ void BrowserWidget::itemRemoved(QString item){ } } -void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ - //qDebug() << "Item Data Available:" << info.fileName(); +void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ + //qDebug() << "Item Data Available:" << info->fileName(); int num = 0; if(listWidget!=0){ //LIST WIDGET - name and icon only - if(!listWidget->findItems(info.fileName(), Qt::MatchExactly).isEmpty()){ + if(!listWidget->findItems(info->fileName(), Qt::MatchExactly).isEmpty()){ //Update existing item - QListWidgetItem *it = listWidget->findItems(info.fileName(), Qt::MatchExactly).first(); - it->setText(info.fileName()); - it->setWhatsThis(info.absoluteFilePath()); + QListWidgetItem *it = listWidget->findItems(info->fileName(), Qt::MatchExactly).first(); + it->setText(info->fileName()); + it->setWhatsThis(info->absoluteFilePath()); it->setIcon(ico); }else{ //New item - QListWidgetItem *it = new CQListWidgetItem(ico, info.fileName(), listWidget); - it->setWhatsThis(info.absoluteFilePath()); - it->setData(Qt::UserRole, (info.isDir() ? "dir" : "file")); //used for sorting + QListWidgetItem *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); } num = listWidget->count(); }else if(treeWidget!=0){ QTreeWidgetItem *it = 0; - if( ! treeWidget->findItems(info.fileName(), Qt::MatchExactly, 0).isEmpty() ){ it = treeWidget->findItems(info.fileName(), Qt::MatchExactly, 0).first(); } - else{ - it = new CQTreeWidgetItem(treeWidget); - it->setText(0, info.fileName() ); //name (0) + if( ! treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).isEmpty() ){ it = treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).first(); } + else{ + it = new CQTreeWidgetItem(treeWidget); + it->setText(0, info->fileName() ); //name (0) treeWidget->addTopLevelItem(it); } //Now set/update all the data 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) - it->setText(4, DTtoString(info.created()) ); //creation date (4) + 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) + it->setText(4, DTtoString(info->created()) ); //creation date (4) //Now all the hidden data - it->setWhatsThis(0, info.absoluteFilePath()); - it->setWhatsThis(3, info.lastModified().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually - it->setWhatsThis(4, info.created().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually + it->setWhatsThis(0, info->absoluteFilePath()); + it->setWhatsThis(3, info->lastModified().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually + it->setWhatsThis(4, info->created().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually num = treeWidget->topLevelItemCount(); } + if(num < numItems){ //Still loading items //this->setEnabled(false); @@ -341,7 +342,6 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ } } } - if( (nF+nD) >0){ stats.prepend("\t"); if(nF>0){ diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h index a0c8fae6..fafb3746 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -72,7 +72,7 @@ private slots: //Browser connections void clearItems(); void itemRemoved(QString); - void itemDataAvailable(QIcon, LFileInfo); + void itemDataAvailable(QIcon, LFileInfo*); void itemsLoading(int total); void selectionChanged(); @@ -86,9 +86,9 @@ signals: void contextMenuRequested(); void DataDropped(QString, QStringList); void hasFocus(QString); //ID output - + //Internal signal void dirChange(QString); //current dir path - + }; #endif -- cgit