From df1b1ce03827d8efae1fa1124a504fd972eb40dc Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 10 Nov 2015 12:37:12 -0500 Subject: Re-work how Lumina finds/loads icons from the current theme. This bypasses the QIcon::fromTheme() functionality completely, that way we get more detection/control over finding bad files and such (SVG files in particular). --- libLumina/LuminaUtils.cpp | 7 ++- libLumina/LuminaUtils.h | 2 +- libLumina/LuminaX11.h | 78 ++++++++++++++++++++++++++++ libLumina/LuminaXDG.cpp | 129 ++++++++++++++++++++++++++++++++-------------- libLumina/libLumina.pro | 2 +- 5 files changed, 174 insertions(+), 44 deletions(-) diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 39e000a2..0e836748 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -199,12 +199,15 @@ QString LUtils::PathToAbsolute(QString path){ return path; } -QStringList LUtils::imageExtensions(){ +QStringList LUtils::imageExtensions(bool wildcards){ //Note that all the image extensions are lowercase!! static QStringList imgExtensions; if(imgExtensions.isEmpty()){ QList fmt = QImageReader::supportedImageFormats(); - for(int i=0; i ATOMS; diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index b027f900..7003c976 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -9,6 +9,7 @@ #include "LuminaUtils.h" #include #include +#include static QStringList mimeglobs; static qint64 mimechecktime; @@ -563,6 +564,9 @@ void LXDG::setEnvironmentVars(){ } QIcon LXDG::findIcon(QString iconName, QString fallback){ + //NOTE: This was re-written on 11/10/15 to avoid using the QIcon::fromTheme() framework + // -- Too many issues with SVG files and/or search paths with the built-in system + //Check if the icon is an absolute path and exists bool DEBUG =false; if(DEBUG){ qDebug() << "[LXDG] Find icon for:" << iconName; } @@ -575,53 +579,87 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ } //Now try to find the icon from the theme if(DEBUG){ qDebug() << "[LXDG] Start search for icon"; } - //Check the default theme search paths - QStringList paths = QIcon::themeSearchPaths(); - if(paths.isEmpty()){ - //Set the XDG default icon theme search paths - paths << QDir::homePath()+"/.icons"; - QStringList xdd = QString(getenv("XDG_DATA_HOME")).split(":"); - xdd << QString(getenv("XDG_DATA_DIRS")).split(":"); - for(int i=0; i 0){ out << D.absolutePath(); } + QStringList dirs = D.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + if(!dirs.isEmpty() && (dirs.contains("32x32") || dirs.contains("scalable")) ){ + //Need to sort these directories by image size + //qDebug() << " - Parent:" << parent << "Dirs:" << dirs; + for(int i=0; i 0){ out << D.absolutePath(); } for(int i=0; i 0){ out << pngs; } + img.clear(); + img = getChildIconDirs(D.absoluteFilePath(dirs[i])); //re-use the old list variable + if(img.length() > 0){ out << img; } } return out; } diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 0a29325e..df8544d5 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -1,6 +1,6 @@ QT += core network -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia concurrent +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia concurrent svg TARGET=LuminaUtils -- cgit