diff options
author | Ken Moore <ken@ixsystems.com> | 2019-02-28 18:50:34 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2019-02-28 18:55:38 -0500 |
commit | 5747f7fe96c2419f8837bafd7122ba2a1ad04497 (patch) | |
tree | 3219ad3d9bbd542c8c7fd6831bca397b4406cf07 /src-qt5/core/libLumina | |
parent | Add XDG mimetype registrations for ISO and IMG files for lumina-archiver. (diff) | |
download | lumina-5747f7fe96c2419f8837bafd7122ba2a1ad04497.tar.gz lumina-5747f7fe96c2419f8837bafd7122ba2a1ad04497.tar.bz2 lumina-5747f7fe96c2419f8837bafd7122ba2a1ad04497.zip |
Two fixes for icons:
1. Fix invalid *.desktop registrations where the Icon field is a relative filename WITH an extension.
Icons from the theme are supposed to be name only (no extension), while absolute file paths are supposed to include the extension.
2. Fix up the detection/usage of non-theme icons within LFileInfo.
Also add a simple icon() function for LFileInfo to handle the 3 different types of icon file returns.
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/LFileInfo.cpp | 15 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LFileInfo.h | 1 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LIconCache.cpp | 1 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.cpp | 5 |
4 files changed, 22 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/LFileInfo.cpp b/src-qt5/core/libLumina/LFileInfo.cpp index 3021d74a..82e9ac50 100644 --- a/src-qt5/core/libLumina/LFileInfo.cpp +++ b/src-qt5/core/libLumina/LFileInfo.cpp @@ -133,10 +133,25 @@ QString LFileInfo::iconfile(){ //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]; } + else if(desk!=0 && iconList[i] == desk->icon){ + //See if this icon is in the old "pixmaps" icon directory + QDir dir("/usr/local/share/pixmaps"); + QStringList matches = dir.entryList(QStringList() << desk->icon+".png" << desk->icon+".jpg"); + if(!matches.isEmpty()){ + return dir.absoluteFilePath(matches.first()); + } + } } return ""; //Fall back to nothing } +QIcon LFileInfo::icon(){ + QString ifile = iconfile(); + if(ifile.startsWith("/")){ return QIcon(ifile); } + else if(ifile.isEmpty()){ return QIcon::fromTheme("unknown"); } + else{ return QIcon::fromTheme(ifile); } +} + // -- Check if this is an XDG desktop file bool LFileInfo::isDesktopFile(){ if(desk==0){ return false; } diff --git a/src-qt5/core/libLumina/LFileInfo.h b/src-qt5/core/libLumina/LFileInfo.h index 21aae19d..94a113bc 100644 --- a/src-qt5/core/libLumina/LFileInfo.h +++ b/src-qt5/core/libLumina/LFileInfo.h @@ -40,6 +40,7 @@ public: // -- Return the icon file to use for this file QString iconfile(); //Note: This string is auto-formatted for use in the LXDG::findIcon() routine. + QIcon icon(); // -- Check if this is an XDG desktop file bool isDesktopFile(); diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp index c3b0cc1b..03f818bb 100644 --- a/src-qt5/core/libLumina/LIconCache.cpp +++ b/src-qt5/core/libLumina/LIconCache.cpp @@ -122,6 +122,7 @@ QString LIconCache::findFile(QString icon){ void LIconCache::loadIcon(QAbstractButton *button, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(icon=="appcafe"){ qDebug() << "appcafe icon:" << isThemeIcon(icon) << HASH.contains(icon); } if(isThemeIcon(icon)){ button->setIcon( iconFromTheme(icon)); return ; diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index aad63a5e..c6a81dbf 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -94,6 +94,8 @@ void XDGDesktop::sync(){ else if(comment.isEmpty() && loc==slang){ comment = val; } //short locale code else if(loc == lang){ comment = val; } }else if(var=="Icon"){ + //Quick fix for bad-registrations which add the icon suffix for theme icons + if(!val.startsWith("/") && val.endsWith(".png") ){ val = val.section(".",0,-2); } if(insection){ if(icon.isEmpty() && loc.isEmpty()){ icon = val; } else if(icon.isEmpty() && loc==slang){ icon = val; } //short locale code @@ -156,6 +158,7 @@ void XDGDesktop::sync(){ } } } + } @@ -963,6 +966,7 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ } //If still no icon found, look for any image format in the "pixmaps" directory if(ico.isNull()){ + //qDebug() << "Null Icon:" << iconName << LOS::AppPrefix(); if(QFile::exists(LOS::AppPrefix()+"share/pixmaps/"+iconName)){ ico.addFile(LOS::AppPrefix()+"share/pixmaps/"+iconName); }else{ @@ -975,6 +979,7 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ //Use the first one found that is a valid format for(int i=0; i<found.length(); i++){ if( formats.contains(found[i].section(".",-1).toLower()) ){ + //qDebug() << " - Found non-theme icon:" << found[i]; ico.addFile( pix.absoluteFilePath(found[i]) ); break; } |