Commit 86097d29 authored by brukie's avatar brukie
Browse files

foo

parent 04072b02
......@@ -4,17 +4,20 @@
#include <QTextEdit>
CardInfoWidget::CardInfoWidget(CardDatabase *_db, QWidget *parent)
: QFrame(parent), db(_db), aspectratio(0)
: QFrame(parent), db(_db), pixmapHeight(0)
{
cardPicture = new QLabel();
cardPicture->setAlignment(Qt::AlignCenter);
nameLabel1 = new QLabel(tr("Name:"));
nameLabel2 = new QLabel();
nameLabel2->setWordWrap(true);
manacostLabel1 = new QLabel(tr("Mana cost:"));
manacostLabel2 = new QLabel();
manacostLabel2->setWordWrap(true);
cardtypeLabel1 = new QLabel(tr("Card type:"));
cardtypeLabel2 = new QLabel();
cardtypeLabel2->setWordWrap(true);
powtoughLabel1 = new QLabel(tr("P / T:"));
powtoughLabel2 = new QLabel();
......@@ -42,12 +45,11 @@ void CardInfoWidget::setCard(CardInfo *card)
if (!card)
return;
if (aspectratio == 0) {
if (pixmapHeight == 0) {
QPixmap *bigPixmap = card->loadPixmap();
aspectratio = (double) bigPixmap->height() / bigPixmap->width();
pixmapHeight = pixmapWidth * bigPixmap->height() / bigPixmap->width();
}
double w = 180;
cardPicture->setPixmap(*card->getPixmap(QSize(w, w * aspectratio)));
cardPicture->setPixmap(*card->getPixmap(QSize(pixmapWidth, pixmapHeight)));
nameLabel2->setText(card->getName());
manacostLabel2->setText(card->getManacost());
......
......@@ -11,7 +11,8 @@ class CardInfoWidget : public QFrame {
Q_OBJECT
private:
CardDatabase *db;
double aspectratio;
static const int pixmapWidth = 180;
int pixmapHeight;
QLabel *cardPicture;
QLabel *nameLabel1, *nameLabel2;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment