mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Fonts] Migrate CardText surfaces to theme font role (#7538)
* [Fonts] Migrate CardText surfaces to theme font role * [Fonts] Keep CardText call sites on the app font and fix px sizes - CardText's unset fallback is qApp->font() again: only the three counter painters (paintNumberEllipse, GeneralCounter, PlayerCounter) were Serif before the role existed, and they now ask for it through ThemeManager::cardTextFont(). Card names, player names, counters, the overlay, the Archidekt and EDHREC labels and the completer delegate keep the app font they used before. - Use setPixelSize for the EDHREC card name (20px) and commander name (28px) and details (16px) sizes: the stylesheets said px, and setPointSize made them about a third larger. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
7a40ed9079
commit
396196b762
20 changed files with 140 additions and 35 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "all_zones_card_amount_widget.h"
|
||||
|
||||
#include "../../theme_manager.h"
|
||||
#include "../general/display/shadow_background_label.h"
|
||||
#include "card_amount_widget.h"
|
||||
#include "libcockatrice/card/card_info.h"
|
||||
|
|
@ -67,6 +68,7 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
|
|||
buttonBoxSideboard->setVisible(!isToken);
|
||||
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &AllZonesCardAmountWidget::adjustFontSize);
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &AllZonesCardAmountWidget::applyCardTextFont);
|
||||
|
||||
QTimer::singleShot(10, this, [this]() { adjustFontSize(this->cardSizeSlider->value()); });
|
||||
|
||||
|
|
@ -90,8 +92,9 @@ void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
|
|||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||
|
||||
// Update the font labels
|
||||
QFont zoneLabelFont = zoneLabelMainboard->font();
|
||||
// Update the font labels. The family comes from the CardText theme
|
||||
// role; the slider-driven point size stays as before.
|
||||
QFont zoneLabelFont = themeManager->appFont(AppFont::CardText);
|
||||
zoneLabelFont.setPointSize(newFontSize);
|
||||
zoneLabelMainboard->setFont(zoneLabelFont);
|
||||
zoneLabelSideboard->setFont(zoneLabelFont);
|
||||
|
|
@ -101,6 +104,11 @@ void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
|
|||
repaint();
|
||||
}
|
||||
|
||||
void AllZonesCardAmountWidget::applyCardTextFont()
|
||||
{
|
||||
adjustFontSize(cardSizeSlider->value());
|
||||
}
|
||||
|
||||
void AllZonesCardAmountWidget::setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount)
|
||||
{
|
||||
buttonBoxMainboard->setAmount(mainboardAmount);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ public slots:
|
|||
void adjustFontSize(int scalePercentage);
|
||||
void setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount);
|
||||
|
||||
private slots:
|
||||
void applyCardTextFont();
|
||||
|
||||
private:
|
||||
QVBoxLayout *layout;
|
||||
QSlider *cardSizeSlider;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "card_amount_widget.h"
|
||||
|
||||
#include "../../theme_manager.h"
|
||||
#include "../deck_editor/deck_state_manager.h"
|
||||
#include "../general/display/dynamic_font_size_push_button.h"
|
||||
#include "deck_list_model.h"
|
||||
|
|
@ -77,6 +78,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
|||
|
||||
// Connect slider for dynamic font size adjustment
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardAmountWidget::adjustFontSize);
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &CardAmountWidget::applyCardTextFont);
|
||||
}
|
||||
|
||||
int CardAmountWidget::getAmount()
|
||||
|
|
@ -138,8 +140,9 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
|
|||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||
|
||||
// Update the font for card count label
|
||||
QFont cardCountFont = cardCountInZone->font();
|
||||
// Update the font for card count label. The family comes from the
|
||||
// CardText theme role; the slider-driven point size stays as before.
|
||||
QFont cardCountFont = themeManager->appFont(AppFont::CardText);
|
||||
cardCountFont.setPointSize(newFontSize);
|
||||
cardCountInZone->setFont(cardCountFont);
|
||||
|
||||
|
|
@ -150,6 +153,11 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
|
|||
repaint();
|
||||
}
|
||||
|
||||
void CardAmountWidget::applyCardTextFont()
|
||||
{
|
||||
adjustFontSize(cardSizeSlider->value());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the card count display in the widget.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ private slots:
|
|||
void removePrintingSideboard();
|
||||
void removePrintingTokensboard();
|
||||
void adjustFontSize(int scalePercentage);
|
||||
void applyCardTextFont();
|
||||
};
|
||||
|
||||
#endif // CARD_AMOUNT_WIDGET_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue