aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-04-12 15:09:28 -0400
committerKen Moore <ken@ixsystems.com>2018-04-12 15:10:05 -0400
commit5a062c388eaacd8b9e900333cf7a496034169f3e (patch)
tree4c26b43e595890e4cb6a0218dcf2865bdf3c96d0
parentClean up a bit of the session initialization routines. (diff)
downloadlumina-5a062c388eaacd8b9e900333cf7a496034169f3e.tar.gz
lumina-5a062c388eaacd8b9e900333cf7a496034169f3e.tar.bz2
lumina-5a062c388eaacd8b9e900333cf7a496034169f3e.zip
Add a quick test script I wrote to probe icon themes and see what is found or not.
-rw-r--r--dev-tools/iconprobe/main.cpp77
-rw-r--r--dev-tools/iconprobe/test.pro12
2 files changed, 89 insertions, 0 deletions
diff --git a/dev-tools/iconprobe/main.cpp b/dev-tools/iconprobe/main.cpp
new file mode 100644
index 00000000..694292c3
--- /dev/null
+++ b/dev-tools/iconprobe/main.cpp
@@ -0,0 +1,77 @@
+#include <QApplication>
+#include <QDebug>
+#include <QFile>
+#include <QDir>
+#include <QTextStream>
+#include <QIcon>
+
+QString findInDir(QString dir, QString file){
+ QDir _dir(dir);
+ QStringList files = _dir.entryList(QStringList() << file+".*", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
+ if(files.isEmpty()){
+ QStringList dirs = _dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ QString tmp;
+ for(int i=0; i<dirs.length() && tmp.isEmpty(); i++){
+ tmp = findInDir( _dir.absoluteFilePath(dirs[i]), file);
+ }
+ return tmp;
+ }else{
+ return _dir.absoluteFilePath(files.first());
+ }
+}
+
+QStringList themeInherits(QString dir){
+ QFile file(dir+"/index.theme");
+ QStringList list;
+ if( file.open(QIODevice::Text | QIODevice::ReadOnly) ){
+ QTextStream in(&file);
+ while(!in.atEnd()){
+ QString line = in.readLine();
+ if(line.startsWith("Inherits=")){
+ //qDebug() << "Got Inherit Line" << line;
+ list = line.section("=",1,-1).split(";");
+ break; //done now
+ }
+ }
+ file.close();
+ }
+ return list;
+}
+
+bool isIconTheme(QString dir){
+ if(!QFile::exists(dir+"/index.theme")){ return false; }
+ QDir base(dir);
+ QStringList dirs = base.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ dirs.removeAll("cursors");
+ return (!dirs.isEmpty());
+}
+
+int main(int argc, char ** argv)
+{
+ QApplication a(argc, argv);
+
+ QString icondir="/usr/local/share/icons";
+ QStringList iconfiles; iconfiles << "user-home" << "falkon" << "firefox" << "utilities-terminal";
+
+ QDir dir(icondir);
+ QStringList themes = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ //Now look through them and see which themes have this file
+ QIcon::setThemeSearchPaths( QStringList() << icondir );
+ for(int i=0; i<themes.length(); i++){
+ QString themepath = dir.absoluteFilePath(themes[i]);
+ if( !isIconTheme(themepath) ){ continue; }
+ qDebug() << "Testing Theme:" << themes[i];
+ QIcon::setThemeName(themes[i]);
+ QStringList inherits = themeInherits(themepath);
+ for(int j=0; j<inherits.length(); j++){ inherits << themeInherits(dir.absoluteFilePath(inherits[j])); }
+ qDebug() << " - Inherits From Themes (in order):" << inherits;
+ for(int j=0; j<iconfiles.length(); j++){
+ qDebug() << " -------------------------";
+ qDebug() << " - Looking for icon:" << iconfiles[j];
+ qDebug() << " - Found File:" << findInDir(themepath, iconfiles[j]);
+ qDebug() << " - Found Icon:" << QIcon::fromTheme(iconfiles[j]).name();
+ }
+ qDebug() << " ================";
+ }
+ return 0;
+}
diff --git a/dev-tools/iconprobe/test.pro b/dev-tools/iconprobe/test.pro
new file mode 100644
index 00000000..48b02c00
--- /dev/null
+++ b/dev-tools/iconprobe/test.pro
@@ -0,0 +1,12 @@
+# Simple Qt program to test whether UI files can be loaded when there is no DBUS session running
+
+QT = core gui widgets
+#Just for consistency - remove the dbus module from this app build (in case "gui" or "widgets" pulled it in)
+QT -= dbus
+
+CONFIG += debug
+
+TARGET = test
+target.path = $${PWD}
+
+SOURCES = main.cpp
bgstack15