mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 03:23:56 -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");
|
text->setObjectName("text");
|
||||||
connect(text, SIGNAL(linkActivated(const QString &)), this, SLOT(setCard(const QString &)));
|
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);
|
tab1 = new QWidget(this);
|
||||||
tab2 = new QWidget(this);
|
tab2 = new QWidget(this);
|
||||||
tab3 = new QWidget(this);
|
tab3 = new QWidget(this);
|
||||||
|
|
@ -69,6 +74,7 @@ void CardInfoFrameWidget::retranslateUi()
|
||||||
setTabText(ImageOnlyView, tr("Image"));
|
setTabText(ImageOnlyView, tr("Image"));
|
||||||
setTabText(TextOnlyView, tr("Description"));
|
setTabText(TextOnlyView, tr("Description"));
|
||||||
setTabText(ImageAndTextView, tr("Both"));
|
setTabText(ImageAndTextView, tr("Both"));
|
||||||
|
viewTransformationButton->setText(tr("View transformation"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardInfoFrameWidget::setViewMode(int mode)
|
void CardInfoFrameWidget::setViewMode(int mode)
|
||||||
|
|
@ -80,10 +86,12 @@ void CardInfoFrameWidget::setViewMode(int mode)
|
||||||
case ImageOnlyView:
|
case ImageOnlyView:
|
||||||
case TextOnlyView:
|
case TextOnlyView:
|
||||||
tab1Layout->addWidget(pic);
|
tab1Layout->addWidget(pic);
|
||||||
|
tab1Layout->addWidget(viewTransformationButton);
|
||||||
tab2Layout->addWidget(text);
|
tab2Layout->addWidget(text);
|
||||||
break;
|
break;
|
||||||
case ImageAndTextView:
|
case ImageAndTextView:
|
||||||
splitter->addWidget(pic);
|
splitter->addWidget(pic);
|
||||||
|
splitter->addWidget(viewTransformationButton);
|
||||||
splitter->addWidget(text);
|
splitter->addWidget(text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -95,6 +103,7 @@ void CardInfoFrameWidget::setViewMode(int mode)
|
||||||
|
|
||||||
void CardInfoFrameWidget::setCard(CardInfoPtr card)
|
void CardInfoFrameWidget::setCard(CardInfoPtr card)
|
||||||
{
|
{
|
||||||
|
viewTransformationButton->setVisible(false);
|
||||||
if (info) {
|
if (info) {
|
||||||
disconnect(info.data(), nullptr, this, nullptr);
|
disconnect(info.data(), nullptr, this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +114,16 @@ void CardInfoFrameWidget::setCard(CardInfoPtr card)
|
||||||
connect(info.data(), SIGNAL(destroyed()), this, SLOT(clearCard()));
|
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);
|
text->setCard(info);
|
||||||
pic->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()
|
void CardInfoFrameWidget::clearCard()
|
||||||
{
|
{
|
||||||
setCard((CardInfoPtr) nullptr);
|
setCard((CardInfoPtr) nullptr);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../../../../game/cards/card_database.h"
|
#include "../../../../game/cards/card_database.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
|
||||||
class AbstractCardItem;
|
class AbstractCardItem;
|
||||||
|
|
@ -18,6 +19,7 @@ private:
|
||||||
CardInfoPtr info;
|
CardInfoPtr info;
|
||||||
CardInfoPictureWidget *pic;
|
CardInfoPictureWidget *pic;
|
||||||
CardInfoTextWidget *text;
|
CardInfoTextWidget *text;
|
||||||
|
QPushButton *viewTransformationButton;
|
||||||
bool cardTextOnly;
|
bool cardTextOnly;
|
||||||
QWidget *tab1, *tab2, *tab3;
|
QWidget *tab1, *tab2, *tab3;
|
||||||
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
|
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
|
||||||
|
|
@ -43,6 +45,7 @@ public slots:
|
||||||
void setCard(const QString &cardName);
|
void setCard(const QString &cardName);
|
||||||
void setCard(const QString &cardName, const QString &providerId);
|
void setCard(const QString &cardName, const QString &providerId);
|
||||||
void setCard(AbstractCardItem *card);
|
void setCard(AbstractCardItem *card);
|
||||||
|
void viewTransformation();
|
||||||
void clearCard();
|
void clearCard();
|
||||||
void setViewMode(int mode);
|
void setViewMode(int mode);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue