From 5747f7fe96c2419f8837bafd7122ba2a1ad04497 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 28 Feb 2019 18:50:34 -0500 Subject: 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. --- src-qt5/core/libLumina/LFileInfo.cpp | 15 +++++++++++++++ src-qt5/core/libLumina/LFileInfo.h | 1 + src-qt5/core/libLumina/LIconCache.cpp | 1 + src-qt5/core/libLumina/LuminaXDG.cpp | 5 +++++ 4 files changed, 22 insertions(+) (limited to 'src-qt5/core/libLumina') 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; iicon){ + //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