This commit is contained in:
Lukas Brübach 2025-01-22 14:54:08 +01:00
parent 280d1aca26
commit 042bfdac0a
10 changed files with 30 additions and 20 deletions

View file

@ -1,6 +1,7 @@
#include "edhrec_commander_api_response_average_deck_statistics.h"
void EdhrecCommanderApiResponseAverageDeckStatistics::fromJson(const QJsonObject &json) {
void EdhrecCommanderApiResponseAverageDeckStatistics::fromJson(const QJsonObject &json)
{
creature = json.value("creature").toInt(0);
instant = json.value("instant").toInt(0);
sorcery = json.value("sorcery").toInt(0);

View file

@ -1,10 +1,14 @@
#include "edhrec_commander_api_response_card_details.h"
#include <QDebug>
EdhrecCommanderApiResponseCardDetails::EdhrecCommanderApiResponseCardDetails()
: synergy(0.0), inclusion(0), numDecks(0), potentialDecks(0) {}
: synergy(0.0), inclusion(0), numDecks(0), potentialDecks(0)
{
}
void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json) {
void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json)
{
// Parse the fields from the JSON object
name = json.value("name").toString();
sanitized = json.value("sanitized").toString();
@ -17,7 +21,8 @@ void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json) {
potentialDecks = json.value("potential_decks").toInt(0);
}
void EdhrecCommanderApiResponseCardDetails::debugPrint() const {
void EdhrecCommanderApiResponseCardDetails::debugPrint() const
{
// Print out all the fields for debugging
qDebug() << "Name:" << name;
qDebug() << "Sanitized:" << sanitized;

View file

@ -1,4 +1,5 @@
#include "edhrec_commander_api_response_card_list.h"
#include <QDebug>
EdhrecCommanderApiResponseCardList::EdhrecCommanderApiResponseCardList()

View file

@ -1,6 +1,7 @@
#include "edhrec_commander_api_response_commander_details.h"
void EdhrecCommanderApiResponseCommanderDetails::fromJson(const QJsonObject &json) {
void EdhrecCommanderApiResponseCommanderDetails::fromJson(const QJsonObject &json)
{
// Parse card-related data
aetherhubUri = json.value("aetherhub_uri").toString();
archidektUri = json.value("archidekt_uri").toString();
@ -44,7 +45,8 @@ void EdhrecCommanderApiResponseCommanderDetails::fromJson(const QJsonObject &jso
url = json.value("url").toString();
}
void EdhrecCommanderApiResponseCommanderDetails::debugPrint() const {
void EdhrecCommanderApiResponseCommanderDetails::debugPrint() const
{
qDebug() << "Card Data:";
qDebug() << "Aetherhub URI:" << aetherhubUri;
qDebug() << "Archidekt URI:" << archidektUri;

View file

@ -1,4 +1,5 @@
#include "edhrec_commander_api_response_card_details_display_widget.h"
#include "../../../../game/cards/card_database_manager.h"
EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCardDetailsDisplayWidget(
@ -24,13 +25,13 @@ EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCa
labelColor = QColor(255, 0, 0); // Red
} else if (inclusionRate <= 60) {
int red = 255 - ((inclusionRate - 30) * 2);
int green = (inclusionRate - 30) * 4; // Adjust green to make the transition smoother
labelColor = QColor(red, green, 0); // purple-ish
int green = (inclusionRate - 30) * 4; // Adjust green to make the transition smoother
labelColor = QColor(red, green, 0); // purple-ish
} else if (inclusionRate <= 90) {
int green = (inclusionRate - 60) * 5; // Increase green
labelColor = QColor(100, green, 100); // Green shades
int green = (inclusionRate - 60) * 5; // Increase green
labelColor = QColor(100, green, 100); // Green shades
} else {
labelColor = QColor(100, 200, 100); // Dark Green
labelColor = QColor(100, 200, 100); // Dark Green
}
label->setStyleSheet(QString("color: %1").arg(labelColor.name()));

View file

@ -5,14 +5,15 @@
#include "api_response/edhrec_commander_api_response_card_details.h"
#include <QHBoxLayout>
#include <QWidget>
#include <QLabel>
#include <QWidget>
class EdhrecCommanderApiResponseCardDetailsDisplayWidget : public QWidget
{
Q_OBJECT
public:
explicit EdhrecCommanderApiResponseCardDetailsDisplayWidget(QWidget *parent,
explicit EdhrecCommanderApiResponseCardDetailsDisplayWidget(
QWidget *parent,
const EdhrecCommanderApiResponseCardDetails &_toDisplay);
private:

View file

@ -31,7 +31,8 @@ EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget
QStringList widgetNames;
// Add commander details
auto commanderPicture = new EdhrecCommanderResponseCommanderDetailsDisplayWidget(this, response.container.getCommanderDetails());
auto commanderPicture =
new EdhrecCommanderResponseCommanderDetailsDisplayWidget(this, response.container.getCommanderDetails());
cardDisplayLayout->addWidget(commanderPicture);
widgetNames.append("Commander Details");

View file

@ -14,7 +14,7 @@ BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation
bannerLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: white;");
// Layout to center the banner label
QVBoxLayout* layout = new QVBoxLayout(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(bannerLabel);
layout->setContentsMargins(0, 20, 0, 20); // Space for the gradient
setLayout(layout);
@ -37,7 +37,7 @@ void BannerWidget::toggleBuddyVisibility() const
}
}
void BannerWidget::paintEvent(QPaintEvent* event)
void BannerWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
@ -55,7 +55,7 @@ void BannerWidget::paintEvent(QPaintEvent* event)
}
// Set neutral gradient colors with calculated transparency
gradient.setColorAt(0, QColor(200, 200, 200, alpha)); // Light grey with alpha
gradient.setColorAt(0, QColor(200, 200, 200, alpha)); // Light grey with alpha
gradient.setColorAt(1, QColor(100, 100, 100, alpha / 1.5)); // Darker grey, slightly more transparent
// Fill the widget background with the gradient

View file

@ -6,8 +6,6 @@
#include <QLoggingCategory>
#include <QWidget>
#include <qscrollarea.h>
#include <QLoggingCategory>
inline Q_LOGGING_CATEGORY(FlowWidgetLog, "flow_widget");
inline Q_LOGGING_CATEGORY(FlowWidgetSizeLog, "flow_widget.size");

View file

@ -163,7 +163,7 @@ public:
}
~MainWindow() override;
TabSupervisor* getTabSupervisor() const
TabSupervisor *getTabSupervisor() const
{
return tabSupervisor;
}