diff --git a/cockatrice/src/client/ui/widgets/cards/card_info_picture_enlarged_widget.cpp b/cockatrice/src/client/ui/widgets/cards/card_info_picture_enlarged_widget.cpp index 31089e7c4..f16b7a4fb 100644 --- a/cockatrice/src/client/ui/widgets/cards/card_info_picture_enlarged_widget.cpp +++ b/cockatrice/src/client/ui/widgets/cards/card_info_picture_enlarged_widget.cpp @@ -1,6 +1,7 @@ #include "card_info_picture_enlarged_widget.h" #include "../../picture_loader/picture_loader.h" +#include "../../../../settings/cache_settings.h" #include #include @@ -17,6 +18,12 @@ CardInfoPictureEnlargedWidget::CardInfoPictureEnlargedWidget(QWidget *parent) { setWindowFlags(Qt::ToolTip); // Keeps this widget on top of everything setAttribute(Qt::WA_TranslucentBackground); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + update(); + }); } /** @@ -79,7 +86,8 @@ void CardInfoPictureEnlargedWidget::paintEvent(QPaintEvent *event) QPoint topLeft{(width() - scaledSize.width()) / 2, (height() - scaledSize.height()) / 2}; // Define the radius for rounded corners - qreal radius = 0.05 * scaledSize.width(); // Adjust the radius as needed for rounded corners + qreal radius = SettingsCache::instance().getCardCornerRadius() * + scaledSize.width(); // Adjust the radius as needed for rounded corners QStylePainter painter(this); // Fill the background with transparent color to ensure rounded corners are rendered properly diff --git a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp index 592766939..15bed554a 100644 --- a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp +++ b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp @@ -3,7 +3,6 @@ #include "../../../../game/cards/card_database_manager.h" #include "../../../../game/cards/card_item.h" #include "../../../../settings/cache_settings.h" -#include "../../../tabs/tab_deck_editor.h" #include "../../../tabs/tab_supervisor.h" #include "../../picture_loader/picture_loader.h" #include "../../window_main.h" @@ -44,6 +43,12 @@ CardInfoPictureWidget::CardInfoPictureWidget(QWidget *parent, const bool hoverTo hoverTimer = new QTimer(this); hoverTimer->setSingleShot(true); connect(hoverTimer, &QTimer::timeout, this, &CardInfoPictureWidget::showEnlargedPixmap); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + update(); + }); } /** @@ -186,7 +191,8 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event) QRect targetRect{targetX, targetY, targetW, targetH}; // Compute rounded corner radius - qreal radius = 0.05 * static_cast(targetRect.width()); // Ensure consistent rounding + qreal radius = SettingsCache::instance().getCardCornerRadius() * + static_cast(targetRect.width()); // Ensure consistent rounding // Draw the pixmap with rounded corners QStylePainter painter(this); diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index b97155d2a..4989b4a3f 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #define WIKI_CUSTOM_PIC_URL "https://github.com/Cockatrice/Cockatrice/wiki/Custom-Picture-Download-URLs" #define WIKI_CUSTOM_SHORTCUTS "https://github.com/Cockatrice/Cockatrice/wiki/Custom-Keyboard-Shortcuts" @@ -383,6 +384,9 @@ AppearanceSettingsPage::AppearanceSettingsPage() cardScalingCheckBox.setChecked(settings.getScaleCards()); connect(&cardScalingCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setCardScaling); + roundCardCornersCheckBox.setChecked(settings.getRoundCardCorners()); + connect(&roundCardCornersCheckBox, &QAbstractButton::toggled, &settings, &SettingsCache::setRoundCardCorners); + verticalCardOverlapPercentBox.setValue(settings.getStackCardOverlapPercent()); verticalCardOverlapPercentBox.setRange(0, 80); connect(&verticalCardOverlapPercentBox, SIGNAL(valueChanged(int)), &settings, @@ -402,14 +406,15 @@ AppearanceSettingsPage::AppearanceSettingsPage() cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2); cardsGrid->addWidget(&autoRotateSidewaysLayoutCardsCheckBox, 1, 0, 1, 2); cardsGrid->addWidget(&cardScalingCheckBox, 2, 0, 1, 2); - cardsGrid->addWidget(&overrideAllCardArtWithPersonalPreferenceCheckBox, 3, 0, 1, 2); - cardsGrid->addWidget(&bumpSetsWithCardsInDeckToTopCheckBox, 4, 0, 1, 2); - cardsGrid->addWidget(&verticalCardOverlapPercentLabel, 5, 0, 1, 1); - cardsGrid->addWidget(&verticalCardOverlapPercentBox, 5, 1, 1, 1); - cardsGrid->addWidget(&cardViewInitialRowsMaxLabel, 6, 0); - cardsGrid->addWidget(&cardViewInitialRowsMaxBox, 6, 1); - cardsGrid->addWidget(&cardViewExpandedRowsMaxLabel, 7, 0); - cardsGrid->addWidget(&cardViewExpandedRowsMaxBox, 7, 1); + cardsGrid->addWidget(&roundCardCornersCheckBox, 3, 0, 1, 2); + cardsGrid->addWidget(&overrideAllCardArtWithPersonalPreferenceCheckBox, 4, 0, 1, 2); + cardsGrid->addWidget(&bumpSetsWithCardsInDeckToTopCheckBox, 5, 0, 1, 2); + cardsGrid->addWidget(&verticalCardOverlapPercentLabel, 6, 0, 1, 1); + cardsGrid->addWidget(&verticalCardOverlapPercentBox, 6, 1, 1, 1); + cardsGrid->addWidget(&cardViewInitialRowsMaxLabel, 7, 0); + cardsGrid->addWidget(&cardViewInitialRowsMaxBox, 7, 1); + cardsGrid->addWidget(&cardViewExpandedRowsMaxLabel, 8, 0); + cardsGrid->addWidget(&cardViewExpandedRowsMaxBox, 8, 1); cardsGroupBox = new QGroupBox; cardsGroupBox->setLayout(cardsGrid); @@ -540,6 +545,7 @@ void AppearanceSettingsPage::retranslateUi() bumpSetsWithCardsInDeckToTopCheckBox.setText( tr("Bump sets that the deck contains cards from to the top in the printing selector")); cardScalingCheckBox.setText(tr("Scale cards on mouse over")); + roundCardCornersCheckBox.setText(tr("Use rounded card corners")); verticalCardOverlapPercentLabel.setText( tr("Minimum overlap percentage of cards on the stack and in vertical hand")); cardViewInitialRowsMaxLabel.setText(tr("Maximum initial height for card view window:")); diff --git a/cockatrice/src/dialogs/dlg_settings.h b/cockatrice/src/dialogs/dlg_settings.h index ec295a618..95ae17979 100644 --- a/cockatrice/src/dialogs/dlg_settings.h +++ b/cockatrice/src/dialogs/dlg_settings.h @@ -107,6 +107,7 @@ private: QCheckBox overrideAllCardArtWithPersonalPreferenceCheckBox; QCheckBox bumpSetsWithCardsInDeckToTopCheckBox; QCheckBox cardScalingCheckBox; + QCheckBox roundCardCornersCheckBox; QLabel verticalCardOverlapPercentLabel; QSpinBox verticalCardOverlapPercentBox; QLabel cardViewInitialRowsMaxLabel; diff --git a/cockatrice/src/game/cards/abstract_card_drag_item.cpp b/cockatrice/src/game/cards/abstract_card_drag_item.cpp index e9fe30c50..0971831b0 100644 --- a/cockatrice/src/game/cards/abstract_card_drag_item.cpp +++ b/cockatrice/src/game/cards/abstract_card_drag_item.cpp @@ -1,6 +1,6 @@ #include "abstract_card_drag_item.h" -#include "card_database.h" +#include "../../settings/cache_settings.h" #include #include @@ -32,6 +32,13 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, .translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF)); setCacheMode(DeviceCoordinateCache); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + prepareGeometryChange(); + update(); + }); } AbstractCardDragItem::~AbstractCardDragItem() @@ -43,7 +50,8 @@ AbstractCardDragItem::~AbstractCardDragItem() QPainterPath AbstractCardDragItem::shape() const { QPainterPath shape; - shape.addRoundedRect(boundingRect(), 0.05 * CARD_WIDTH, 0.05 * CARD_WIDTH); + qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; + shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); return shape; } diff --git a/cockatrice/src/game/cards/abstract_card_item.cpp b/cockatrice/src/game/cards/abstract_card_item.cpp index 28ed493e7..0b73d5489 100644 --- a/cockatrice/src/game/cards/abstract_card_item.cpp +++ b/cockatrice/src/game/cards/abstract_card_item.cpp @@ -29,6 +29,13 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, refreshCardInfo(); setAcceptHoverEvents(true); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + prepareGeometryChange(); + update(); + }); } AbstractCardItem::~AbstractCardItem() @@ -44,7 +51,8 @@ QRectF AbstractCardItem::boundingRect() const QPainterPath AbstractCardItem::shape() const { QPainterPath shape; - shape.addRoundedRect(boundingRect(), 0.05 * CARD_WIDTH, 0.05 * CARD_WIDTH); + qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; + shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); return shape; } diff --git a/cockatrice/src/game/deckview/deck_view.cpp b/cockatrice/src/game/deckview/deck_view.cpp index bbc25ef6a..94f79e0bd 100644 --- a/cockatrice/src/game/deckview/deck_view.cpp +++ b/cockatrice/src/game/deckview/deck_view.cpp @@ -74,6 +74,13 @@ DeckViewCard::DeckViewCard(QGraphicsItem *parent, : AbstractCardItem(parent, _name, _providerId, 0, -1), originZone(_originZone), dragItem(0) { setAcceptHoverEvents(true); + + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + update(); + }); } DeckViewCard::~DeckViewCard() @@ -91,7 +98,7 @@ void DeckViewCard::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti pen.setJoinStyle(Qt::MiterJoin); pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red); painter->setPen(pen); - qreal cardRadius = 0.05 * (CARD_WIDTH - 3); + qreal cardRadius = SettingsCache::instance().getCardCornerRadius() * (CARD_WIDTH - 3); painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius); painter->restore(); } @@ -519,4 +526,4 @@ void DeckView::clearDeck() void DeckView::resetSideboardPlan() { deckViewScene->resetSideboardPlan(); -} \ No newline at end of file +} diff --git a/cockatrice/src/game/zones/pile_zone.cpp b/cockatrice/src/game/zones/pile_zone.cpp index b2645bd6a..62fa44a77 100644 --- a/cockatrice/src/game/zones/pile_zone.cpp +++ b/cockatrice/src/game/zones/pile_zone.cpp @@ -21,6 +21,13 @@ PileZone::PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _c .translate((float)CARD_WIDTH / 2, (float)CARD_HEIGHT / 2) .rotate(90) .translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2)); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + prepareGeometryChange(); + update(); + }); } QRectF PileZone::boundingRect() const @@ -31,7 +38,8 @@ QRectF PileZone::boundingRect() const QPainterPath PileZone::shape() const { QPainterPath shape; - shape.addRoundedRect(boundingRect(), 0.05 * CARD_WIDTH, 0.05 * CARD_WIDTH); + qreal cardCornerRadius = SettingsCache::instance().getCardCornerRadius() * CARD_WIDTH; + shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); return shape; } diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index bd88a8a3f..1d9474259 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -254,6 +254,7 @@ SettingsCache::SettingsCache() showShortcuts = settings->value("menu/showshortcuts", true).toBool(); displayCardNames = settings->value("cards/displaycardnames", true).toBool(); + roundCardCorners = settings->value("cards/roundcardcorners", true).toBool(); overrideAllCardArtWithPersonalPreference = settings->value("cards/overrideallcardartwithpersonalpreference", false).toBool(); bumpSetsWithCardsInDeckToTop = settings->value("cards/bumpsetswithcardsindecktotop", true).toBool(); @@ -331,6 +332,14 @@ SettingsCache::SettingsCache() rememberGameSettings = settings->value("game/remembergamesettings", true).toBool(); clientID = settings->value("personal/clientid", 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) @@ -1286,6 +1295,16 @@ void SettingsCache::setMaxFontSize(int _max) settings->setValue("game/maxfontsize", maxFontSize); } +void SettingsCache::setRoundCardCorners(bool _roundCardCorners) +{ + if (_roundCardCorners == roundCardCorners) + return; + + roundCardCorners = _roundCardCorners; + settings->setValue("cards/roundcardcorners", _roundCardCorners); + emit roundCardCornersChanged(roundCardCorners); +} + void SettingsCache::loadPaths() { QString dataPath = getDataPath(); diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index 771b2663c..1e2aefa84 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -47,6 +47,7 @@ class QSettings; class SettingsCache : public QObject { Q_OBJECT + signals: void langChanged(); void picsPathChanged(); @@ -82,6 +83,8 @@ signals: void downloadSpoilerTimeIndexChanged(); void downloadSpoilerStatusChanged(); void useTearOffMenusChanged(bool state); + void roundCardCornersChanged(bool roundCardCorners); + void cardCornerRadiusChanged(qreal cardCornerRadius); private: QSettings *settings; @@ -201,6 +204,7 @@ private: bool rememberGameSettings; QList releaseChannels; bool isPortableBuild; + bool roundCardCorners; public: SettingsCache(); @@ -727,6 +731,14 @@ public: { return mbDownloadSpoilers; } + bool getRoundCardCorners() const + { + return roundCardCorners; + } + qreal getCardCornerRadius() const + { + return roundCardCorners ? 0.05 : 0.; + } static SettingsCache &instance(); void resetPaths(); @@ -834,6 +846,7 @@ public slots: void setNotifyAboutNewVersion(QT_STATE_CHANGED_T _notifyaboutnewversion); void setUpdateReleaseChannelIndex(int value); void setMaxFontSize(int _max); + void setRoundCardCorners(bool _roundCardCorners); }; #endif diff --git a/dbconverter/src/mocks.cpp b/dbconverter/src/mocks.cpp index e2f6ed4df..4b30b573d 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -384,6 +384,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */) void SettingsCache::setMaxFontSize(int /* _max */) { } +void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */) +{ +} void PictureLoader::clearPixmapCache(CardInfoPtr /* card */) {