1 /* coded by Ketmar // Vampire Avalon (ketmar@ketmar.no-ip.org)
3 * This program is free software. It comes without any warranty, to
4 * the extent permitted by applicable law. You can redistribute it
5 * and/or modify it under the terms of the Do What The Fuck You Want
6 * To Public License, Version 2, as published by Sam Hocevar. See
7 * http://sam.zoy.org/wtfpl/COPYING for more details.
14 #include <QApplication>
18 #include <QStringList>
20 #include <QTextStream>
24 #include "previewwidget.h"
28 QString loadFile (const QString &fileName) {
31 if (file.open(QIODevice::ReadOnly)) {
33 stream.setDevice(&file);
34 stream.setCodec("UTF-8");
35 res = stream.readAll();
43 static void doThemeScan (QStringList
&lst
, QDir
&dir
) {
44 QStringList filters
; filters
<< "*";
45 QFileInfoList
fl(dir
.entryInfoList(filters
, QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::Readable
| QDir::Executable
));
46 foreach (const QFileInfo
&fi
, fl
) {
47 if (dir
.exists(fi
.baseName()+"/cursors")) {
48 //qDebug() << fi.baseName();
55 static QStringList
enumThemes () {
57 //qDebug() << QDir::homePath();
58 //QString pts("~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons");
60 // get the search path from Xcursor
61 QString pts
= XcursorLibraryPath();
64 QStringList pathList
= pts
.split(':', QString::SkipEmptyParts
);
67 QMutableStringListIterator
i(pathList
);
69 const QString path
= i
.next();
70 QMutableStringListIterator
j(i
);
71 while (j
.hasNext()) if (j
.next() == path
) j
.remove();
74 // expand all occurrences of ~/ to the home dir
75 pathList
.replaceInStrings(QRegExp("^~\\/"), QDir::home().path() + '/');
76 //qDebug() << pathList;
78 foreach (const QString
&path
, pathList
) {
85 QMutableStringListIterator
i(res
);
87 const QString path
= i
.next();
88 QMutableStringListIterator
j(i
);
89 while (j
.hasNext()) if (j
.next() == path
) j
.remove();
97 ///////////////////////////////////////////////////////////////////////////////
98 int main (int argc
, char *argv
[]) {
99 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("koi8-r"));
100 QTextCodec::setCodecForLocale(QTextCodec::codecForName("koi8-r"));
102 QApplication
app(argc
, argv
);
104 QStringList tlist
= enumThemes();
106 foreach (const QString
&s
, tlist
) {
107 qDebug() << f
<< "--" << s
;
112 PreviewWidget *pw = new PreviewWidget;
113 XCursorTheme t(tlist[1]);
119 if (argc
< 2) return 0;
124 if (f
>= 0 && f
< tlist
.size()) {
126 fprintf(stderr
, "ERROR! invalid Xfixes!\n");
129 qDebug() << "loading theme:" << tlist
[f
];
130 XCursorTheme
t(tlist
[f
]);
132 PreviewWidget
*pw
= new PreviewWidget
;
136 } else applyTheme(t
);