mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-23 10:52:16 -07:00
Initialize button sizes correctly.
This commit is contained in:
parent
f4904e7c7e
commit
ea9b336a6b
1 changed files with 12 additions and 1 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "../general/display/dynamic_font_size_push_button.h"
|
#include "../general/display/dynamic_font_size_push_button.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
CardAmountWidget::CardAmountWidget(QWidget *parent,
|
CardAmountWidget::CardAmountWidget(QWidget *parent,
|
||||||
TabDeckEditor *deckEditor,
|
TabDeckEditor *deckEditor,
|
||||||
DeckListModel *deckModel,
|
DeckListModel *deckModel,
|
||||||
|
|
@ -18,13 +20,16 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(10);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
layout->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
incrementButton = new DynamicFontSizePushButton(this);
|
incrementButton = new DynamicFontSizePushButton(this);
|
||||||
incrementButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
||||||
incrementButton->setText("+");
|
incrementButton->setText("+");
|
||||||
decrementButton = new DynamicFontSizePushButton(this);
|
decrementButton = new DynamicFontSizePushButton(this);
|
||||||
decrementButton->setText("-");
|
decrementButton->setText("-");
|
||||||
|
|
||||||
|
incrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
|
||||||
|
decrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
|
||||||
|
|
||||||
// Set up connections
|
// Set up connections
|
||||||
if (zoneName == DECK_ZONE_MAIN) {
|
if (zoneName == DECK_ZONE_MAIN) {
|
||||||
connect(incrementButton, &QPushButton::clicked, this, &CardAmountWidget::addPrintingMainboard);
|
connect(incrementButton, &QPushButton::clicked, this, &CardAmountWidget::addPrintingMainboard);
|
||||||
|
|
@ -48,6 +53,12 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
||||||
// Connect slider for dynamic font size adjustment
|
// Connect slider for dynamic font size adjustment
|
||||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardAmountWidget::adjustFontSize);
|
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardAmountWidget::adjustFontSize);
|
||||||
adjustFontSize(cardSizeSlider->value());
|
adjustFontSize(cardSizeSlider->value());
|
||||||
|
|
||||||
|
// Resize after a little delay since, initially, the parent widget has no size.
|
||||||
|
QTimer::singleShot(50, this, [this]() {
|
||||||
|
incrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
|
||||||
|
decrementButton->setFixedSize(parentWidget()->size().width() / 3, parentWidget()->size().height() / 9);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardAmountWidget::paintEvent(QPaintEvent *event)
|
void CardAmountWidget::paintEvent(QPaintEvent *event)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue