mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Fonts] Migrate CardText surfaces to theme font role
This commit is contained in:
parent
145f7adf73
commit
ee2e0a9fa0
18 changed files with 121 additions and 26 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../interface/card_localization.h"
|
#include "../../interface/card_localization.h"
|
||||||
#include "../../interface/card_picture_loader/card_picture_loader.h"
|
#include "../../interface/card_picture_loader/card_picture_loader.h"
|
||||||
|
#include "../../interface/theme_manager.h"
|
||||||
#include "../card_dimensions.h"
|
#include "../card_dimensions.h"
|
||||||
#include "../game_scene.h"
|
#include "../game_scene.h"
|
||||||
#include "../z_values.h"
|
#include "../z_values.h"
|
||||||
|
|
@ -146,7 +147,7 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
|
||||||
painter->rotate(angle);
|
painter->rotate(angle);
|
||||||
painter->translate(-translatedSize.width() / 2, -translatedSize.height() / 2);
|
painter->translate(-translatedSize.width() / 2, -translatedSize.height() / 2);
|
||||||
|
|
||||||
QFont f;
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
f.setPixelSize(fontSize * scale);
|
f.setPixelSize(fontSize * scale);
|
||||||
|
|
||||||
painter->setFont(f);
|
painter->setFont(f);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include "abstract_graphics_item.h"
|
#include "abstract_graphics_item.h"
|
||||||
|
|
||||||
|
#include "../../interface/theme_manager.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
|
@ -20,7 +22,7 @@ void AbstractGraphicsItem::paintNumberEllipse(int number,
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QString numStr = QString::number(number);
|
QString numStr = QString::number(number);
|
||||||
QFont font("Serif");
|
QFont font = themeManager->appFont(AppFont::CardText);
|
||||||
font.setPixelSize(fontSize);
|
font.setPixelSize(fontSize);
|
||||||
font.setWeight(QFont::Bold);
|
font.setWeight(QFont::Bold);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "counter_general.h"
|
#include "counter_general.h"
|
||||||
|
|
||||||
#include "../../interface/pixel_map_generator.h"
|
#include "../../interface/pixel_map_generator.h"
|
||||||
|
#include "../../interface/theme_manager.h"
|
||||||
#include "abstract_graphics_item.h"
|
#include "abstract_graphics_item.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
@ -41,7 +42,7 @@ void GeneralCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /
|
||||||
painter->drawPixmap(QPoint(0, 0), pixmap);
|
painter->drawPixmap(QPoint(0, 0), pixmap);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
QFont f("Serif");
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
f.setPixelSize(qMax((int)(radius * scaleFactor), 10));
|
f.setPixelSize(qMax((int)(radius * scaleFactor), 10));
|
||||||
f.setWeight(QFont::Bold);
|
f.setWeight(QFont::Bold);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../../game/player/player_info.h"
|
#include "../../game/player/player_info.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../../game/player/player_logic.h"
|
||||||
#include "../../interface/pixel_map_generator.h"
|
#include "../../interface/pixel_map_generator.h"
|
||||||
|
#include "../../interface/theme_manager.h"
|
||||||
#include "../board/abstract_counter.h"
|
#include "../board/abstract_counter.h"
|
||||||
#include "../board/abstract_graphics_item.h"
|
#include "../board/abstract_graphics_item.h"
|
||||||
#include "../board/arrow_target.h"
|
#include "../board/arrow_target.h"
|
||||||
|
|
@ -76,7 +77,7 @@ void PlayerCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*
|
||||||
|
|
||||||
QRectF translatedRect = path.controlPointRect();
|
QRectF translatedRect = path.controlPointRect();
|
||||||
QSize translatedSize = translatedRect.size().toSize();
|
QSize translatedSize = translatedRect.size().toSize();
|
||||||
QFont font("Serif");
|
QFont font = themeManager->appFont(AppFont::CardText);
|
||||||
font.setWeight(QFont::Bold);
|
font.setWeight(QFont::Bold);
|
||||||
font.setPixelSize(qMax(qRound(translatedSize.height() / 1.3), 9));
|
font.setPixelSize(qMax(qRound(translatedSize.height() / 1.3), 9));
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
|
|
@ -226,7 +227,7 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
|
||||||
name = name.mid(0, 10) + "...";
|
name = name.mid(0, 10) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont font;
|
QFont font = themeManager->appFont(AppFont::CardText);
|
||||||
font.setPixelSize(qMax(qRound(translatedNameRect.height() / 1.5), 9));
|
font.setPixelSize(qMax(qRound(translatedNameRect.height() / 1.5), 9));
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
painter->setPen(Qt::white);
|
painter->setPen(Qt::white);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "art_crop_attribution.h"
|
#include "art_crop_attribution.h"
|
||||||
|
|
||||||
|
#include "../../theme_manager.h"
|
||||||
#include "libcockatrice/card/printing/printing_info.h"
|
#include "libcockatrice/card/printing/printing_info.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
@ -35,7 +36,10 @@ QRectF paintArtAttribution(QPainter &painter,
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
|
|
||||||
|
// Family comes from the CardText theme role; the incoming painter size
|
||||||
|
// stays the basis for the scale factor exactly as before.
|
||||||
QFont font = painter.font();
|
QFont font = painter.font();
|
||||||
|
font.setFamily(themeManager->appFont(AppFont::CardText).family());
|
||||||
font.setPointSizeF(qMax(6.0, font.pointSizeF() * scale));
|
font.setPointSizeF(qMax(6.0, font.pointSizeF() * scale));
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include "card_info_picture_with_text_overlay_widget.h"
|
#include "card_info_picture_with_text_overlay_widget.h"
|
||||||
|
|
||||||
|
#include "../../theme_manager.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
@ -43,6 +45,7 @@ CardInfoPictureWithTextOverlayWidget::CardInfoPictureWithTextOverlayWidget(QWidg
|
||||||
fontSize(fontSize), textAlignment(alignment), highlighted(false)
|
fontSize(fontSize), textAlignment(alignment), highlighted(false)
|
||||||
{
|
{
|
||||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
connect(themeManager, &ThemeManager::fontsChanged, this, &CardInfoPictureWithTextOverlayWidget::applyCardTextFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,6 +100,13 @@ void CardInfoPictureWithTextOverlayWidget::setTextAlignment(const Qt::Alignment
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardInfoPictureWithTextOverlayWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
// The overlay paint reads the CardText role font at paint time, so a
|
||||||
|
// theme font change only needs a repaint here.
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void CardInfoPictureWithTextOverlayWidget::setHighlighted(bool _highlighted)
|
void CardInfoPictureWithTextOverlayWidget::setHighlighted(bool _highlighted)
|
||||||
{
|
{
|
||||||
if (highlighted == _highlighted) {
|
if (highlighted == _highlighted) {
|
||||||
|
|
@ -168,8 +178,10 @@ void CardInfoPictureWithTextOverlayWidget::paintEvent(QPaintEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the optimal font size
|
// Calculate the optimal font size. The family comes from the CardText
|
||||||
QFont font = painter.font();
|
// theme role; the fontSize member stays the starting size and the
|
||||||
|
// shrink-to-fit logic below is unchanged.
|
||||||
|
QFont font = themeManager->appFont(AppFont::CardText);
|
||||||
int optimalFontSize = fontSize; // Start with the user-defined font size
|
int optimalFontSize = fontSize; // Start with the user-defined font size
|
||||||
const QFontMetrics baseMetrics(font);
|
const QFontMetrics baseMetrics(font);
|
||||||
int textWidth = pixmapRect.width();
|
int textWidth = pixmapRect.width();
|
||||||
|
|
@ -284,7 +296,7 @@ QSize CardInfoPictureWithTextOverlayWidget::minimumSizeHint() const
|
||||||
const QSize pixmapSize = pixmap.isNull() ? QSize(0, 0) : pixmap.size();
|
const QSize pixmapSize = pixmap.isNull() ? QSize(0, 0) : pixmap.size();
|
||||||
|
|
||||||
// Get the font metrics for the overlay text
|
// Get the font metrics for the overlay text
|
||||||
QFont font;
|
QFont font = themeManager->appFont(AppFont::CardText);
|
||||||
font.setPointSize(fontSize);
|
font.setPointSize(fontSize);
|
||||||
const QFontMetrics fontMetrics(font);
|
const QFontMetrics fontMetrics(font);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ protected:
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
[[nodiscard]] QSize minimumSizeHint() const override;
|
[[nodiscard]] QSize minimumSizeHint() const override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyCardTextFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawOutlinedText(QPainter &painter,
|
void drawOutlinedText(QPainter &painter,
|
||||||
const QRect &textRect,
|
const QRect &textRect,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "all_zones_card_amount_widget.h"
|
#include "all_zones_card_amount_widget.h"
|
||||||
|
|
||||||
|
#include "../../theme_manager.h"
|
||||||
#include "../general/display/shadow_background_label.h"
|
#include "../general/display/shadow_background_label.h"
|
||||||
#include "card_amount_widget.h"
|
#include "card_amount_widget.h"
|
||||||
#include "libcockatrice/card/card_info.h"
|
#include "libcockatrice/card/card_info.h"
|
||||||
|
|
@ -67,6 +68,7 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
|
||||||
buttonBoxSideboard->setVisible(!isToken);
|
buttonBoxSideboard->setVisible(!isToken);
|
||||||
|
|
||||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &AllZonesCardAmountWidget::adjustFontSize);
|
connect(cardSizeSlider, &QSlider::valueChanged, this, &AllZonesCardAmountWidget::adjustFontSize);
|
||||||
|
connect(themeManager, &ThemeManager::fontsChanged, this, &AllZonesCardAmountWidget::applyCardTextFont);
|
||||||
|
|
||||||
QTimer::singleShot(10, this, [this]() { adjustFontSize(this->cardSizeSlider->value()); });
|
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;
|
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||||
|
|
||||||
// Update the font labels
|
// Update the font labels. The family comes from the CardText theme
|
||||||
QFont zoneLabelFont = zoneLabelMainboard->font();
|
// role; the slider-driven point size stays as before.
|
||||||
|
QFont zoneLabelFont = themeManager->appFont(AppFont::CardText);
|
||||||
zoneLabelFont.setPointSize(newFontSize);
|
zoneLabelFont.setPointSize(newFontSize);
|
||||||
zoneLabelMainboard->setFont(zoneLabelFont);
|
zoneLabelMainboard->setFont(zoneLabelFont);
|
||||||
zoneLabelSideboard->setFont(zoneLabelFont);
|
zoneLabelSideboard->setFont(zoneLabelFont);
|
||||||
|
|
@ -101,6 +104,11 @@ void AllZonesCardAmountWidget::adjustFontSize(int scalePercentage)
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllZonesCardAmountWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
adjustFontSize(cardSizeSlider->value());
|
||||||
|
}
|
||||||
|
|
||||||
void AllZonesCardAmountWidget::setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount)
|
void AllZonesCardAmountWidget::setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount)
|
||||||
{
|
{
|
||||||
buttonBoxMainboard->setAmount(mainboardAmount);
|
buttonBoxMainboard->setAmount(mainboardAmount);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ public slots:
|
||||||
void adjustFontSize(int scalePercentage);
|
void adjustFontSize(int scalePercentage);
|
||||||
void setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount);
|
void setAmounts(int mainboardAmount, int sideboardAmount, int tokensboardAmount);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyCardTextFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
QSlider *cardSizeSlider;
|
QSlider *cardSizeSlider;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "card_amount_widget.h"
|
#include "card_amount_widget.h"
|
||||||
|
|
||||||
|
#include "../../theme_manager.h"
|
||||||
#include "../deck_editor/deck_state_manager.h"
|
#include "../deck_editor/deck_state_manager.h"
|
||||||
#include "../general/display/dynamic_font_size_push_button.h"
|
#include "../general/display/dynamic_font_size_push_button.h"
|
||||||
#include "deck_list_model.h"
|
#include "deck_list_model.h"
|
||||||
|
|
@ -78,6 +79,7 @@ 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);
|
||||||
|
connect(themeManager, &ThemeManager::fontsChanged, this, &CardAmountWidget::applyCardTextFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardAmountWidget::getAmount()
|
int CardAmountWidget::getAmount()
|
||||||
|
|
@ -139,8 +141,9 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
|
||||||
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
int newFontSize = minFontSize + (scalePercentage - basePercentage) * (maxFontSize - minFontSize) / 225;
|
||||||
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
newFontSize = std::clamp(newFontSize, minFontSize, maxFontSize);
|
||||||
|
|
||||||
// Update the font for card count label
|
// Update the font for card count label. The family comes from the
|
||||||
QFont cardCountFont = cardCountInZone->font();
|
// CardText theme role; the slider-driven point size stays as before.
|
||||||
|
QFont cardCountFont = themeManager->appFont(AppFont::CardText);
|
||||||
cardCountFont.setPointSize(newFontSize);
|
cardCountFont.setPointSize(newFontSize);
|
||||||
cardCountInZone->setFont(cardCountFont);
|
cardCountInZone->setFont(cardCountFont);
|
||||||
|
|
||||||
|
|
@ -151,6 +154,11 @@ void CardAmountWidget::adjustFontSize(int scalePercentage)
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardAmountWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
adjustFontSize(cardSizeSlider->value());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Updates the card count display in the widget.
|
* @brief Updates the card count display in the widget.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ private slots:
|
||||||
void removePrintingSideboard();
|
void removePrintingSideboard();
|
||||||
void removePrintingTokensboard();
|
void removePrintingTokensboard();
|
||||||
void adjustFontSize(int scalePercentage);
|
void adjustFontSize(int scalePercentage);
|
||||||
|
void applyCardTextFont();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CARD_AMOUNT_WIDGET_H
|
#endif // CARD_AMOUNT_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "archidekt_deck_preview_image_display_widget.h"
|
#include "archidekt_deck_preview_image_display_widget.h"
|
||||||
|
|
||||||
|
#include "../../../../../theme_manager.h"
|
||||||
#include "../../../../general/display/shadow_background_label.h"
|
#include "../../../../general/display/shadow_background_label.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
@ -17,13 +18,9 @@ ArchidektDeckPreviewImageDisplayWidget::ArchidektDeckPreviewImageDisplayWidget(Q
|
||||||
bottomLeftLabel = new ShadowBackgroundLabel(this, "");
|
bottomLeftLabel = new ShadowBackgroundLabel(this, "");
|
||||||
bottomRightLabel = new ShadowBackgroundLabel(this, "");
|
bottomRightLabel = new ShadowBackgroundLabel(this, "");
|
||||||
|
|
||||||
QFont f;
|
applyCardTextFont();
|
||||||
f.setBold(true);
|
connect(themeManager, &ThemeManager::fontsChanged, this,
|
||||||
f.setPointSize(16);
|
&ArchidektDeckPreviewImageDisplayWidget::applyCardTextFont);
|
||||||
topLeftLabel->setFont(f);
|
|
||||||
topRightLabel->setFont(f);
|
|
||||||
bottomLeftLabel->setFont(f);
|
|
||||||
bottomRightLabel->setFont(f);
|
|
||||||
|
|
||||||
// Raise so labels appear above image
|
// Raise so labels appear above image
|
||||||
topLeftLabel->raise();
|
topLeftLabel->raise();
|
||||||
|
|
@ -32,6 +29,18 @@ ArchidektDeckPreviewImageDisplayWidget::ArchidektDeckPreviewImageDisplayWidget(Q
|
||||||
bottomRightLabel->raise();
|
bottomRightLabel->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchidektDeckPreviewImageDisplayWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
// Family comes from the CardText theme role; size and weight stay caller-side as before.
|
||||||
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
|
f.setBold(true);
|
||||||
|
f.setPointSize(16);
|
||||||
|
topLeftLabel->setFont(f);
|
||||||
|
topRightLabel->setFont(f);
|
||||||
|
bottomLeftLabel->setFont(f);
|
||||||
|
bottomRightLabel->setFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
void ArchidektDeckPreviewImageDisplayWidget::setAspectRatio(float ratio)
|
void ArchidektDeckPreviewImageDisplayWidget::setAspectRatio(float ratio)
|
||||||
{
|
{
|
||||||
aspectRatio = ratio;
|
aspectRatio = ratio;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyCardTextFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float aspectRatio = 1.0f; ///< Aspect ratio to maintain for the preview image
|
float aspectRatio = 1.0f; ///< Aspect ratio to maintain for the preview image
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "edhrec_api_response_card_details_display_widget.h"
|
#include "edhrec_api_response_card_details_display_widget.h"
|
||||||
|
|
||||||
|
#include "../../../../../../theme_manager.h"
|
||||||
#include "../../../../../cards/card_info_picture_widget.h"
|
#include "../../../../../cards/card_info_picture_widget.h"
|
||||||
#include "../../../../../cards/card_size_widget.h"
|
#include "../../../../../cards/card_size_widget.h"
|
||||||
#include "../../../../../general/display/background_plate_widget.h"
|
#include "../../../../../general/display/background_plate_widget.h"
|
||||||
|
|
@ -9,6 +10,7 @@
|
||||||
#include "edhrec_api_response_card_synergy_display_widget.h"
|
#include "edhrec_api_response_card_synergy_display_widget.h"
|
||||||
#include "libcockatrice/card/database/card_database_querier.h"
|
#include "libcockatrice/card/database/card_database_querier.h"
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
@ -31,7 +33,9 @@ EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWi
|
||||||
nameLabel = new QLabel(this);
|
nameLabel = new QLabel(this);
|
||||||
nameLabel->setText(toDisplay.name);
|
nameLabel->setText(toDisplay.name);
|
||||||
nameLabel->setAlignment(Qt::AlignHCenter);
|
nameLabel->setAlignment(Qt::AlignHCenter);
|
||||||
nameLabel->setStyleSheet("font-size: 20px; font-weight: bold");
|
applyCardTextFont();
|
||||||
|
connect(themeManager, &ThemeManager::fontsChanged, this,
|
||||||
|
&EdhrecApiResponseCardDetailsDisplayWidget::applyCardTextFont);
|
||||||
|
|
||||||
inclusionDisplayWidget = new EdhrecApiResponseCardInclusionDisplayWidget(this, toDisplay);
|
inclusionDisplayWidget = new EdhrecApiResponseCardInclusionDisplayWidget(this, toDisplay);
|
||||||
|
|
||||||
|
|
@ -93,3 +97,13 @@ void EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
|
||||||
{
|
{
|
||||||
emit requestUrl(toDisplay.url);
|
emit requestUrl(toDisplay.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EdhrecApiResponseCardDetailsDisplayWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
// Family comes from the CardText theme role; the 20px size and bold
|
||||||
|
// weight previously carried by the stylesheet stay caller-side.
|
||||||
|
QFont cardFont = themeManager->appFont(AppFont::CardText);
|
||||||
|
cardFont.setPointSize(20);
|
||||||
|
cardFont.setWeight(QFont::Bold);
|
||||||
|
nameLabel->setFont(cardFont);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void requestUrl(QString url);
|
void requestUrl(QString url);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyCardTextFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EdhrecApiResponseCardDetails toDisplay;
|
EdhrecApiResponseCardDetails toDisplay;
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "edhrec_api_response_commander_details_display_widget.h"
|
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||||
|
|
||||||
|
#include "../../../../../../theme_manager.h"
|
||||||
#include "../../../../../cards/card_info_picture_widget.h"
|
#include "../../../../../cards/card_info_picture_widget.h"
|
||||||
#include "../../../../../cards/card_size_widget.h"
|
#include "../../../../../cards/card_size_widget.h"
|
||||||
#include "../../api_response/cards/edhrec_commander_api_response_commander_details.h"
|
#include "../../api_response/cards/edhrec_commander_api_response_commander_details.h"
|
||||||
|
|
@ -8,6 +9,7 @@
|
||||||
#include "edhrec_commander_api_response_navigation_widget.h"
|
#include "edhrec_commander_api_response_navigation_widget.h"
|
||||||
#include "libcockatrice/card/database/card_database_querier.h"
|
#include "libcockatrice/card/database/card_database_querier.h"
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
@ -55,15 +57,16 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
|
||||||
commanderName = new QLabel(this);
|
commanderName = new QLabel(this);
|
||||||
commanderName->setText(commanderDetails.getName());
|
commanderName->setText(commanderDetails.getName());
|
||||||
commanderName->setAlignment(Qt::AlignCenter);
|
commanderName->setAlignment(Qt::AlignCenter);
|
||||||
commanderName->setStyleSheet("font-size: 28px; font-weight: bold");
|
|
||||||
|
|
||||||
label = new QLabel(this);
|
label = new QLabel(this);
|
||||||
label->setAlignment(Qt::AlignCenter);
|
label->setAlignment(Qt::AlignCenter);
|
||||||
label->setStyleSheet("font-size: 16px");
|
|
||||||
|
|
||||||
salt = new QLabel(this);
|
salt = new QLabel(this);
|
||||||
salt->setAlignment(Qt::AlignCenter);
|
salt->setAlignment(Qt::AlignCenter);
|
||||||
salt->setStyleSheet("font-size: 16px");
|
|
||||||
|
applyCardTextFont();
|
||||||
|
connect(themeManager, &ThemeManager::fontsChanged, this,
|
||||||
|
&EdhrecCommanderResponseCommanderDetailsDisplayWidget::applyCardTextFont);
|
||||||
|
|
||||||
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
|
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
|
||||||
|
|
||||||
|
|
@ -90,3 +93,18 @@ void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi()
|
||||||
label->setText(commanderDetails.getLabel());
|
label->setText(commanderDetails.getLabel());
|
||||||
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
|
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::applyCardTextFont()
|
||||||
|
{
|
||||||
|
// Family comes from the CardText theme role; the point sizes and the
|
||||||
|
// bold weight previously carried by the stylesheets stay caller-side.
|
||||||
|
QFont nameFont = themeManager->appFont(AppFont::CardText);
|
||||||
|
nameFont.setPointSize(28);
|
||||||
|
nameFont.setWeight(QFont::Bold);
|
||||||
|
commanderName->setFont(nameFont);
|
||||||
|
|
||||||
|
QFont detailsFont = themeManager->appFont(AppFont::CardText);
|
||||||
|
detailsFont.setPointSize(16);
|
||||||
|
label->setFont(detailsFont);
|
||||||
|
salt->setFont(detailsFont);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ public:
|
||||||
QString baseUrl);
|
QString baseUrl);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyCardTextFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||||
QHBoxLayout *layout;
|
QHBoxLayout *layout;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "card_completer_delegate.h"
|
#include "card_completer_delegate.h"
|
||||||
|
|
||||||
|
#include "../../interface/theme_manager.h"
|
||||||
#include "../../pixel_map_generator.h"
|
#include "../../pixel_map_generator.h"
|
||||||
#include "../cards/additional_info/mana_cost_widget.h"
|
#include "../cards/additional_info/mana_cost_widget.h"
|
||||||
#include "libcockatrice/card/database/card_database_querier.h"
|
#include "libcockatrice/card/database/card_database_querier.h"
|
||||||
|
|
@ -181,7 +182,7 @@ void CardCompleterDelegate::drawManaSymbol(QPainter *p, QPoint centre, const QSt
|
||||||
p->setBrush(Qt::NoBrush);
|
p->setBrush(Qt::NoBrush);
|
||||||
p->drawEllipse(pip.adjusted(1, 1, -1, -1));
|
p->drawEllipse(pip.adjusted(1, 1, -1, -1));
|
||||||
|
|
||||||
QFont f = p->font();
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
f.setPixelSize(qMax(radius - 1, 7));
|
f.setPixelSize(qMax(radius - 1, 7));
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
|
|
||||||
|
|
@ -429,7 +430,7 @@ void CardCompleterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||||
const QRect nameRect = showInfoBand ? QRect(textLeft, rect.top() + 2, textWidth, 20)
|
const QRect nameRect = showInfoBand ? QRect(textLeft, rect.top() + 2, textWidth, 20)
|
||||||
: QRect(textLeft, rect.top() + 2, textWidth, rect.height() - 4);
|
: QRect(textLeft, rect.top() + 2, textWidth, rect.height() - 4);
|
||||||
|
|
||||||
QFont f = option.font;
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
f.setPixelSize(13);
|
f.setPixelSize(13);
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
|
|
||||||
|
|
@ -451,7 +452,7 @@ void CardCompleterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||||
if (showInfoBand) {
|
if (showInfoBand) {
|
||||||
const QRect infoRect(textLeft, rect.top() + 22, textWidth, rect.height() - 24);
|
const QRect infoRect(textLeft, rect.top() + 22, textWidth, rect.height() - 24);
|
||||||
|
|
||||||
QFont f = option.font;
|
QFont f = themeManager->appFont(AppFont::CardText);
|
||||||
f.setPixelSize(10);
|
f.setPixelSize(10);
|
||||||
|
|
||||||
painter->setFont(f);
|
painter->setFont(f);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue