Boop the mainboard/sideboard label and the cardCount after a little bit of delay to make sure they initialize at the right size.

This commit is contained in:
Lukas Brübach 2024-12-16 01:40:32 +01:00 committed by ZeldaZach
parent 21e4aa8021
commit 2d59540f15
No known key found for this signature in database
2 changed files with 8 additions and 3 deletions

View file

@ -2,6 +2,8 @@
#include "../general/display/shadow_background_label.h"
#include <QTimer>
AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
TabDeckEditor *deckEditor,
DeckListModel *deckModel,
@ -32,7 +34,10 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
layout->addWidget(buttonBoxSideboard, 0, Qt::AlignHCenter | Qt::AlignTop);
connect(cardSizeSlider, &QSlider::valueChanged, this, &AllZonesCardAmountWidget::adjustFontSize);
adjustFontSize(cardSizeSlider->value());
QTimer::singleShot(10, this, [this]() {
adjustFontSize(this->cardSizeSlider->value());
});
setMouseTracking(true);
}

View file

@ -52,10 +52,10 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
// Connect slider for dynamic font size adjustment
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardAmountWidget::adjustFontSize);
adjustFontSize(cardSizeSlider->value());
// Resize after a little delay since, initially, the parent widget has no size.
QTimer::singleShot(50, this, [this]() {
QTimer::singleShot(10, this, [this]() {
adjustFontSize(this->cardSizeSlider->value());
incrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
decrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
});