From a8b7fb91e4cfe11adb541e202e1af87caf53a245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 19 Jan 2025 17:01:39 +0100 Subject: [PATCH] Commander details display widget. --- cockatrice/CMakeLists.txt | 1 + ...ponse_commander_details_display_widget.cpp | 36 +++++++++++++++++++ ...esponse_commander_details_display_widget.h | 26 ++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.cpp create mode 100644 cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.h diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index a58e5b5a7..9a4b16ded 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -152,6 +152,7 @@ set(cockatrice_SOURCES src/client/tabs/api/edhrec/edhrec_commander_api_response_display_widget.cpp src/client/tabs/api/edhrec/edhrec_commander_api_response_card_details_display_widget.cpp src/client/tabs/api/edhrec/edhrec_commander_api_response_card_list_display_widget.cpp + src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.cpp src/client/tabs/api/edhrec/api_response/edhrec_commander_api_response_archidekt_links.cpp src/client/tabs/api/edhrec/api_response/edhrec_commander_api_response_average_deck_statistics.cpp src/client/tabs/api/edhrec/api_response/edhrec_commander_api_response_card_details.cpp diff --git a/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.cpp b/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.cpp new file mode 100644 index 000000000..72a671633 --- /dev/null +++ b/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.cpp @@ -0,0 +1,36 @@ +#include "edhrec_commander_api_response_commander_details_display_widget.h" + +#include "../../../../game/cards/card_database_manager.h" +#include "../../../ui/widgets/cards/card_info_picture_widget.h" + +#include + +EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCommanderDetailsDisplayWidget( + QWidget *parent, + const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails) + : QWidget(parent), commanderDetails(_commanderDetails) +{ + layout = new QVBoxLayout(this); + setLayout(layout); + + auto commanderPicture = new CardInfoPictureWidget(this); + commanderPicture->setCard(CardDatabaseManager::getInstance()->getCard(commanderDetails.getName())); + + commanderDetails.debugPrint(); + + label = new QLabel(this); + label->setAlignment(Qt::AlignCenter); + salt = new QLabel(this); + salt->setAlignment(Qt::AlignCenter); + + layout->addWidget(commanderPicture); + layout->addWidget(label); + layout->addWidget(salt); + retranslateUi(); +} + +void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi() +{ + label->setText(commanderDetails.getLabel()); + salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt())); +} \ No newline at end of file diff --git a/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.h b/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.h new file mode 100644 index 000000000..b77f6658d --- /dev/null +++ b/cockatrice/src/client/tabs/api/edhrec/edhrec_commander_api_response_commander_details_display_widget.h @@ -0,0 +1,26 @@ +#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H +#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H + +#include "api_response/edhrec_commander_api_response_commander_details.h" + +#include +#include +#include + +class EdhrecCommanderResponseCommanderDetailsDisplayWidget : public QWidget +{ + Q_OBJECT +public: + explicit EdhrecCommanderResponseCommanderDetailsDisplayWidget( + QWidget *parent, + const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails); + void retranslateUi(); + +private: + QLabel *label; + QLabel *salt; + QVBoxLayout *layout; + EdhrecCommanderApiResponseCommanderDetails commanderDetails; +}; + +#endif // EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H