mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
get thing to work
This commit is contained in:
parent
81a8a091f6
commit
b439b640bd
3 changed files with 19 additions and 10 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "../../../../game/cards/card_database_manager.h"
|
||||
#include "../../../../game/cards/card_item.h"
|
||||
#include "../../../../settings/cache_settings.h"
|
||||
#include "card_info_display_widget.h"
|
||||
#include "card_info_picture_widget.h"
|
||||
#include "card_info_text_widget.h"
|
||||
|
||||
|
|
@ -16,6 +17,8 @@ CardInfoFrameWidget::CardInfoFrameWidget(const QString &cardName, QWidget *paren
|
|||
setContentsMargins(3, 3, 3, 3);
|
||||
pic = new CardInfoPictureWidget();
|
||||
pic->setObjectName("pic");
|
||||
connect(pic, &CardInfoPictureWidget::cardChanged, this, qOverload<CardInfoPtr>(&CardInfoFrameWidget::setCard));
|
||||
|
||||
text = new CardInfoTextWidget();
|
||||
text->setObjectName("text");
|
||||
connect(text, SIGNAL(linkActivated(const QString &)), this, SLOT(setCard(const QString &)));
|
||||
|
|
|
|||
|
|
@ -253,6 +253,9 @@ QMenu *CardInfoPictureWidget::createRightClickMenu()
|
|||
return cardMenu;
|
||||
}
|
||||
|
||||
auto viewRelatedCards = new QMenu(tr("View related cards"));
|
||||
cardMenu->addMenu(viewRelatedCards);
|
||||
|
||||
bool atLeastOneGoodRelationFound = false;
|
||||
QList<CardRelation *> relatedCards = info->getAllRelatedCards();
|
||||
for (const CardRelation *cardRelation : relatedCards) {
|
||||
|
|
@ -264,20 +267,19 @@ QMenu *CardInfoPictureWidget::createRightClickMenu()
|
|||
}
|
||||
|
||||
if (!atLeastOneGoodRelationFound) {
|
||||
viewRelatedCards->setEnabled(false);
|
||||
return cardMenu;
|
||||
}
|
||||
|
||||
const auto ¤tCardSet = CardDatabase::getSetInfoForCard(info);
|
||||
|
||||
auto viewRelatedCards = new QMenu(tr("View related cards"));
|
||||
cardMenu->addMenu(viewRelatedCards);
|
||||
for (const CardRelation *relatedCard : relatedCards) {
|
||||
QString relatedCardName = relatedCard->getName();
|
||||
// QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||
/*connect(viewCard, &QAction::triggered, game, [this, relatedCardName, currentCardSet] {
|
||||
game->viewCardInfo(relatedCardName, currentCardSet.getProperty("uuid"));
|
||||
});*/
|
||||
for (const auto &relatedCard : relatedCards) {
|
||||
const auto &relatedCardName = relatedCard->getName();
|
||||
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||
connect(viewCard, &QAction::triggered, this, [this, &relatedCardName] {
|
||||
emit cardChanged(CardDatabaseManager::getInstance()->getCard(relatedCardName));
|
||||
});
|
||||
viewRelatedCards->addAction(viewCard);
|
||||
}
|
||||
|
||||
return cardMenu;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public slots:
|
|||
signals:
|
||||
void hoveredOnCard(CardInfoPtr hoveredCard);
|
||||
void cardScaleFactorChanged(int _scale);
|
||||
void cardChanged(CardInfoPtr card);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
@ -67,6 +68,9 @@ private:
|
|||
QTimer *hoverTimer;
|
||||
|
||||
QMenu *createRightClickMenu();
|
||||
|
||||
private slots:
|
||||
void actChangeCard(const QString &cardName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue