diff --git a/cockatrice/src/cardinfowidget.cpp b/cockatrice/src/cardinfowidget.cpp index 591d710e..b07847d5 100644 --- a/cockatrice/src/cardinfowidget.cpp +++ b/cockatrice/src/cardinfowidget.cpp @@ -4,17 +4,20 @@ #include 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()); diff --git a/cockatrice/src/cardinfowidget.h b/cockatrice/src/cardinfowidget.h index 7f8d43dc..0d1c58b9 100644 --- a/cockatrice/src/cardinfowidget.h +++ b/cockatrice/src/cardinfowidget.h @@ -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;