aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-04-17 10:27:22 -0400
committerKen Moore <ken@ixsystems.com>2018-04-17 10:27:22 -0400
commit3a53ebfe91ae0aad59c071c48076fa57256920c5 (patch)
tree24ee87eeeb8a48fcc3a37f47c2c9f209eaa87f5b /src-qt5/core
parentFix up the clipboard persistance. (diff)
downloadlumina-3a53ebfe91ae0aad59c071c48076fa57256920c5.tar.gz
lumina-3a53ebfe91ae0aad59c071c48076fa57256920c5.tar.bz2
lumina-3a53ebfe91ae0aad59c071c48076fa57256920c5.zip
Fix up the detection of icons in LFileInfo.
Add a large failover system where a list of possible icons are created, and the first one which exists in the theme is used. Also update the iconprobe dev tool a but: make it take an optional list of icons as input
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/libLumina/LFileInfo.cpp45
-rw-r--r--src-qt5/core/libLumina/LFileInfo.h3
2 files changed, 26 insertions, 22 deletions
diff --git a/src-qt5/core/libLumina/LFileInfo.cpp b/src-qt5/core/libLumina/LFileInfo.cpp
index e7d2b71a..3b659c75 100644
--- a/src-qt5/core/libLumina/LFileInfo.cpp
+++ b/src-qt5/core/libLumina/LFileInfo.cpp
@@ -35,29 +35,37 @@ void LFileInfo::loadExtraInfo(){
mime = "inode/directory";
//Special directory icons
QString name = this->fileName().toLower();
- if(name=="desktop"){ icon = "user-desktop"; }
- else if(name=="tmp"){ icon = "folder-temp"; }
- else if(name=="video" || name=="videos"){ icon = "folder-video"; }
- else if(name=="music" || name=="audio"){ icon = "folder-sound"; }
- else if(name=="projects" || name=="devel"){ icon = "folder-development"; }
- else if(name=="notes"){ icon = "folder-txt"; }
- else if(name=="downloads"){ icon = "folder-downloads"; }
- else if(name=="documents"){ icon = "folder-documents"; }
- else if(name=="images" || name=="pictures"){ icon = "folder-image"; }
- else if(this->absoluteFilePath().startsWith("/net/")){ icon = "folder-remote"; }
- else if( !this->isReadable() ){ icon = "folder-locked"; }
+ if(name=="desktop"){ iconList << "user-desktop"; }
+ else if(name=="tmp"){ iconList << "folder-temp"; }
+ else if(name=="video" || name=="videos"){ iconList << "folder-video" << "camera-photo-film" ; }
+ else if(name=="music" || name=="audio"){ iconList << "folder-sound" << "media-playlist-audio"; }
+ else if(name=="projects" || name=="devel"){ iconList << "folder-development"; }
+ else if(name=="notes"){ iconList << "folder-txt" << "note-multiple-outline" << "note-multiple"; }
+ else if(name=="downloads"){ iconList << "folder-downloads" << "folder-download"; }
+ else if(name=="documents"){ iconList << "folder-documents"; }
+ else if(name=="images" || name=="pictures"){ iconList << "folder-image"; }
+ else if(this->absoluteFilePath().startsWith("/net/")){ iconList << "folder-remote"; }
+ else if( !this->isReadable() ){ iconList << "folder-locked"<< "folder-lock"; }
+ iconList << "folder";
}else if( this->suffix()=="desktop"){
mime = "application/x-desktop";
- icon = "application-x-desktop"; //default value
+ iconList << "application-x-desktop"; //default value
desk = new XDGDesktop(this->absoluteFilePath(), 0);
if(desk->type!=XDGDesktop::BAD){
//use the specific desktop file info (if possible)
- if(!desk->icon.isEmpty()){ icon = desk->icon; }
+ if(!desk->icon.isEmpty()){ iconList << desk->icon; }
}
}else{
//Generic file, just determine the mimetype
mime = LXDG::findAppMimeForFile(this->fileName());
}
+ //check the mimetype for an icon as needed
+ QString tmp = mime;
+ tmp.replace("/","-");
+ iconList << tmp;
+ if(this->isExecutable()){
+ iconList << "application-x-executable";
+ }
}
bool LFileInfo::zfsAvailable(){
@@ -94,14 +102,9 @@ QString LFileInfo::mimetype(){
// -- Return the icon to use for this file
QString LFileInfo::iconfile(){
- if(!icon.isEmpty()){
- return icon;
- }else if(!mime.isEmpty()){
- QString tmp = mime;
- tmp.replace("/","-");
- return tmp;
- }else if(this->isExecutable()){
- return "application-x-executable";
+ //Go through the icon list and find the first one that exists in the current theme
+ for(int i=0; i<iconList.length(); i++){
+ if( QIcon::hasThemeIcon(iconList[i])){ return iconList[i]; }
}
return ""; //Fall back to nothing
}
diff --git a/src-qt5/core/libLumina/LFileInfo.h b/src-qt5/core/libLumina/LFileInfo.h
index df1abb65..f72c8649 100644
--- a/src-qt5/core/libLumina/LFileInfo.h
+++ b/src-qt5/core/libLumina/LFileInfo.h
@@ -17,7 +17,8 @@
class LFileInfo : public QFileInfo{
private:
- QString mime, icon, zfs_ds;
+ QString mime, zfs_ds;
+ QStringList iconList;
XDGDesktop *desk;
void loadExtraInfo();
bgstack15