Things and stuff

This commit is contained in:
Lukas Brübach 2025-01-22 10:24:38 +01:00
parent 37c8f4245d
commit 002f83cbb9
6 changed files with 38 additions and 32 deletions

View file

@ -13,7 +13,7 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
layout = new QVBoxLayout(this);
setLayout(layout);
auto commanderPicture = new CardInfoPictureWidget(this);
commanderPicture = new CardInfoPictureWidget(this);
commanderPicture->setCard(CardDatabaseManager::getInstance()->getCard(commanderDetails.getName()));
commanderDetails.debugPrint();

View file

@ -1,6 +1,7 @@
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
#include "../../../ui/widgets/cards/card_info_picture_widget.h"
#include "api_response/edhrec_commander_api_response_commander_details.h"
#include <QLabel>
@ -20,6 +21,7 @@ private:
QLabel *label;
QLabel *salt;
QVBoxLayout *layout;
CardInfoPictureWidget *commanderPicture;
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
};

View file

@ -4,6 +4,7 @@
#include "../../../ui/widgets/cards/card_info_picture_widget.h"
#include "api_response/edhrec_commander_api_response.h"
#include "edhrec_commander_api_response_card_list_display_widget.h"
#include "edhrec_commander_api_response_commander_details_display_widget.h"
#include <QResizeEvent>
@ -16,9 +17,7 @@ EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget
layout->setAlignment(Qt::AlignHCenter);
auto commanderPicture = new CardInfoPictureWidget(this);
commanderPicture->setCard(
CardDatabaseManager::getInstance()->getCard(response.container.getCommanderDetails().getName()));
auto commanderPicture = new EdhrecCommanderResponseCommanderDetailsDisplayWidget(this, response.container.getCommanderDetails());
layout->addWidget(commanderPicture);
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();

View file

@ -18,7 +18,7 @@ TabEdhRec::TabEdhRec(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
scrollArea->setWidgetResizable(true);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// flowWidget = new FlowWidget(this, Qt::Vertical, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
networkManager = new QNetworkAccessManager(this);
setCentralWidget(scrollArea);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
@ -32,13 +32,11 @@ TabEdhRec::TabEdhRec(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
void TabEdhRec::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
qDebug() << "resizeEvent: " << event->size();
if (scrollArea) {
if (scrollArea->widget()) {
scrollArea->widget()->resize(event->size());
}
}
}
void TabEdhRec::retranslateUi()
@ -54,14 +52,14 @@ void TabEdhRec::setCard(CardInfoPtr _cardToQuery)
return;
}
QString cardName = cardToQuery->getName(); // Assuming `getName()` fetches the card's name.
QString cardName = cardToQuery->getName();
QString formattedName = cardName.toLower().replace(" ", "-").remove(QRegularExpression("[^a-z0-9\\-]"));
QString url = QString("https://json.edhrec.com/pages/commanders/%1.json").arg(formattedName);
QNetworkRequest request{QUrl(url)};
networkManager->get(request); // Issue the GET request.
networkManager->get(request);
}
void TabEdhRec::processApiJson(QNetworkReply *reply)

View file

@ -540,6 +540,7 @@ void TabDeckEditor::databaseCustomMenu(QPoint point)
QMenu menu;
const CardInfoPtr info = currentCardInfo();
if (info) {
// add to deck and sideboard options
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRec;
addToDeck = menu.addAction(tr("Add to Deck"));
@ -567,6 +568,7 @@ void TabDeckEditor::databaseCustomMenu(QPoint point)
}
}
menu.exec(databaseView->mapToGlobal(point));
}
}
void TabDeckEditor::decklistCustomMenu(QPoint point)

View file

@ -163,6 +163,11 @@ public:
}
~MainWindow() override;
TabSupervisor* getTabSupervisor() const
{
return tabSupervisor;
}
protected:
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent *event) override;