# HG changeset patch # User unc0rr # Date 1221882759 0 # Node ID 1f8456577a39be06e48738650c4373ce2c32b604 # Parent 2ca5484725ba46a659b0cea7bc63c41921079783 Draw a hedgehog under the hat in hats combobox diff -r 2ca5484725ba -r 1f8456577a39 QTfrontend/hats.cpp --- a/QTfrontend/hats.cpp Fri Sep 19 20:42:42 2008 +0000 +++ b/QTfrontend/hats.cpp Sat Sep 20 03:52:39 2008 +0000 @@ -18,12 +18,15 @@ #include #include +#include #include "hwconsts.h" #include "hats.h" HatsModel::HatsModel(QObject* parent) : QAbstractListModel(parent) { + QPixmap hhpix = QPixmap(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png").copy(0, 0, 32, 32); + QDir tmpdir; tmpdir.cd(datadir->absolutePath()); tmpdir.cd("Graphics"); @@ -31,14 +34,23 @@ tmpdir.setFilter(QDir::Files); + QStringList hatsList = tmpdir.entryList(QStringList("*.png")); for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it ) { QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png"); - hats.append(qMakePair(str, QIcon(pix.copy(0, 0, 32, 32)))); + + QPixmap tmppix(32, 37); + tmppix.fill(QColor(Qt::transparent)); + + QPainter painter(&tmppix); + painter.drawPixmap(QPoint(0, 5), hhpix); + painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); + painter.end(); + + hats.append(qMakePair(str, QIcon(tmppix))); } - } QVariant HatsModel::headerData(int section,