mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 09:03:57 -07:00
[PrintingSelector] Don't change font size
This commit is contained in:
parent
5309dd17be
commit
27e3fff158
2 changed files with 1 additions and 39 deletions
|
|
@ -35,48 +35,13 @@ SetNameAndCollectorsNumberDisplayWidget::SetNameAndCollectorsNumberDisplayWidget
|
|||
collectorsNumber->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
// Store the card size slider and connect its signal to the font size adjustment slot
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &SetNameAndCollectorsNumberDisplayWidget::adjustFontSize);
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &SetNameAndCollectorsNumberDisplayWidget::adjustSize);
|
||||
|
||||
// Add labels to the layout
|
||||
layout->addWidget(setName);
|
||||
layout->addWidget(collectorsNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adjusts the font size of the labels based on the slider value.
|
||||
*
|
||||
* This method adjusts the font size of the set name and collectors number labels
|
||||
* according to the scale percentage provided by the slider. The font size is clamped
|
||||
* to a range between the defined minimum and maximum font sizes.
|
||||
*
|
||||
* @param scalePercentage The scale percentage from the slider.
|
||||
*/
|
||||
void SetNameAndCollectorsNumberDisplayWidget::adjustFontSize(int scalePercentage)
|
||||
{
|
||||
// Define the base font size and the range
|
||||
const int minFontSize = 8; // Minimum font size
|
||||
const int maxFontSize = 32; // Maximum font size
|
||||
const int basePercentage = 100; // Scale at 100%
|
||||
|
||||
// Calculate the new font size
|
||||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||
|
||||
// Clamp the font size to the defined range
|
||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||
|
||||
// Update the fonts for both labels
|
||||
QFont setNameFont = setName->font();
|
||||
setNameFont.setPointSize(newFontSize);
|
||||
setName->setFont(setNameFont);
|
||||
|
||||
QFont collectorsNumberFont = collectorsNumber->font();
|
||||
collectorsNumberFont.setPointSize(newFontSize);
|
||||
collectorsNumber->setFont(collectorsNumberFont);
|
||||
|
||||
// Optionally trigger a resize to accommodate new font size
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles resize events to adjust the height of the set name label.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ public:
|
|||
QSlider *cardSizeSlider);
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void adjustFontSize(int scalePercentage);
|
||||
|
||||
private:
|
||||
QVBoxLayout *layout;
|
||||
QLabel *setName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue