mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
Add a button to easily view the transformed version of a card. (#5498)
* Add a button to easily view the transformed version of a card. * Minor reword * Minor fix --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
This commit is contained in:
parent
724db755af
commit
e752578d15
2 changed files with 35 additions and 0 deletions
|
|
@ -23,6 +23,11 @@ CardInfoFrameWidget::CardInfoFrameWidget(const QString &cardName, QWidget *paren
|
|||
text->setObjectName("text");
|
||||
connect(text, SIGNAL(linkActivated(const QString &)), this, SLOT(setCard(const QString &)));
|
||||
|
||||
viewTransformationButton = new QPushButton();
|
||||
viewTransformationButton->setObjectName("viewTransformationButton");
|
||||
connect(viewTransformationButton, &QPushButton::clicked, this, &CardInfoFrameWidget::viewTransformation);
|
||||
viewTransformationButton->setVisible(false);
|
||||
|
||||
tab1 = new QWidget(this);
|
||||
tab2 = new QWidget(this);
|
||||
tab3 = new QWidget(this);
|
||||
|
|
@ -69,6 +74,7 @@ void CardInfoFrameWidget::retranslateUi()
|
|||
setTabText(ImageOnlyView, tr("Image"));
|
||||
setTabText(TextOnlyView, tr("Description"));
|
||||
setTabText(ImageAndTextView, tr("Both"));
|
||||
viewTransformationButton->setText(tr("View transformation"));
|
||||
}
|
||||
|
||||
void CardInfoFrameWidget::setViewMode(int mode)
|
||||
|
|
@ -80,10 +86,12 @@ void CardInfoFrameWidget::setViewMode(int mode)
|
|||
case ImageOnlyView:
|
||||
case TextOnlyView:
|
||||
tab1Layout->addWidget(pic);
|
||||
tab1Layout->addWidget(viewTransformationButton);
|
||||
tab2Layout->addWidget(text);
|
||||
break;
|
||||
case ImageAndTextView:
|
||||
splitter->addWidget(pic);
|
||||
splitter->addWidget(viewTransformationButton);
|
||||
splitter->addWidget(text);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -95,6 +103,7 @@ void CardInfoFrameWidget::setViewMode(int mode)
|
|||
|
||||
void CardInfoFrameWidget::setCard(CardInfoPtr card)
|
||||
{
|
||||
viewTransformationButton->setVisible(false);
|
||||
if (info) {
|
||||
disconnect(info.data(), nullptr, this, nullptr);
|
||||
}
|
||||
|
|
@ -105,6 +114,16 @@ void CardInfoFrameWidget::setCard(CardInfoPtr card)
|
|||
connect(info.data(), SIGNAL(destroyed()), this, SLOT(clearCard()));
|
||||
}
|
||||
|
||||
if (info) {
|
||||
const auto &cardRelations = info->getAllRelatedCards();
|
||||
for (const auto &cardRelation : cardRelations) {
|
||||
if (cardRelation->getDoesTransform()) {
|
||||
viewTransformationButton->setVisible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text->setCard(info);
|
||||
pic->setCard(info);
|
||||
}
|
||||
|
|
@ -126,6 +145,19 @@ void CardInfoFrameWidget::setCard(AbstractCardItem *card)
|
|||
}
|
||||
}
|
||||
|
||||
void CardInfoFrameWidget::viewTransformation()
|
||||
{
|
||||
if (info) {
|
||||
const auto &cardRelations = info->getAllRelatedCards();
|
||||
for (const auto &cardRelation : cardRelations) {
|
||||
if (cardRelation->getDoesTransform()) {
|
||||
setCard(cardRelation->getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardInfoFrameWidget::clearCard()
|
||||
{
|
||||
setCard((CardInfoPtr) nullptr);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../../../../game/cards/card_database.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QTabWidget>
|
||||
|
||||
class AbstractCardItem;
|
||||
|
|
@ -18,6 +19,7 @@ private:
|
|||
CardInfoPtr info;
|
||||
CardInfoPictureWidget *pic;
|
||||
CardInfoTextWidget *text;
|
||||
QPushButton *viewTransformationButton;
|
||||
bool cardTextOnly;
|
||||
QWidget *tab1, *tab2, *tab3;
|
||||
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
|
||||
|
|
@ -43,6 +45,7 @@ public slots:
|
|||
void setCard(const QString &cardName);
|
||||
void setCard(const QString &cardName, const QString &providerId);
|
||||
void setCard(AbstractCardItem *card);
|
||||
void viewTransformation();
|
||||
void clearCard();
|
||||
void setViewMode(int mode);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue