mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02: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
|
||||
* in rows within the constraints of available width or parent scroll areas.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ class CardSizeWidget : public QWidget
|
|||
|
||||
public:
|
||||
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr, int defaultValue = 100);
|
||||
QSlider *getSlider() const;
|
||||
[[nodiscard]] QSlider *getSlider() const;
|
||||
public slots:
|
||||
void updateCardSizeSetting(int newValue);
|
||||
static void updateCardSizeSetting(int newValue);
|
||||
|
||||
private:
|
||||
QWidget *parent;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void DynamicFontSizeLabel::paintEvent(QPaintEvent *event)
|
|||
// 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();
|
||||
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 */
|
||||
void setTextColor(QColor color);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void ShadowBackgroundLabel::paintEvent(QPaintEvent *event)
|
|||
{
|
||||
QPainter painter(this);
|
||||
|
||||
// Enable anti-aliasing for smoother edges.
|
||||
// Enable antialiasing for smoother edges.
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// Set semi-transparent black brush and disable border pen.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "flow_widget.h"
|
||||
|
||||
#include "../../../layouts/flow_layout.h"
|
||||
#include "../../../layouts/horizontal_flow_layout.h"
|
||||
#include "../../../layouts/vertical_flow_layout.h"
|
||||
|
||||
|
|
@ -29,21 +28,21 @@ FlowWidget::FlowWidget(QWidget *parent,
|
|||
// Main Widget and Layout
|
||||
this->setMinimumSize(0, 0);
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
main_layout = new QHBoxLayout();
|
||||
this->setLayout(main_layout);
|
||||
mainLayout = new QHBoxLayout();
|
||||
this->setLayout(mainLayout);
|
||||
|
||||
// Flow Layout inside the scroll area
|
||||
container = new QWidget();
|
||||
|
||||
if (horizontalPolicy != Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
||||
flow_layout = new HorizontalFlowLayout(container);
|
||||
flowLayout = new HorizontalFlowLayout(container);
|
||||
} else if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy != Qt::ScrollBarAlwaysOff) {
|
||||
flow_layout = new VerticalFlowLayout(container);
|
||||
flowLayout = new VerticalFlowLayout(container);
|
||||
} 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.
|
||||
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
container->setMinimumSize(0, 0);
|
||||
|
|
@ -60,10 +59,10 @@ FlowWidget::FlowWidget(QWidget *parent,
|
|||
|
||||
// Use the FlowLayout container directly if we disable the ScrollArea
|
||||
if (horizontalPolicy == Qt::ScrollBarAlwaysOff && verticalPolicy == Qt::ScrollBarAlwaysOff) {
|
||||
main_layout->addWidget(container);
|
||||
mainLayout->addWidget(container);
|
||||
} else {
|
||||
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
|
||||
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()
|
||||
{
|
||||
if (flow_layout != nullptr) {
|
||||
if (flowLayout != nullptr) {
|
||||
QLayoutItem *item;
|
||||
while ((item = flow_layout->takeAt(0)) != nullptr) {
|
||||
while ((item = flowLayout->takeAt(0)) != nullptr) {
|
||||
item->widget()->deleteLater(); // Delete the widget
|
||||
delete item; // Delete the layout item
|
||||
}
|
||||
} else {
|
||||
if (scrollArea->horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff &&
|
||||
scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
|
||||
flow_layout = new HorizontalFlowLayout(container);
|
||||
flowLayout = new HorizontalFlowLayout(container);
|
||||
} else if (scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff &&
|
||||
scrollArea->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff) {
|
||||
flow_layout = new VerticalFlowLayout(container);
|
||||
flowLayout = new VerticalFlowLayout(container);
|
||||
} 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);
|
||||
|
||||
// Trigger the layout to recalculate
|
||||
if (flow_layout != nullptr) {
|
||||
flow_layout->invalidate(); // Marks the layout as dirty and requires recalculation
|
||||
flow_layout->activate(); // Recalculate the layout based on the new size
|
||||
if (flowLayout != nullptr) {
|
||||
flowLayout->invalidate(); // Marks the layout as dirty and requires recalculation
|
||||
flowLayout->activate(); // Recalculate the layout based on the new size
|
||||
}
|
||||
|
||||
// Ensure the scroll area and its content adjust correctly
|
||||
if (scrollArea != nullptr) {
|
||||
if (scrollArea->widget() != nullptr) {
|
||||
scrollArea->widget()->adjustSize();
|
||||
}
|
||||
if (scrollArea != nullptr && scrollArea->widget() != nullptr) {
|
||||
scrollArea->widget()->adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,11 +145,9 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
|
|||
QSize maxSize(0, 0); // Initialize to a zero size
|
||||
|
||||
// Iterate over all widgets in the flow layout to find the maximum sizeHint
|
||||
for (int i = 0; i < flow_layout->count(); ++i) {
|
||||
QLayoutItem *item = flow_layout->itemAt(i);
|
||||
if (item) {
|
||||
QWidget *widget = item->widget();
|
||||
if (widget) {
|
||||
for (int i = 0; i < flowLayout->count(); ++i) {
|
||||
if (QLayoutItem *item = flowLayout->itemAt(i)) {
|
||||
if (QWidget *widget = item->widget()) {
|
||||
// Update the max size based on the sizeHint of each widget
|
||||
QSize widgetSizeHint = widget->sizeHint();
|
||||
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
|
||||
for (int i = 0; i < flow_layout->count(); ++i) {
|
||||
QLayoutItem *item = flow_layout->itemAt(i);
|
||||
if (item) {
|
||||
QWidget *widget = item->widget();
|
||||
if (widget) {
|
||||
for (int i = 0; i < flowLayout->count(); ++i) {
|
||||
if (QLayoutItem *item = flowLayout->itemAt(i)) {
|
||||
if (QWidget *widget = item->widget()) {
|
||||
widget->setMinimumSize(maxSize);
|
||||
}
|
||||
}
|
||||
|
|
@ -175,10 +168,10 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
|
|||
|
||||
QLayoutItem *FlowWidget::itemAt(int index) const
|
||||
{
|
||||
return flow_layout->itemAt(index);
|
||||
return flowLayout->itemAt(index);
|
||||
}
|
||||
|
||||
int FlowWidget::count() const
|
||||
{
|
||||
return flow_layout->count();
|
||||
return flowLayout->count();
|
||||
}
|
||||
|
|
@ -26,8 +26,8 @@ protected:
|
|||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
QHBoxLayout *main_layout;
|
||||
FlowLayout *flow_layout;
|
||||
QHBoxLayout *mainLayout;
|
||||
FlowLayout *flowLayout;
|
||||
QWidget *container;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
|
|||
const int maxFontSize = 32; // Maximum font size
|
||||
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);
|
||||
|
||||
// Update the font labels
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#include "card_amount_widget.h"
|
||||
|
||||
#include "../general/display/dynamic_font_size_push_button.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +21,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
|||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr &rootCard,
|
||||
CardInfoPerSet &setInfoForCard,
|
||||
QString zoneName)
|
||||
const QString& zoneName)
|
||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
||||
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 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);
|
||||
|
||||
// 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);
|
||||
if (find_card.isValid() && find_card != newCardIndex) {
|
||||
auto amount = deckModel->data(find_card, Qt::DisplayRole);
|
||||
if (amount.toInt() > 1) {
|
||||
for (int i = 0; i < amount.toInt() - 1; i++) {
|
||||
deckModel->addCard(rootCard->getName(), setInfoForCard, zone);
|
||||
}
|
||||
for (int i = 0; i < amount.toInt() - 1; i++) {
|
||||
deckModel->addCard(rootCard->getName(), setInfoForCard, zone);
|
||||
}
|
||||
deckModel->removeRow(find_card.row(), find_card.parent());
|
||||
};
|
||||
}
|
||||
newCardIndex = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
||||
setInfoForCard.getProperty("num"));
|
||||
deckView->setCurrentIndex(newCardIndex);
|
||||
|
|
@ -237,8 +233,7 @@ void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
|||
*/
|
||||
void CardAmountWidget::decrementCardHelper(const QString &zone)
|
||||
{
|
||||
QModelIndex idx;
|
||||
idx = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
||||
QModelIndex idx = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"),
|
||||
setInfoForCard.getProperty("num"));
|
||||
offsetCountAtIndex(idx, -1);
|
||||
}
|
||||
|
|
@ -251,8 +246,6 @@ void CardAmountWidget::decrementCardHelper(const QString &zone)
|
|||
*/
|
||||
int CardAmountWidget::countCardsInZone(const QString &deckZone)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (setInfoForCard.getProperty("uuid").isEmpty()) {
|
||||
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;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (auto *i : *listRoot) {
|
||||
auto *countCurrentZone = dynamic_cast<InnerDecklistNode *>(i);
|
||||
if (!countCurrentZone) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr &rootCard,
|
||||
CardInfoPerSet &setInfoForCard,
|
||||
QString zoneName);
|
||||
const QString& zoneName);
|
||||
int countCardsInZone(const QString &deckZone);
|
||||
|
||||
public slots:
|
||||
|
|
@ -36,8 +36,6 @@ public slots:
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void hideElements();
|
||||
void showElements();
|
||||
|
||||
private:
|
||||
TabDeckEditor *deckEditor;
|
||||
|
|
@ -53,7 +51,6 @@ private:
|
|||
QLabel *cardCountInZone;
|
||||
|
||||
bool hovered;
|
||||
QPropertyAnimation *fadeAnimation;
|
||||
|
||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
||||
void decrementCardHelper(const QString &zoneName);
|
||||
|
|
|
|||
|
|
@ -120,18 +120,18 @@ void PrintingSelector::selectNextCard()
|
|||
*
|
||||
* @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) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
nextIndex = currentIndex;
|
||||
nextIndex = deckViewCurrentIndex;
|
||||
|
||||
// Increment to the next valid index, skipping header rows
|
||||
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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class PrintingSelector : public QWidget
|
|||
public:
|
||||
PrintingSelector(QWidget *parent, TabDeckEditor *deckEditor, DeckListModel *deckModel, QTreeView *deckView);
|
||||
void setCard(const CardInfoPtr &newCard, const QString &_currentZone);
|
||||
CardInfoPerSet getSetForUUID(const QString &uuid);
|
||||
void getAllSetsForCurrentCard();
|
||||
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#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 "printing_selector_card_overlay_widget.h"
|
||||
#include "set_name_and_collectors_number_display_widget.h"
|
||||
|
|
@ -9,6 +7,7 @@
|
|||
#include <QGraphicsEffect>
|
||||
#include <QStackedWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <utility>
|
||||
|
||||
/**
|
||||
* @brief Constructs a PrintingSelectorCardDisplayWidget to display card information.
|
||||
|
|
@ -29,15 +28,15 @@
|
|||
* @param currentZone The current zone in which the card is located.
|
||||
*/
|
||||
PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *parent,
|
||||
TabDeckEditor *deckEditor,
|
||||
DeckListModel *deckModel,
|
||||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard,
|
||||
QString ¤tZone)
|
||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
||||
rootCard(rootCard), setInfoForCard(setInfoForCard), currentZone(currentZone)
|
||||
TabDeckEditor *_deckEditor,
|
||||
DeckListModel *_deckModel,
|
||||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet& _setInfoForCard,
|
||||
QString &_currentZone)
|
||||
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), cardSizeSlider(_cardSizeSlider),
|
||||
rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard), currentZone(_currentZone)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
|
|
|||
|
|
@ -24,20 +24,19 @@ class PrintingSelectorCardDisplayWidget : public QWidget
|
|||
|
||||
public:
|
||||
PrintingSelectorCardDisplayWidget(QWidget *parent,
|
||||
TabDeckEditor *deckEditor,
|
||||
DeckListModel *deckModel,
|
||||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard,
|
||||
QString ¤tZone);
|
||||
TabDeckEditor *_deckEditor,
|
||||
DeckListModel *_deckModel,
|
||||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet& _setInfoForCard,
|
||||
QString &_currentZone);
|
||||
|
||||
public slots:
|
||||
void clampSetNameToPicture();
|
||||
|
||||
private:
|
||||
QVBoxLayout *layout;
|
||||
AllZonesCardAmountWidget *allZonesCardAmountWidget;
|
||||
SetNameAndCollectorsNumberDisplayWidget *setNameAndCollectorsNumberDisplayWidget;
|
||||
TabDeckEditor *deckEditor;
|
||||
DeckListModel *deckModel;
|
||||
|
|
@ -47,7 +46,6 @@ private:
|
|||
CardInfoPtr setCard;
|
||||
CardInfoPerSet setInfoForCard;
|
||||
QString currentZone;
|
||||
CardInfoPictureWidget *cardInfoPicture;
|
||||
PrintingSelectorCardOverlayWidget *overlayWidget;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QVBoxLayout>
|
||||
#include <utility>
|
||||
|
||||
/**
|
||||
* @brief Constructs a PrintingSelectorCardOverlayWidget for displaying a card overlay.
|
||||
|
|
@ -23,14 +24,14 @@
|
|||
* @param setInfoForCard The set-specific information for the card being displayed.
|
||||
*/
|
||||
PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *parent,
|
||||
TabDeckEditor *deckEditor,
|
||||
DeckListModel *deckModel,
|
||||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard)
|
||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), rootCard(rootCard),
|
||||
setInfoForCard(setInfoForCard)
|
||||
TabDeckEditor *_deckEditor,
|
||||
DeckListModel *_deckModel,
|
||||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard)
|
||||
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)),
|
||||
setInfoForCard(_setInfoForCard)
|
||||
{
|
||||
// Set up the main layout
|
||||
auto *mainLayout = new QVBoxLayout(this);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef 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 "../../../../deck/deck_list_model.h"
|
||||
#include "../../../../deck/deck_view.h"
|
||||
|
|
@ -19,12 +16,12 @@ class PrintingSelectorCardOverlayWidget : public QWidget
|
|||
|
||||
public:
|
||||
explicit PrintingSelectorCardOverlayWidget(QWidget *parent,
|
||||
TabDeckEditor *deckEditor,
|
||||
DeckListModel *deckModel,
|
||||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard);
|
||||
TabDeckEditor *_deckEditor,
|
||||
DeckListModel *_deckModel,
|
||||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
@ -49,6 +46,4 @@ private:
|
|||
CardInfoPerSet setInfoForCard;
|
||||
};
|
||||
|
||||
#endif // CARDOVERLAYWIDGET_H
|
||||
|
||||
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class PrintingSelectorCardSearchWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrintingSelectorCardSearchWidget(PrintingSelector *parent);
|
||||
explicit PrintingSelectorCardSearchWidget(PrintingSelector *parent);
|
||||
QString getSearchText();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -6,12 +6,9 @@
|
|||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_ALPHABETICAL = tr("Alphabetical");
|
||||
const QString PrintingSelectorCardSortingWidget::SORT_OPTIONS_PREFERENCE = tr("Preference");
|
||||
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 = {
|
||||
SORT_OPTIONS_ALPHABETICAL, SORT_OPTIONS_PREFERENCE, SORT_OPTIONS_RELEASE_DATE, SORT_OPTIONS_CONTAINED_IN_DECK,
|
||||
SORT_OPTIONS_POTENTIAL_CARDS};
|
||||
SORT_OPTIONS_ALPHABETICAL, SORT_OPTIONS_PREFERENCE, SORT_OPTIONS_RELEASE_DATE};
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<CardInfoPerSet> &sets,
|
||||
const QString searchText) const
|
||||
const QString& searchText)
|
||||
{
|
||||
if (searchText.isEmpty()) {
|
||||
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.
|
||||
*/
|
||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<CardInfoPerSet> &sets,
|
||||
CardInfoPtr selectedCard,
|
||||
const CardInfoPtr& selectedCard,
|
||||
DeckListModel *deckModel)
|
||||
{
|
||||
if (!selectedCard) {
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ class PrintingSelectorCardSortingWidget : public QWidget
|
|||
public:
|
||||
explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent);
|
||||
QList<CardInfoPerSet> sortSets(CardInfoPerSetMap cardInfoPerSets);
|
||||
QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, QString searchText) const;
|
||||
QList<CardInfoPerSet>
|
||||
prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, CardInfoPtr selectedCard, DeckListModel *deckModel);
|
||||
static QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, const QString& searchText) ;
|
||||
static QList<CardInfoPerSet>
|
||||
prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, const CardInfoPtr& selectedCard, DeckListModel *deckModel);
|
||||
|
||||
public slots:
|
||||
void updateSortOrder();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
|||
|
||||
// Set up the expanded widget with its layout
|
||||
expandedWidget = new QWidget(this);
|
||||
QVBoxLayout *expandedLayout = new QVBoxLayout(expandedWidget);
|
||||
auto *expandedLayout = new QVBoxLayout(expandedWidget);
|
||||
expandedLayout->setContentsMargins(0, 0, 0, 0);
|
||||
expandedLayout->setSpacing(0);
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
|||
|
||||
// Set up the collapsed widget with its layout
|
||||
collapsedWidget = new QWidget(this);
|
||||
QHBoxLayout *collapsedLayout = new QHBoxLayout(collapsedWidget);
|
||||
auto *collapsedLayout = new QHBoxLayout(collapsedWidget);
|
||||
collapsedLayout->setContentsMargins(5, 0, 5, 0);
|
||||
collapsedLayout->setSpacing(0);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidg
|
|||
collapsedLayout->addWidget(expandButton);
|
||||
|
||||
// Label for collapsed state
|
||||
QLabel *collapsedLabel = new QLabel(tr("Display Options"), this);
|
||||
auto *collapsedLabel = new QLabel(tr("Display Options"), this);
|
||||
collapsedLayout->addWidget(collapsedLabel);
|
||||
|
||||
collapsedWidget->setLayout(collapsedLayout);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void SetNameAndCollectorsNumberDisplayWidget::adjustFontSize(int scalePercentage
|
|||
const int basePercentage = 100; // Scale at 100%
|
||||
|
||||
// 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
|
||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||
|
|
|
|||
|
|
@ -316,14 +316,6 @@ public:
|
|||
|
||||
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
|
||||
const QList<CardRelation *> &getRelatedCards() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue