OTHER: enable zipped skins in SkinChooser

For now this is an ugly hack, but I plan to rework that sometime later
This commit is contained in:
Thomas Frauendorfer 2010-03-13 14:26:27 +01:00
parent 2aabed9491
commit cbcffe4b94
3 changed files with 30 additions and 1 deletions

View file

@ -75,7 +75,7 @@ SkinList::SkinList (QWidget *parent) : QListWidget (parent)
}
foreach (QFileInfo fileInfo, list) {
QPixmap p = Skin::getPixmap ("main", fileInfo.filePath());
QPixmap p = Skin::getMainPixmap (fileInfo.filePath());
if (!p.isNull()) {
new SkinChooserItem (QIcon (p), fileInfo.baseName (),
fileInfo.absoluteFilePath (), this);

View file

@ -801,6 +801,34 @@ Skin::setSkin (const QString& path)
return true;
}
const QPixmap
Skin::getMainPixmap (const QString& path)
{
DirIteratorBase *iter = DirIteratorBase::open(path);
if (iter == 0) {
return QPixmap ();
}
QString entry;
QPixmap ret = QPixmap ();
while (!(entry = iter->next ().toLower ()).isEmpty ()) {
if ((entry = QFileInfo (entry).fileName ()).isEmpty ()) {
// workaround to ignore pathes in archives
continue;
}
entry = entry.section(".", 0, 0);
if (entry == "main") {
ret = iter->pixmapEntry ();
if (!ret.isNull ())
break;
}
}
delete iter;
return ret;
}
const QPixmap
Skin::getPixmap (const QString& file, const QString &path)
{

View file

@ -42,6 +42,7 @@ class Skin : public QObject
const bool isValid () const {return m_valid;}
static const QPixmap getPixmap (const QString&, const QString&);
static const QPixmap getMainPixmap (const QString& path);
const QSize getSize (uint item) const
{ return m_sizes.value (item); }