aboutsummaryrefslogtreecommitdiff
path: root/dev-tools/iconprobe/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dev-tools/iconprobe/main.cpp')
-rw-r--r--dev-tools/iconprobe/main.cpp77
1 files changed, 77 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;
+}
bgstack15