Update mainboard/sideboard labels correctly.

This commit is contained in:
Lukas Brübach 2024-12-16 00:50:43 +01:00 committed by ZeldaZach
parent f3a7be7e3f
commit f4904e7c7e
No known key found for this signature in database
4 changed files with 28 additions and 2 deletions

View file

@ -8,7 +8,7 @@ CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *flowWidget) : parent
cardSizeLabel = new QLabel(tr("Card Size"), this);
cardSizeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
cardSizeSlider = new QSlider(Qt::Horizontal, this);
cardSizeSlider->setRange(25, 250);
cardSizeSlider->setRange(50, 250);
cardSizeSlider->setValue(100);
cardSizeLayout->addWidget(cardSizeLabel);

View file

@ -31,9 +31,32 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
layout->addWidget(zoneLabelSideboard, 0, Qt::AlignHCenter | Qt::AlignBottom);
layout->addWidget(buttonBoxSideboard, 0, Qt::AlignHCenter | Qt::AlignTop);
connect(cardSizeSlider, &QSlider::valueChanged, this, &AllZonesCardAmountWidget::adjustFontSize);
adjustFontSize(cardSizeSlider->value());
setMouseTracking(true);
}
void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
{
qDebug() << scalePercentage;
const int minFontSize = 8; // Minimum font size
const int maxFontSize = 32; // Maximum font size
const int basePercentage = 100; // Scale at 100%
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / (250 - 25);
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
// Update the font labels
QFont zoneLabelFont = zoneLabelMainboard->font();
zoneLabelFont.setPointSize(newFontSize);
zoneLabelMainboard->setFont(zoneLabelFont);
zoneLabelSideboard->setFont(zoneLabelFont);
// Repaint the widget (if necessary)
repaint();
}
int AllZonesCardAmountWidget::getMainboardAmount()
{
return buttonBoxMainboard->countCardsInZone(DECK_ZONE_MAIN);

View file

@ -27,6 +27,9 @@ public:
void enterEvent(QEvent *event) override;
#endif
public slots:
void adjustFontSize(int scalePercentage);
private:
QVBoxLayout *layout;
TabDeckEditor *deckEditor;

View file

@ -67,7 +67,7 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
{
qDebug() << scalePercentage;
const int minFontSize = 8; // Minimum font size
const int maxFontSize = 24; // Maximum font size
const int maxFontSize = 32; // Maximum font size
const int basePercentage = 100; // Scale at 100%
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / (250 - 25);