aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-08 10:10:15 -0400
committerKen Moore <ken@ixsystems.com>2017-06-08 10:10:15 -0400
commit92aef217826de24e8086d88f41ca4bb361c89fc8 (patch)
tree73db0df1e2944af5859d07a6cfa559e947062698 /src-qt5
parentTry to streamline the item loading routine in lumina-fm a bit more. No discer... (diff)
downloadlumina-92aef217826de24e8086d88f41ca4bb361c89fc8.tar.gz
lumina-92aef217826de24e8086d88f41ca4bb361c89fc8.tar.bz2
lumina-92aef217826de24e8086d88f41ca4bb361c89fc8.zip
Add "back" in the option to show/skip image file previews.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp42
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h5
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp15
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/MainUI.cpp9
-rw-r--r--src-qt5/desktop-utils/lumina-fm/MainUI.h2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/MainUI.ui7
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp5
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h1
9 files changed, 58 insertions, 30 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index 0d4ddc0c..b7eb9709 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -18,12 +18,13 @@ Browser::Browser(QObject *parent) : QObject(parent){
connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) );
connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
showHidden = false;
+ showThumbs = false;
imageFormats = LUtils::imageExtensions(false); //lowercase suffixes
- connect(this, SIGNAL(threadDone(QString, QByteArray)), this, SLOT(futureFinished(QString, QByteArray)), Qt::QueuedConnection); //will always be between different threads
+ connect(this, SIGNAL(threadDone(QString, QByteArray)), this, SLOT(futureFinished(QString, QByteArray))); //will always be between different threads
}
Browser::~Browser(){
- watcher->deleteLater();
+ //watcher->deleteLater();
}
QString Browser::currentDirectory(){ return currentDir; }
@@ -31,18 +32,27 @@ QString Browser::currentDirectory(){ return currentDir; }
void Browser::showHiddenFiles(bool show){
if(show !=showHidden){
showHidden = show;
- QTimer::singleShot(0, this, SLOT(loadDirectory()) );
+ if(!currentDir.isEmpty()){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); }
}
}
bool Browser::showingHiddenFiles(){
return showHidden;
}
+void Browser::showThumbnails(bool show){
+ if(show != showThumbs){
+ showThumbs = show;
+ if(!currentDir.isEmpty()){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); }
+ }
+}
+
+bool Browser::showingThumbnails(){
+ return showThumbs;
+}
+
// PRIVATE
void Browser::loadItem(QString info, Browser *obj){
//qDebug() << "LoadItem:" << info;
- //FileItem item;
- //itemame = info;
QByteArray bytes;
if(imageFormats.contains(info.section(".",-1).toLower()) ){
QFile file(info);
@@ -50,12 +60,6 @@ void Browser::loadItem(QString info, Browser *obj){
bytes = file.readAll();
file.close();
}
-
- /*QPixmap pix;
- if(pix.load(item.info.absoluteFilePath()) ){
- if(pix.height()>128){ pix = pix.scaled(128, 128, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); }
- item.icon.addPixmap(pix);
- }*/
}
//qDebug() << " - done with item:" << info;
obj->emit threadDone(info, bytes);
@@ -85,28 +89,31 @@ void Browser::dirChanged(QString dir){
void Browser::futureFinished(QString name, QByteArray icon){
//Note: this will be called once for every item that loads
+ qDebug() << "Future Finished:" << name;
QIcon ico;
LFileInfo info(name);
if(!icon.isEmpty()){
+ //qDebug() << " -- Data:";
QPixmap pix;
if(pix.loadFromData(icon) ){ ico.addPixmap(pix); }
}else if(info.isDir()){
+ //qDebug() << " -- Folder:";
ico = loadIcon("folder");
- //LXDG::findIcon("folder","inode/directory");
}
if(ico.isNull()){
- //qDebug() << "MimeType:" << info.fileName() << info.mimetype();
+ //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype();
ico = loadIcon(info.iconfile());
- //ico = LXDG::findIcon( info.iconfile(), "unknown" );
}
+ qDebug() << " -- emit signal";
this->emit itemDataAvailable( ico, info );
+ qDebug() << " -- done:" << name;
}
// PUBLIC SLOTS
void Browser::loadDirectory(QString dir){
- //qDebug() << "Load Directory" << dir;
if(dir.isEmpty()){ dir = currentDir; } //reload current directory
if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded
+ qDebug() << "Load Directory" << dir;
if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir)
oldFiles.clear();
emit clearItems();
@@ -124,17 +131,14 @@ void Browser::loadDirectory(QString dir){
if(showHidden){ files = directory.entryList( QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDir::NoSort); }
else{ files = directory.entryList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort); }
emit itemsLoading(files.length());
- //QCoreApplication::processEvents();
- //QCoreApplication::sendPostedEvents();
for(int i=0; i<files.length(); i++){
watcher->addPath(directory.absoluteFilePath(files[i]));
//qDebug() << "Future Starting:" << files[i];
QString path = directory.absoluteFilePath(files[i]);
if(old.contains(path)){ old.removeAll(path); }
oldFiles << path; //add to list for next time
- if(imageFormats.contains(path.section(".",-1).toLower())){
+ if(showThumbs && imageFormats.contains(path.section(".",-1).toLower())){
QtConcurrent::run(this, &Browser::loadItem, path, this);
- //QCoreApplication::sendPostedEvents();
}else{
//No special icon loading - just skip the file read step
futureFinished(path, QByteArray()); //loadItem(path, this);
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
index b5c7c038..b96a7281 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.h
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -35,12 +35,15 @@ public:
void showHiddenFiles(bool);
bool showingHiddenFiles();
+ void showThumbnails(bool);
+ bool showingThumbnails();
+
//FileItem loadItem(QString info); //this is the main loader class - multiple instances each run in a separate thread
private:
QString currentDir;
QFileSystemWatcher *watcher;
- bool showHidden;
+ bool showHidden, showThumbs;
QStringList imageFormats, oldFiles;
QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
index 50c3cb98..a64c03ca 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
@@ -17,6 +17,7 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
//Setup the Widget/UI
this->setLayout( new QVBoxLayout(this) );
ID = objID;
+ //BROWSER = 0;
//Setup the backend browser object
BROWSER = new Browser(this);
connect(BROWSER, SIGNAL(clearItems()), this, SLOT(clearItems()) );
@@ -33,13 +34,13 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
}
BrowserWidget::~BrowserWidget(){
-
+ BROWSER->deleteLater();
}
void BrowserWidget::changeDirectory(QString dir){
- qDebug() << "Change Directory:" << dir << historyList;
if(BROWSER->currentDirectory()==dir){ return; } //already on this directory
-
+ qDebug() << "Change Directory:" << dir << historyList;
+
if( !dir.contains("/.zfs/snapshot/") ){
if(historyList.isEmpty() || !dir.isEmpty()){ historyList << dir; }
}else{
@@ -107,6 +108,14 @@ bool BrowserWidget::hasHiddenFiles(){
return BROWSER->showingHiddenFiles();
}
+void BrowserWidget::showThumbnails(bool show){
+ BROWSER->showThumbnails(show);
+}
+
+bool BrowserWidget::hasThumbnails(){
+ return BROWSER->showingThumbnails();
+}
+
void BrowserWidget::setThumbnailSize(int px){
bool larger = true;
if(listWidget!=0){
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
index 803a036d..a0c8fae6 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -46,6 +46,8 @@ public:
void showHiddenFiles(bool show);
bool hasHiddenFiles();
+ void showThumbnails(bool show);
+ bool hasThumbnails();
void setThumbnailSize(int px);
int thumbnailSize();
diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
index d4dfe1eb..9962a4bf 100644
--- a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
@@ -180,6 +180,7 @@ void MainUI::OpenDirs(QStringList dirs){
DW->setShowDetails(radio_view_details->isChecked());
DW->setThumbnailSize(settings->value("iconsize", 32).toInt());
DW->showHidden( ui->actionView_Hidden_Files->isChecked() );
+ DW->showThumbnails( ui->actionShow_Thumbnails->isChecked() );
//Now load the directory
DW->ChangeDir(dirs[i]); //kick off loading the directory info
}
@@ -274,6 +275,8 @@ void MainUI::loadSettings(){
// but before the first directory gets loaded
ui->actionView_Hidden_Files->setChecked( settings->value("showhidden", false).toBool() );
on_actionView_Hidden_Files_triggered(); //make sure to update the models too
+ ui->actionShow_Thumbnails->setChecked( settings->value("showthumbnails",true).toBool());
+ on_actionShow_Thumbnails_triggered(); //make sure to update models too
//ui->actionShow_Action_Buttons->setChecked(settings->value("showactions", true).toBool() );
//on_actionShow_Action_Buttons_triggered(); //make sure to update the UI
//ui->actionShow_Thumbnails->setChecked( settings->value("showthumbnails", true).toBool() );
@@ -479,12 +482,12 @@ void MainUI::on_actionView_Hidden_Files_triggered(){
//for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowSidebar(show); }
}*/
-/*void MainUI::on_actionShow_Thumbnails_triggered(){
+void MainUI::on_actionShow_Thumbnails_triggered(){
//Now save this setting for later
bool show = ui->actionShow_Thumbnails->isChecked();
settings->setValue("showthumbnails", show);
- //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowThumbnails(show); }
-}*/
+ for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->showThumbnails(show); }
+}
void MainUI::goToBookmark(QAction *act){
if(act==ui->actionManage_Bookmarks){
diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.h b/src-qt5/desktop-utils/lumina-fm/MainUI.h
index 2b4c0d7b..9f542ea9 100644
--- a/src-qt5/desktop-utils/lumina-fm/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-fm/MainUI.h
@@ -127,7 +127,7 @@ private slots:
void on_actionRefresh_triggered();
void on_actionView_Hidden_Files_triggered();
//void on_actionShow_Action_Buttons_triggered();
- //void on_actionShow_Thumbnails_triggered();
+ void on_actionShow_Thumbnails_triggered();
void goToBookmark(QAction*);
void goToDevice(QAction*);
void viewModeChanged(bool);
diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.ui b/src-qt5/desktop-utils/lumina-fm/MainUI.ui
index f356eadb..189b563f 100644
--- a/src-qt5/desktop-utils/lumina-fm/MainUI.ui
+++ b/src-qt5/desktop-utils/lumina-fm/MainUI.ui
@@ -69,7 +69,7 @@
<x>0</x>
<y>0</y>
<width>567</width>
- <height>371</height>
+ <height>367</height>
</rect>
</property>
<layout class="QHBoxLayout" name="BrowserLayout">
@@ -106,7 +106,7 @@
<x>0</x>
<y>0</y>
<width>567</width>
- <height>22</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -135,6 +135,7 @@
<addaction name="separator"/>
<addaction name="actionView_Hidden_Files"/>
<addaction name="separator"/>
+ <addaction name="actionShow_Thumbnails"/>
<addaction name="menuView_Mode"/>
</widget>
<widget class="QMenu" name="menuBookmarks">
@@ -242,7 +243,7 @@
<bool>true</bool>
</property>
<property name="text">
- <string>Load Thumbnails</string>
+ <string>Show Image Previews</string>
</property>
</action>
<action name="actionSearch">
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index ac038126..293db823 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -117,6 +117,11 @@ void DirWidget::showHidden(bool show){
if(RCBW!=0){ RCBW->showHiddenFiles(show); }
}
+void DirWidget::showThumbnails(bool show){
+ BW->showThumbnails(show);
+ if(RCBW!=0){ RCBW->showThumbnails(show); }
+}
+
void DirWidget::setThumbnailSize(int px){
BW->setThumbnailSize(px);
if(RCBW!=0){ RCBW->setThumbnailSize(px); }
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
index 38e7a657..5f06e2b6 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
@@ -47,6 +47,7 @@ public:
//View Settings
void setShowDetails(bool show);
void showHidden(bool show);
+ void showThumbnails(bool show);
void setThumbnailSize(int px);
void setFocusLineDir();
bgstack15