mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
Update mainboard/sideboard labels correctly.
This commit is contained in:
parent
f3a7be7e3f
commit
f4904e7c7e
4 changed files with 28 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ public:
|
|||
void enterEvent(QEvent *event) override;
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void adjustFontSize(int scalePercentage);
|
||||
|
||||
private:
|
||||
QVBoxLayout *layout;
|
||||
TabDeckEditor *deckEditor;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue