From 2d59540f1536b3113ab5f0e71d5cc942dab7b3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 16 Dec 2024 01:40:32 +0100 Subject: [PATCH] Boop the mainboard/sideboard label and the cardCount after a little bit of delay to make sure they initialize at the right size. --- .../printing_selector/all_zones_card_amount_widget.cpp | 7 ++++++- .../ui/widgets/printing_selector/card_amount_widget.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/client/ui/widgets/printing_selector/all_zones_card_amount_widget.cpp b/cockatrice/src/client/ui/widgets/printing_selector/all_zones_card_amount_widget.cpp index 4664c4abc..c72604d6e 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/all_zones_card_amount_widget.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/all_zones_card_amount_widget.cpp @@ -2,6 +2,8 @@ #include "../general/display/shadow_background_label.h" +#include + 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); } diff --git a/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp b/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp index 3ae4fe9b5..00eec6f9b 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp @@ -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); });