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_database_manager.h"
|
||||||
#include "../../../../game/cards/card_item.h"
|
#include "../../../../game/cards/card_item.h"
|
||||||
#include "../../../../settings/cache_settings.h"
|
#include "../../../../settings/cache_settings.h"
|
||||||
|
#include "card_info_display_widget.h"
|
||||||
#include "card_info_picture_widget.h"
|
#include "card_info_picture_widget.h"
|
||||||
#include "card_info_text_widget.h"
|
#include "card_info_text_widget.h"
|
||||||
|
|
||||||
|
|
@ -16,6 +17,8 @@ CardInfoFrameWidget::CardInfoFrameWidget(const QString &cardName, QWidget *paren
|
||||||
setContentsMargins(3, 3, 3, 3);
|
setContentsMargins(3, 3, 3, 3);
|
||||||
pic = new CardInfoPictureWidget();
|
pic = new CardInfoPictureWidget();
|
||||||
pic->setObjectName("pic");
|
pic->setObjectName("pic");
|
||||||
|
connect(pic, &CardInfoPictureWidget::cardChanged, this, qOverload<CardInfoPtr>(&CardInfoFrameWidget::setCard));
|
||||||
|
|
||||||
text = new CardInfoTextWidget();
|
text = new CardInfoTextWidget();
|
||||||
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 &)));
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,9 @@ QMenu *CardInfoPictureWidget::createRightClickMenu()
|
||||||
return cardMenu;
|
return cardMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto viewRelatedCards = new QMenu(tr("View related cards"));
|
||||||
|
cardMenu->addMenu(viewRelatedCards);
|
||||||
|
|
||||||
bool atLeastOneGoodRelationFound = false;
|
bool atLeastOneGoodRelationFound = false;
|
||||||
QList<CardRelation *> relatedCards = info->getAllRelatedCards();
|
QList<CardRelation *> relatedCards = info->getAllRelatedCards();
|
||||||
for (const CardRelation *cardRelation : relatedCards) {
|
for (const CardRelation *cardRelation : relatedCards) {
|
||||||
|
|
@ -264,20 +267,19 @@ QMenu *CardInfoPictureWidget::createRightClickMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!atLeastOneGoodRelationFound) {
|
if (!atLeastOneGoodRelationFound) {
|
||||||
|
viewRelatedCards->setEnabled(false);
|
||||||
return cardMenu;
|
return cardMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ¤tCardSet = CardDatabase::getSetInfoForCard(info);
|
for (const auto &relatedCard : relatedCards) {
|
||||||
|
const auto &relatedCardName = relatedCard->getName();
|
||||||
auto viewRelatedCards = new QMenu(tr("View related cards"));
|
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||||
cardMenu->addMenu(viewRelatedCards);
|
connect(viewCard, &QAction::triggered, this, [this, &relatedCardName] {
|
||||||
for (const CardRelation *relatedCard : relatedCards) {
|
emit cardChanged(CardDatabaseManager::getInstance()->getCard(relatedCardName));
|
||||||
QString relatedCardName = relatedCard->getName();
|
});
|
||||||
// QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
viewRelatedCards->addAction(viewCard);
|
||||||
/*connect(viewCard, &QAction::triggered, game, [this, relatedCardName, currentCardSet] {
|
|
||||||
game->viewCardInfo(relatedCardName, currentCardSet.getProperty("uuid"));
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cardMenu;
|
return cardMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void hoveredOnCard(CardInfoPtr hoveredCard);
|
void hoveredOnCard(CardInfoPtr hoveredCard);
|
||||||
void cardScaleFactorChanged(int _scale);
|
void cardScaleFactorChanged(int _scale);
|
||||||
|
void cardChanged(CardInfoPtr card);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
@ -67,6 +68,9 @@ private:
|
||||||
QTimer *hoverTimer;
|
QTimer *hoverTimer;
|
||||||
|
|
||||||
QMenu *createRightClickMenu();
|
QMenu *createRightClickMenu();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void actChangeCard(const QString &cardName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue