mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 17:32:15 -07:00
Cleanup from Reading
This commit is contained in:
parent
9f493b2070
commit
9dd2dd4929
22 changed files with 93 additions and 148 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* @file flow_layout.cpp
|
* @file flowLayout.cpp
|
||||||
* @brief Implementation of the FlowLayout class, a custom layout for dynamically organizing widgets
|
* @brief Implementation of the FlowLayout class, a custom layout for dynamically organizing widgets
|
||||||
* in rows within the constraints of available width or parent scroll areas.
|
* in rows within the constraints of available width or parent scroll areas.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ class CardSizeWidget : public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr, int defaultValue = 100);
|
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr, int defaultValue = 100);
|
||||||
QSlider *getSlider() const;
|
[[nodiscard]] QSlider *getSlider() const;
|
||||||
public slots:
|
public slots:
|
||||||
void updateCardSizeSetting(int newValue);
|
static void updateCardSizeSetting(int newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *parent;
|
QWidget *parent;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ void DynamicFontSizeLabel::paintEvent(QPaintEvent *event)
|
||||||
// LOG(true, "Paint delay" << ((float)timer.nsecsElapsed())/1000000.0 << " mS");
|
// LOG(true, "Paint delay" << ((float)timer.nsecsElapsed())/1000000.0 << " mS");
|
||||||
}
|
}
|
||||||
|
|
||||||
float DynamicFontSizeLabel::getWidgetMaximumFontSize(QWidget *widget, QString text)
|
float DynamicFontSizeLabel::getWidgetMaximumFontSize(QWidget *widget, const QString& text)
|
||||||
{
|
{
|
||||||
QFont font = widget->font();
|
QFont font = widget->font();
|
||||||
const QRect widgetRect = widget->contentsRect();
|
const QRect widgetRect = widget->contentsRect();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static float getWidgetMaximumFontSize(QWidget *widget, QString text);
|
static float getWidgetMaximumFontSize(QWidget *widget, const QString& text);
|
||||||
|
|
||||||
/* This method overwrite stylesheet */
|
/* This method overwrite stylesheet */
|
||||||
void setTextColor(QColor color);
|
void setTextColor(QColor color);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ void ShadowBackgroundLabel::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
// Enable anti-aliasing for smoother edges.
|
// Enable antialiasing for smoother edges.
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
// Set semi-transparent black brush and disable border pen.
|
// Set semi-transparent black brush and disable border pen.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "flow_widget.h"
|
#include "flow_widget.h"
|
||||||
|
|
||||||
#include "../../../layouts/flow_layout.h"
|
|
||||||
#include "../../../layouts/horizontal_flow_layout.h"
|
#include "../../../layouts/horizontal_flow_layout.h"
|
||||||
#include "../../../layouts/vertical_flow_layout.h"
|
#include "../../../layouts/vertical_flow_layout.h"
|
||||||
|
|
||||||
|
|
@ -29,21 +28,21 @@ FlowWidget::FlowWidget(QWidget *parent,
|
||||||
// Main Widget and Layout
|
// Main Widget and Layout
|
||||||
this->setMinimumSize(0, 0);
|
this->setMinimumSize(0, 0);
|
||||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
main_layout = new QHBoxLayout();
|
mainLayout = new QHBoxLayout();
|
||||||
this->setLayout(main_layout);
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
// Flow Layout inside the scroll area
|
// Flow Layout inside the scroll area
|
||||||
container = new QWidget();
|
container = new QWidget();
|
||||||
|
|
||||||
if (horizontalPolicy != Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
if (horizontalPolicy != Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
||||||
flow_layout = new HorizontalFlowLayout(container);
|
flowLayout = new HorizontalFlowLayout(container);
|
||||||
} else if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy != Qt::ScrollBarAlwaysOff) {
|
} else if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy != Qt::ScrollBarAlwaysOff) {
|
||||||
flow_layout = new VerticalFlowLayout(container);
|
flowLayout = new VerticalFlowLayout(container);
|
||||||
} else {
|
} else {
|
||||||
flow_layout = new FlowLayout(container, 0, 0, 0);
|
flowLayout = new FlowLayout(container, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
container->setLayout(flow_layout);
|
container->setLayout(flowLayout);
|
||||||
// The container should expand as much as possible, trusting the scrollArea to constrain it.
|
// The container should expand as much as possible, trusting the scrollArea to constrain it.
|
||||||
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
container->setMinimumSize(0, 0);
|
container->setMinimumSize(0, 0);
|
||||||
|
|
@ -60,10 +59,10 @@ FlowWidget::FlowWidget(QWidget *parent,
|
||||||
|
|
||||||
// Use the FlowLayout container directly if we disable the ScrollArea
|
// Use the FlowLayout container directly if we disable the ScrollArea
|
||||||
if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
||||||
main_layout->addWidget(container);
|
mainLayout->addWidget(container);
|
||||||
} else {
|
} else {
|
||||||
scrollArea->setWidget(container);
|
scrollArea->setWidget(container);
|
||||||
main_layout->addWidget(scrollArea);
|
mainLayout->addWidget(scrollArea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +84,7 @@ void FlowWidget::addWidget(QWidget *widget_to_add) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the widget to the flow layout
|
// Add the widget to the flow layout
|
||||||
this->flow_layout->addWidget(widget_to_add);
|
flowLayout->addWidget(widget_to_add);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,23 +94,23 @@ void FlowWidget::addWidget(QWidget *widget_to_add) const
|
||||||
*/
|
*/
|
||||||
void FlowWidget::clearLayout()
|
void FlowWidget::clearLayout()
|
||||||
{
|
{
|
||||||
if (flow_layout != nullptr) {
|
if (flowLayout != nullptr) {
|
||||||
QLayoutItem *item;
|
QLayoutItem *item;
|
||||||
while ((item = flow_layout->takeAt(0)) != nullptr) {
|
while ((item = flowLayout->takeAt(0)) != nullptr) {
|
||||||
item->widget()->deleteLater(); // Delete the widget
|
item->widget()->deleteLater(); // Delete the widget
|
||||||
delete item; // Delete the layout item
|
delete item; // Delete the layout item
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (scrollArea->horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff &&
|
if (scrollArea->horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff &&
|
||||||
scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
|
scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
|
||||||
flow_layout = new HorizontalFlowLayout(container);
|
flowLayout = new HorizontalFlowLayout(container);
|
||||||
} else if (scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff &&
|
} else if (scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff &&
|
||||||
scrollArea->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff) {
|
scrollArea->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff) {
|
||||||
flow_layout = new VerticalFlowLayout(container);
|
flowLayout = new VerticalFlowLayout(container);
|
||||||
} else {
|
} else {
|
||||||
flow_layout = new FlowLayout(container, 0, 0, 0);
|
flowLayout = new FlowLayout(container, 0, 0, 0);
|
||||||
}
|
}
|
||||||
this->container->setLayout(flow_layout);
|
container->setLayout(flowLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,16 +126,14 @@ void FlowWidget::resizeEvent(QResizeEvent *event)
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
|
|
||||||
// Trigger the layout to recalculate
|
// Trigger the layout to recalculate
|
||||||
if (flow_layout != nullptr) {
|
if (flowLayout != nullptr) {
|
||||||
flow_layout->invalidate(); // Marks the layout as dirty and requires recalculation
|
flowLayout->invalidate(); // Marks the layout as dirty and requires recalculation
|
||||||
flow_layout->activate(); // Recalculate the layout based on the new size
|
flowLayout->activate(); // Recalculate the layout based on the new size
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the scroll area and its content adjust correctly
|
// Ensure the scroll area and its content adjust correctly
|
||||||
if (scrollArea != nullptr) {
|
if (scrollArea != nullptr && scrollArea->widget() != nullptr) {
|
||||||
if (scrollArea->widget() != nullptr) {
|
scrollArea->widget()->adjustSize();
|
||||||
scrollArea->widget()->adjustSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,11 +145,9 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
|
||||||
QSize maxSize(0, 0); // Initialize to a zero size
|
QSize maxSize(0, 0); // Initialize to a zero size
|
||||||
|
|
||||||
// Iterate over all widgets in the flow layout to find the maximum sizeHint
|
// Iterate over all widgets in the flow layout to find the maximum sizeHint
|
||||||
for (int i = 0; i < flow_layout->count(); ++i) {
|
for (int i = 0; i < flowLayout->count(); ++i) {
|
||||||
QLayoutItem *item = flow_layout->itemAt(i);
|
if (QLayoutItem *item = flowLayout->itemAt(i)) {
|
||||||
if (item) {
|
if (QWidget *widget = item->widget()) {
|
||||||
QWidget *widget = item->widget();
|
|
||||||
if (widget) {
|
|
||||||
// Update the max size based on the sizeHint of each widget
|
// Update the max size based on the sizeHint of each widget
|
||||||
QSize widgetSizeHint = widget->sizeHint();
|
QSize widgetSizeHint = widget->sizeHint();
|
||||||
maxSize.setWidth(qMax(maxSize.width(), widgetSizeHint.width()));
|
maxSize.setWidth(qMax(maxSize.width(), widgetSizeHint.width()));
|
||||||
|
|
@ -162,11 +157,9 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the minimum size for all widgets to the max sizeHint
|
// Set the minimum size for all widgets to the max sizeHint
|
||||||
for (int i = 0; i < flow_layout->count(); ++i) {
|
for (int i = 0; i < flowLayout->count(); ++i) {
|
||||||
QLayoutItem *item = flow_layout->itemAt(i);
|
if (QLayoutItem *item = flowLayout->itemAt(i)) {
|
||||||
if (item) {
|
if (QWidget *widget = item->widget()) {
|
||||||
QWidget *widget = item->widget();
|
|
||||||
if (widget) {
|
|
||||||
widget->setMinimumSize(maxSize);
|
widget->setMinimumSize(maxSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,10 +168,10 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
|
||||||
|
|
||||||
QLayoutItem *FlowWidget::itemAt(int index) const
|
QLayoutItem *FlowWidget::itemAt(int index) const
|
||||||
{
|
{
|
||||||
return flow_layout->itemAt(index);
|
return flowLayout->itemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowWidget::count() const
|
int FlowWidget::count() const
|
||||||
{
|
{
|
||||||
return flow_layout->count();
|
return flowLayout->count();
|
||||||
}
|
}
|
||||||
|
|
@ -26,8 +26,8 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHBoxLayout *main_layout;
|
QHBoxLayout *mainLayout;
|
||||||
FlowLayout *flow_layout;
|
FlowLayout *flowLayout;
|
||||||
QWidget *container;
|
QWidget *container;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
|
||||||
const int maxFontSize = 32; // Maximum font size
|
const int maxFontSize = 32; // Maximum font size
|
||||||
const int basePercentage = 100; // Scale at 100%
|
const int basePercentage = 100; // Scale at 100%
|
||||||
|
|
||||||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / (250 - 25);
|
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||||
|
|
||||||
// Update the font labels
|
// Update the font labels
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#include "card_amount_widget.h"
|
#include "card_amount_widget.h"
|
||||||
|
|
||||||
#include "../general/display/dynamic_font_size_push_button.h"
|
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,7 +21,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
||||||
QSlider *cardSizeSlider,
|
QSlider *cardSizeSlider,
|
||||||
CardInfoPtr &rootCard,
|
CardInfoPtr &rootCard,
|
||||||
CardInfoPerSet &setInfoForCard,
|
CardInfoPerSet &setInfoForCard,
|
||||||
QString zoneName)
|
const QString& zoneName)
|
||||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
||||||
rootCard(rootCard), setInfoForCard(setInfoForCard), zoneName(zoneName), hovered(false)
|
rootCard(rootCard), setInfoForCard(setInfoForCard), zoneName(zoneName), hovered(false)
|
||||||
{
|
{
|
||||||
|
|
@ -111,7 +109,7 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
|
||||||
const int maxFontSize = 32; ///< Maximum font size
|
const int maxFontSize = 32; ///< Maximum font size
|
||||||
const int basePercentage = 100; ///< Scale at 100%
|
const int basePercentage = 100; ///< Scale at 100%
|
||||||
|
|
||||||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / (250 - 25);
|
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||||
|
|
||||||
// Update the font for card count label
|
// Update the font for card count label
|
||||||
|
|
@ -148,13 +146,11 @@ void CardAmountWidget::addPrinting(const QString &zone)
|
||||||
QModelIndex find_card = deckModel->findCard(rootCard->getName(), zone);
|
QModelIndex find_card = deckModel->findCard(rootCard->getName(), zone);
|
||||||
if (find_card.isValid() && find_card != newCardIndex) {
|
if (find_card.isValid() && find_card != newCardIndex) {
|
||||||
auto amount = deckModel->data(find_card, Qt::DisplayRole);
|
auto amount = deckModel->data(find_card, Qt::DisplayRole);
|
||||||
if (amount.toInt() > 1) {
|
for (int i = 0; i < amount.toInt() - 1; i++) {
|
||||||
for (int i = 0; i < amount.toInt() - 1; i++) {
|
deckModel->addCard(rootCard->getName(), setInfoForCard, zone);
|
||||||
deckModel->addCard(rootCard->getName(), setInfoForCard, zone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
deckModel->removeRow(find_card.row(), find_card.parent());
|
deckModel->removeRow(find_card.row(), find_card.parent());
|
||||||
};
|
}
|
||||||
newCardIndex = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
newCardIndex = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
||||||
setInfoForCard.getProperty("num"));
|
setInfoForCard.getProperty("num"));
|
||||||
deckView->setCurrentIndex(newCardIndex);
|
deckView->setCurrentIndex(newCardIndex);
|
||||||
|
|
@ -237,8 +233,7 @@ void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
||||||
*/
|
*/
|
||||||
void CardAmountWidget::decrementCardHelper(const QString &zone)
|
void CardAmountWidget::decrementCardHelper(const QString &zone)
|
||||||
{
|
{
|
||||||
QModelIndex idx;
|
QModelIndex idx = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
||||||
idx = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
|
||||||
setInfoForCard.getProperty("num"));
|
setInfoForCard.getProperty("num"));
|
||||||
offsetCountAtIndex(idx, -1);
|
offsetCountAtIndex(idx, -1);
|
||||||
}
|
}
|
||||||
|
|
@ -251,8 +246,6 @@ void CardAmountWidget::decrementCardHelper(const QString &zone)
|
||||||
*/
|
*/
|
||||||
int CardAmountWidget::countCardsInZone(const QString &deckZone)
|
int CardAmountWidget::countCardsInZone(const QString &deckZone)
|
||||||
{
|
{
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
if (setInfoForCard.getProperty("uuid").isEmpty()) {
|
if (setInfoForCard.getProperty("uuid").isEmpty()) {
|
||||||
return 0; // Cards without uuids/providerIds CANNOT match another card, they are undefined for us.
|
return 0; // Cards without uuids/providerIds CANNOT match another card, they are undefined for us.
|
||||||
}
|
}
|
||||||
|
|
@ -271,6 +264,8 @@ int CardAmountWidget::countCardsInZone(const QString &deckZone)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
for (auto *i : *listRoot) {
|
for (auto *i : *listRoot) {
|
||||||
auto *countCurrentZone = dynamic_cast<InnerDecklistNode *>(i);
|
auto *countCurrentZone = dynamic_cast<InnerDecklistNode *>(i);
|
||||||
if (!countCurrentZone) {
|
if (!countCurrentZone) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
QSlider *cardSizeSlider,
|
QSlider *cardSizeSlider,
|
||||||
CardInfoPtr &rootCard,
|
CardInfoPtr &rootCard,
|
||||||
CardInfoPerSet &setInfoForCard,
|
CardInfoPerSet &setInfoForCard,
|
||||||
QString zoneName);
|
const QString& zoneName);
|
||||||
int countCardsInZone(const QString &deckZone);
|
int countCardsInZone(const QString &deckZone);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
@ -36,8 +36,6 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
void hideElements();
|
|
||||||
void showElements();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TabDeckEditor *deckEditor;
|
TabDeckEditor *deckEditor;
|
||||||
|
|
@ -53,7 +51,6 @@ private:
|
||||||
QLabel *cardCountInZone;
|
QLabel *cardCountInZone;
|
||||||
|
|
||||||
bool hovered;
|
bool hovered;
|
||||||
QPropertyAnimation *fadeAnimation;
|
|
||||||
|
|
||||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
||||||
void decrementCardHelper(const QString &zoneName);
|
void decrementCardHelper(const QString &zoneName);
|
||||||
|
|
|
||||||
|
|
@ -120,18 +120,18 @@ void PrintingSelector::selectNextCard()
|
||||||
*
|
*
|
||||||
* @param changeBy The direction to change, -1 for previous, 1 for next.
|
* @param changeBy The direction to change, -1 for previous, 1 for next.
|
||||||
*/
|
*/
|
||||||
void PrintingSelector::selectCard(int changeBy)
|
void PrintingSelector::selectCard(const int changeBy)
|
||||||
{
|
{
|
||||||
if (changeBy == 0) {
|
if (changeBy == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current index of the selected item
|
// Get the current index of the selected item
|
||||||
auto currentIndex = deckView->currentIndex();
|
auto deckViewCurrentIndex = deckView->currentIndex();
|
||||||
|
|
||||||
auto nextIndex = currentIndex.siblingAtRow(currentIndex.row() + changeBy);
|
auto nextIndex = deckViewCurrentIndex.siblingAtRow(deckViewCurrentIndex.row() + changeBy);
|
||||||
if (!nextIndex.isValid()) {
|
if (!nextIndex.isValid()) {
|
||||||
nextIndex = currentIndex;
|
nextIndex = deckViewCurrentIndex;
|
||||||
|
|
||||||
// Increment to the next valid index, skipping header rows
|
// Increment to the next valid index, skipping header rows
|
||||||
AbstractDecklistNode *node;
|
AbstractDecklistNode *node;
|
||||||
|
|
@ -151,27 +151,6 @@ void PrintingSelector::selectCard(int changeBy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieves the card set for a specific UUID.
|
|
||||||
*
|
|
||||||
* @param uuid The UUID of the set to retrieve.
|
|
||||||
* @return The CardInfoPerSet associated with the UUID.
|
|
||||||
*/
|
|
||||||
CardInfoPerSet PrintingSelector::getSetForUUID(const QString &uuid)
|
|
||||||
{
|
|
||||||
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
|
||||||
|
|
||||||
for (const auto &cardInfoPerSetList : cardInfoPerSets) {
|
|
||||||
for (const auto &cardInfoPerSet : cardInfoPerSetList) {
|
|
||||||
if (cardInfoPerSet.getProperty("uuid") == uuid) {
|
|
||||||
return cardInfoPerSet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CardInfoPerSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Loads and displays all sets for the current selected card.
|
* @brief Loads and displays all sets for the current selected card.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ class PrintingSelector : public QWidget
|
||||||
public:
|
public:
|
||||||
PrintingSelector(QWidget *parent, TabDeckEditor *deckEditor, DeckListModel *deckModel, QTreeView *deckView);
|
PrintingSelector(QWidget *parent, TabDeckEditor *deckEditor, DeckListModel *deckModel, QTreeView *deckView);
|
||||||
void setCard(const CardInfoPtr &newCard, const QString &_currentZone);
|
void setCard(const CardInfoPtr &newCard, const QString &_currentZone);
|
||||||
CardInfoPerSet getSetForUUID(const QString &uuid);
|
|
||||||
void getAllSetsForCurrentCard();
|
void getAllSetsForCurrentCard();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#include "printing_selector_card_display_widget.h"
|
#include "printing_selector_card_display_widget.h"
|
||||||
|
|
||||||
#include "../../../../deck/deck_loader.h"
|
|
||||||
#include "../../../../game/cards/card_database_manager.h"
|
|
||||||
#include "card_amount_widget.h"
|
#include "card_amount_widget.h"
|
||||||
#include "printing_selector_card_overlay_widget.h"
|
#include "printing_selector_card_overlay_widget.h"
|
||||||
#include "set_name_and_collectors_number_display_widget.h"
|
#include "set_name_and_collectors_number_display_widget.h"
|
||||||
|
|
@ -9,6 +7,7 @@
|
||||||
#include <QGraphicsEffect>
|
#include <QGraphicsEffect>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructs a PrintingSelectorCardDisplayWidget to display card information.
|
* @brief Constructs a PrintingSelectorCardDisplayWidget to display card information.
|
||||||
|
|
@ -29,15 +28,15 @@
|
||||||
* @param currentZone The current zone in which the card is located.
|
* @param currentZone The current zone in which the card is located.
|
||||||
*/
|
*/
|
||||||
PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *parent,
|
PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *parent,
|
||||||
TabDeckEditor *deckEditor,
|
TabDeckEditor *_deckEditor,
|
||||||
DeckListModel *deckModel,
|
DeckListModel *_deckModel,
|
||||||
QTreeView *deckView,
|
QTreeView *_deckView,
|
||||||
QSlider *cardSizeSlider,
|
QSlider *_cardSizeSlider,
|
||||||
CardInfoPtr rootCard,
|
CardInfoPtr _rootCard,
|
||||||
CardInfoPerSet setInfoForCard,
|
const CardInfoPerSet& _setInfoForCard,
|
||||||
QString ¤tZone)
|
QString &_currentZone)
|
||||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), cardSizeSlider(_cardSizeSlider),
|
||||||
rootCard(rootCard), setInfoForCard(setInfoForCard), currentZone(currentZone)
|
rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard), currentZone(_currentZone)
|
||||||
{
|
{
|
||||||
layout = new QVBoxLayout(this);
|
layout = new QVBoxLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
|
||||||
|
|
@ -24,20 +24,19 @@ class PrintingSelectorCardDisplayWidget : public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrintingSelectorCardDisplayWidget(QWidget *parent,
|
PrintingSelectorCardDisplayWidget(QWidget *parent,
|
||||||
TabDeckEditor *deckEditor,
|
TabDeckEditor *_deckEditor,
|
||||||
DeckListModel *deckModel,
|
DeckListModel *_deckModel,
|
||||||
QTreeView *deckView,
|
QTreeView *_deckView,
|
||||||
QSlider *cardSizeSlider,
|
QSlider *_cardSizeSlider,
|
||||||
CardInfoPtr rootCard,
|
CardInfoPtr _rootCard,
|
||||||
CardInfoPerSet setInfoForCard,
|
const CardInfoPerSet& _setInfoForCard,
|
||||||
QString ¤tZone);
|
QString &_currentZone);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clampSetNameToPicture();
|
void clampSetNameToPicture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
AllZonesCardAmountWidget *allZonesCardAmountWidget;
|
|
||||||
SetNameAndCollectorsNumberDisplayWidget *setNameAndCollectorsNumberDisplayWidget;
|
SetNameAndCollectorsNumberDisplayWidget *setNameAndCollectorsNumberDisplayWidget;
|
||||||
TabDeckEditor *deckEditor;
|
TabDeckEditor *deckEditor;
|
||||||
DeckListModel *deckModel;
|
DeckListModel *deckModel;
|
||||||
|
|
@ -47,7 +46,6 @@ private:
|
||||||
CardInfoPtr setCard;
|
CardInfoPtr setCard;
|
||||||
CardInfoPerSet setInfoForCard;
|
CardInfoPerSet setInfoForCard;
|
||||||
QString currentZone;
|
QString currentZone;
|
||||||
CardInfoPictureWidget *cardInfoPicture;
|
|
||||||
PrintingSelectorCardOverlayWidget *overlayWidget;
|
PrintingSelectorCardOverlayWidget *overlayWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructs a PrintingSelectorCardOverlayWidget for displaying a card overlay.
|
* @brief Constructs a PrintingSelectorCardOverlayWidget for displaying a card overlay.
|
||||||
|
|
@ -23,14 +24,14 @@
|
||||||
* @param setInfoForCard The set-specific information for the card being displayed.
|
* @param setInfoForCard The set-specific information for the card being displayed.
|
||||||
*/
|
*/
|
||||||
PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *parent,
|
PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *parent,
|
||||||
TabDeckEditor *deckEditor,
|
TabDeckEditor *_deckEditor,
|
||||||
DeckListModel *deckModel,
|
DeckListModel *_deckModel,
|
||||||
QTreeView *deckView,
|
QTreeView *_deckView,
|
||||||
QSlider *cardSizeSlider,
|
QSlider *_cardSizeSlider,
|
||||||
CardInfoPtr rootCard,
|
CardInfoPtr _rootCard,
|
||||||
CardInfoPerSet setInfoForCard)
|
const CardInfoPerSet &_setInfoForCard)
|
||||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), rootCard(rootCard),
|
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)),
|
||||||
setInfoForCard(setInfoForCard)
|
setInfoForCard(_setInfoForCard)
|
||||||
{
|
{
|
||||||
// Set up the main layout
|
// Set up the main layout
|
||||||
auto *mainLayout = new QVBoxLayout(this);
|
auto *mainLayout = new QVBoxLayout(this);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
#ifndef PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
#ifndef PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
||||||
#define PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
#define PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
||||||
|
|
||||||
#ifndef CARDOVERLAYWIDGET_H
|
|
||||||
#define CARDOVERLAYWIDGET_H
|
|
||||||
|
|
||||||
#include "../../../../client/ui/widgets/cards/card_info_picture_widget.h"
|
#include "../../../../client/ui/widgets/cards/card_info_picture_widget.h"
|
||||||
#include "../../../../deck/deck_list_model.h"
|
#include "../../../../deck/deck_list_model.h"
|
||||||
#include "../../../../deck/deck_view.h"
|
#include "../../../../deck/deck_view.h"
|
||||||
|
|
@ -19,12 +16,12 @@ class PrintingSelectorCardOverlayWidget : public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PrintingSelectorCardOverlayWidget(QWidget *parent,
|
explicit PrintingSelectorCardOverlayWidget(QWidget *parent,
|
||||||
TabDeckEditor *deckEditor,
|
TabDeckEditor *_deckEditor,
|
||||||
DeckListModel *deckModel,
|
DeckListModel *_deckModel,
|
||||||
QTreeView *deckView,
|
QTreeView *_deckView,
|
||||||
QSlider *cardSizeSlider,
|
QSlider *_cardSizeSlider,
|
||||||
CardInfoPtr rootCard,
|
CardInfoPtr _rootCard,
|
||||||
CardInfoPerSet setInfoForCard);
|
const CardInfoPerSet &_setInfoForCard);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
@ -49,6 +46,4 @@ private:
|
||||||
CardInfoPerSet setInfoForCard;
|
CardInfoPerSet setInfoForCard;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CARDOVERLAYWIDGET_H
|
|
||||||
|
|
||||||
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class PrintingSelectorCardSearchWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrintingSelectorCardSearchWidget(PrintingSelector *parent);
|
explicit PrintingSelectorCardSearchWidget(PrintingSelector *parent);
|
||||||
QString getSearchText();
|
QString getSearchText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,9 @@
|
||||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_ALPHABETICAL = tr("Alphabetical");
|
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_ALPHABETICAL = tr("Alphabetical");
|
||||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_PREFERENCE = tr("Preference");
|
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_PREFERENCE = tr("Preference");
|
||||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_RELEASE_DATE = tr("Release Date");
|
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_RELEASE_DATE = tr("Release Date");
|
||||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_CONTAINED_IN_DECK = tr("Contained in Deck");
|
|
||||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_POTENTIAL_CARDS = tr("Potential Cards in Deck");
|
|
||||||
|
|
||||||
const QStringList PrintingSelectorCardSortingWidget::SORT_OPTIONS = {
|
const QStringList PrintingSelectorCardSortingWidget::SORT_OPTIONS = {
|
||||||
SORT_OPTIONS_ALPHABETICAL, SORT_OPTIONS_PREFERENCE, SORT_OPTIONS_RELEASE_DATE, SORT_OPTIONS_CONTAINED_IN_DECK,
|
SORT_OPTIONS_ALPHABETICAL, SORT_OPTIONS_PREFERENCE, SORT_OPTIONS_RELEASE_DATE};
|
||||||
SORT_OPTIONS_POTENTIAL_CARDS};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A widget for sorting and filtering card sets in the Printing Selector.
|
* @brief A widget for sorting and filtering card sets in the Printing Selector.
|
||||||
|
|
@ -131,7 +128,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(CardInfoPerSet
|
||||||
* @return A filtered list of card sets.
|
* @return A filtered list of card sets.
|
||||||
*/
|
*/
|
||||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<CardInfoPerSet> &sets,
|
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<CardInfoPerSet> &sets,
|
||||||
const QString searchText) const
|
const QString& searchText)
|
||||||
{
|
{
|
||||||
if (searchText.isEmpty()) {
|
if (searchText.isEmpty()) {
|
||||||
return sets;
|
return sets;
|
||||||
|
|
@ -163,7 +160,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<
|
||||||
* @return A list of card sets with the printings contained in the deck prepended.
|
* @return A list of card sets with the printings contained in the deck prepended.
|
||||||
*/
|
*/
|
||||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<CardInfoPerSet> &sets,
|
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<CardInfoPerSet> &sets,
|
||||||
CardInfoPtr selectedCard,
|
const CardInfoPtr& selectedCard,
|
||||||
DeckListModel *deckModel)
|
DeckListModel *deckModel)
|
||||||
{
|
{
|
||||||
if (!selectedCard) {
|
if (!selectedCard) {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ class PrintingSelectorCardSortingWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent);
|
explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent);
|
||||||
QList<CardInfoPerSet> sortSets(CardInfoPerSetMap cardInfoPerSets);
|
QList<CardInfoPerSet> sortSets(CardInfoPerSetMap cardInfoPerSets);
|
||||||
QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, QString searchText) const;
|
static QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, const QString& searchText) ;
|
||||||
QList<CardInfoPerSet>
|
static QList<CardInfoPerSet>
|
||||||
prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, CardInfoPtr selectedCard, DeckListModel *deckModel);
|
prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, const CardInfoPtr& selectedCard, DeckListModel *deckModel);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateSortOrder();
|
void updateSortOrder();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
||||||
|
|
||||||
// Set up the expanded widget with its layout
|
// Set up the expanded widget with its layout
|
||||||
expandedWidget = new QWidget(this);
|
expandedWidget = new QWidget(this);
|
||||||
QVBoxLayout *expandedLayout = new QVBoxLayout(expandedWidget);
|
auto *expandedLayout = new QVBoxLayout(expandedWidget);
|
||||||
expandedLayout->setContentsMargins(0, 0, 0, 0);
|
expandedLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
expandedLayout->setSpacing(0);
|
expandedLayout->setSpacing(0);
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
||||||
|
|
||||||
// Set up the collapsed widget with its layout
|
// Set up the collapsed widget with its layout
|
||||||
collapsedWidget = new QWidget(this);
|
collapsedWidget = new QWidget(this);
|
||||||
QHBoxLayout *collapsedLayout = new QHBoxLayout(collapsedWidget);
|
auto *collapsedLayout = new QHBoxLayout(collapsedWidget);
|
||||||
collapsedLayout->setContentsMargins(5, 0, 5, 0);
|
collapsedLayout->setContentsMargins(5, 0, 5, 0);
|
||||||
collapsedLayout->setSpacing(0);
|
collapsedLayout->setSpacing(0);
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
||||||
collapsedLayout->addWidget(expandButton);
|
collapsedLayout->addWidget(expandButton);
|
||||||
|
|
||||||
// Label for collapsed state
|
// Label for collapsed state
|
||||||
QLabel *collapsedLabel = new QLabel(tr("Display Options"), this);
|
auto *collapsedLabel = new QLabel(tr("Display Options"), this);
|
||||||
collapsedLayout->addWidget(collapsedLabel);
|
collapsedLayout->addWidget(collapsedLabel);
|
||||||
|
|
||||||
collapsedWidget->setLayout(collapsedLayout);
|
collapsedWidget->setLayout(collapsedLayout);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ void SetNameAndCollectorsNumberDisplayWidget::adjustFontSize(int scalePercentage
|
||||||
const int basePercentage = 100; // Scale at 100%
|
const int basePercentage = 100; // Scale at 100%
|
||||||
|
|
||||||
// Calculate the new font size
|
// Calculate the new font size
|
||||||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / (250 - 25);
|
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||||
|
|
||||||
// Clamp the font size to the defined range
|
// Clamp the font size to the defined range
|
||||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||||
|
|
|
||||||
|
|
@ -316,14 +316,6 @@ public:
|
||||||
|
|
||||||
return sets[setName][0].getProperty(propertyName);
|
return sets[setName][0].getProperty(propertyName);
|
||||||
}
|
}
|
||||||
void setSetProperty(const QString &, const QString &, const QString &)
|
|
||||||
{
|
|
||||||
// if (!sets.contains(setName))
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// sets[setName].setProperty(_name, _value);
|
|
||||||
// emit cardInfoChanged(smartThis);
|
|
||||||
}
|
|
||||||
|
|
||||||
// related cards
|
// related cards
|
||||||
const QList<CardRelation *> &getRelatedCards() const
|
const QList<CardRelation *> &getRelatedCards() const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue