Get rid of cardCornerRadius property

This commit is contained in:
Basile Clément 2025-03-21 19:24:06 +01:00
parent 8389884aae
commit 6b5acb7fa0
No known key found for this signature in database
8 changed files with 8 additions and 21 deletions

View file

@ -86,8 +86,8 @@ void CardInfoPictureEnlargedWidget::paintEvent(QPaintEvent *event)
QPoint topLeft{(width() - scaledSize.width()) / 2, (height() - scaledSize.height()) / 2}; QPoint topLeft{(width() - scaledSize.width()) / 2, (height() - scaledSize.height()) / 2};
// Define the radius for rounded corners // Define the radius for rounded corners
qreal radius = SettingsCache::instance().getCardCornerRadius() * // Adjust the radius as needed for rounded corners
scaledSize.width(); // Adjust the radius as needed for rounded corners qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * scaledSize.width() : 0.;
QStylePainter painter(this); QStylePainter painter(this);
// Fill the background with transparent color to ensure rounded corners are rendered properly // Fill the background with transparent color to ensure rounded corners are rendered properly

View file

@ -191,8 +191,8 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event)
QRect targetRect{targetX, targetY, targetW, targetH}; QRect targetRect{targetX, targetY, targetW, targetH};
// Compute rounded corner radius // Compute rounded corner radius
qreal radius = SettingsCache::instance().getCardCornerRadius() * // Ensure consistent rounding
static_cast<qreal>(targetRect.width()); // Ensure consistent rounding qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * static_cast<qreal>(targetRect.width()) : 0.;
// Draw the pixmap with rounded corners // Draw the pixmap with rounded corners
QStylePainter painter(this); QStylePainter painter(this);

View file

@ -50,7 +50,7 @@ AbstractCardDragItem::~AbstractCardDragItem()
QPainterPath AbstractCardDragItem::shape() const QPainterPath AbstractCardDragItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -48,7 +48,7 @@ QRectF AbstractCardItem::boundingRect() const
QPainterPath AbstractCardItem::shape() const QPainterPath AbstractCardItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -97,7 +97,7 @@ void DeckViewCard::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
pen.setJoinStyle(Qt::MiterJoin); pen.setJoinStyle(Qt::MiterJoin);
pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red); pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red);
painter->setPen(pen); painter->setPen(pen);
qreal cardRadius = SettingsCache::instance().getCardCornerRadius() * (CARD_WIDTH - 3); qreal cardRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * (CARD_WIDTH - 3) : 0.0;
painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius); painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius);
painter->restore(); painter->restore();
} }

View file

@ -38,7 +38,7 @@ QRectF PileZone::boundingRect() const
QPainterPath PileZone::shape() const QPainterPath PileZone::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -332,14 +332,6 @@ SettingsCache::SettingsCache()
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool(); rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
clientID = settings->value("personal/clientid", CLIENT_INFO_NOT_SET).toString(); clientID = settings->value("personal/clientid", CLIENT_INFO_NOT_SET).toString();
clientVersion = settings->value("personal/clientversion", CLIENT_INFO_NOT_SET).toString(); clientVersion = settings->value("personal/clientversion", CLIENT_INFO_NOT_SET).toString();
connect(this, &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCornersChanged) {
if (_roundCardCornersChanged) {
emit cardCornerRadiusChanged(0.05);
} else {
emit cardCornerRadiusChanged(0.);
}
});
} }
void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus) void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus)

View file

@ -84,7 +84,6 @@ signals:
void downloadSpoilerStatusChanged(); void downloadSpoilerStatusChanged();
void useTearOffMenusChanged(bool state); void useTearOffMenusChanged(bool state);
void roundCardCornersChanged(bool roundCardCorners); void roundCardCornersChanged(bool roundCardCorners);
void cardCornerRadiusChanged(qreal cardCornerRadius);
private: private:
QSettings *settings; QSettings *settings;
@ -735,10 +734,6 @@ public:
{ {
return roundCardCorners; return roundCardCorners;
} }
qreal getCardCornerRadius() const
{
return roundCardCorners ? 0.05 : 0.;
}
static SettingsCache &instance(); static SettingsCache &instance();
void resetPaths(); void resetPaths();