mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
* move message_log_widget to game * move files * update headers * fix cmakelists * oracle fixes * split implementation out to cpp * fix recursive import * fix main file * format
This commit is contained in:
parent
f484c98152
commit
17dcaf9afa
337 changed files with 728 additions and 721 deletions
|
|
@ -0,0 +1,74 @@
|
|||
#include "card_info_display_widget.h"
|
||||
|
||||
#include "../../../database/card_database_manager.h"
|
||||
#include "../../../game/board/card_item.h"
|
||||
#include "../../../main.h"
|
||||
#include "card_info_picture_widget.h"
|
||||
#include "card_info_text_widget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QVBoxLayout>
|
||||
#include <utility>
|
||||
|
||||
CardInfoDisplayWidget::CardInfoDisplayWidget(const CardRef &cardRef, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QFrame(parent, flags), aspectRatio((qreal)CARD_HEIGHT / (qreal)CARD_WIDTH)
|
||||
{
|
||||
setContentsMargins(3, 3, 3, 3);
|
||||
pic = new CardInfoPictureWidget();
|
||||
pic->setObjectName("pic");
|
||||
text = new CardInfoTextWidget();
|
||||
text->setObjectName("text");
|
||||
connect(text, &CardInfoTextWidget::linkActivated, this, [this](const QString &card) { setCard({card}); });
|
||||
|
||||
auto *layout = new QVBoxLayout();
|
||||
layout->setObjectName("layout");
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(pic, 0, Qt::AlignCenter);
|
||||
layout->addWidget(text, 0, Qt::AlignCenter);
|
||||
setLayout(layout);
|
||||
|
||||
setFrameStyle(QFrame::Panel | QFrame::Raised);
|
||||
|
||||
int pixmapHeight = QGuiApplication::primaryScreen()->geometry().height() / 3;
|
||||
int pixmapWidth = static_cast<int>(pixmapHeight / aspectRatio);
|
||||
pic->setFixedWidth(pixmapWidth);
|
||||
pic->setFixedHeight(pixmapHeight);
|
||||
setFixedWidth(pixmapWidth + 150);
|
||||
|
||||
setCard(cardRef);
|
||||
|
||||
// ensure our parent gets a valid size to position us correctly
|
||||
resize(width(), sizeHint().height());
|
||||
}
|
||||
|
||||
void CardInfoDisplayWidget::setCard(const ExactCard &card)
|
||||
{
|
||||
if (exactCard)
|
||||
disconnect(exactCard.getCardPtr().data(), nullptr, this, nullptr);
|
||||
exactCard = card;
|
||||
if (exactCard)
|
||||
connect(exactCard.getCardPtr().data(), &QObject::destroyed, this, &CardInfoDisplayWidget::clear);
|
||||
|
||||
text->setCard(exactCard.getCardPtr());
|
||||
pic->setCard(exactCard);
|
||||
}
|
||||
|
||||
void CardInfoDisplayWidget::setCard(const CardRef &cardRef)
|
||||
{
|
||||
setCard(CardDatabaseManager::getInstance()->guessCard(cardRef));
|
||||
if (exactCard.isEmpty()) {
|
||||
text->setInvalidCardName(cardRef.name);
|
||||
}
|
||||
}
|
||||
|
||||
void CardInfoDisplayWidget::setCard(AbstractCardItem *card)
|
||||
{
|
||||
setCard(card->getCard());
|
||||
}
|
||||
|
||||
void CardInfoDisplayWidget::clear()
|
||||
{
|
||||
setCard(ExactCard());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue