foo
This commit is contained in:
parent
04072b02d1
commit
86097d29b6
2 changed files with 9 additions and 6 deletions
|
@ -4,17 +4,20 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
CardInfoWidget::CardInfoWidget(CardDatabase *_db, QWidget *parent)
|
CardInfoWidget::CardInfoWidget(CardDatabase *_db, QWidget *parent)
|
||||||
: QFrame(parent), db(_db), aspectratio(0)
|
: QFrame(parent), db(_db), pixmapHeight(0)
|
||||||
{
|
{
|
||||||
cardPicture = new QLabel();
|
cardPicture = new QLabel();
|
||||||
cardPicture->setAlignment(Qt::AlignCenter);
|
cardPicture->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
nameLabel1 = new QLabel(tr("Name:"));
|
nameLabel1 = new QLabel(tr("Name:"));
|
||||||
nameLabel2 = new QLabel();
|
nameLabel2 = new QLabel();
|
||||||
|
nameLabel2->setWordWrap(true);
|
||||||
manacostLabel1 = new QLabel(tr("Mana cost:"));
|
manacostLabel1 = new QLabel(tr("Mana cost:"));
|
||||||
manacostLabel2 = new QLabel();
|
manacostLabel2 = new QLabel();
|
||||||
|
manacostLabel2->setWordWrap(true);
|
||||||
cardtypeLabel1 = new QLabel(tr("Card type:"));
|
cardtypeLabel1 = new QLabel(tr("Card type:"));
|
||||||
cardtypeLabel2 = new QLabel();
|
cardtypeLabel2 = new QLabel();
|
||||||
|
cardtypeLabel2->setWordWrap(true);
|
||||||
powtoughLabel1 = new QLabel(tr("P / T:"));
|
powtoughLabel1 = new QLabel(tr("P / T:"));
|
||||||
powtoughLabel2 = new QLabel();
|
powtoughLabel2 = new QLabel();
|
||||||
|
|
||||||
|
@ -42,12 +45,11 @@ void CardInfoWidget::setCard(CardInfo *card)
|
||||||
if (!card)
|
if (!card)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (aspectratio == 0) {
|
if (pixmapHeight == 0) {
|
||||||
QPixmap *bigPixmap = card->loadPixmap();
|
QPixmap *bigPixmap = card->loadPixmap();
|
||||||
aspectratio = (double) bigPixmap->height() / bigPixmap->width();
|
pixmapHeight = pixmapWidth * bigPixmap->height() / bigPixmap->width();
|
||||||
}
|
}
|
||||||
double w = 180;
|
cardPicture->setPixmap(*card->getPixmap(QSize(pixmapWidth, pixmapHeight)));
|
||||||
cardPicture->setPixmap(*card->getPixmap(QSize(w, w * aspectratio)));
|
|
||||||
|
|
||||||
nameLabel2->setText(card->getName());
|
nameLabel2->setText(card->getName());
|
||||||
manacostLabel2->setText(card->getManacost());
|
manacostLabel2->setText(card->getManacost());
|
||||||
|
|
|
@ -11,7 +11,8 @@ class CardInfoWidget : public QFrame {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
double aspectratio;
|
static const int pixmapWidth = 180;
|
||||||
|
int pixmapHeight;
|
||||||
|
|
||||||
QLabel *cardPicture;
|
QLabel *cardPicture;
|
||||||
QLabel *nameLabel1, *nameLabel2;
|
QLabel *nameLabel1, *nameLabel2;
|
||||||
|
|
Loading…
Reference in a new issue