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..775390182 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,5 +1,6 @@ #include "card_info_picture_enlarged_widget.h" +#include "../../../../settings/cache_settings.h" #include "../../picture_loader/picture_loader.h" #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 + // Adjust the radius as needed for rounded corners + qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * scaledSize.width() : 0.; 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..546568a73 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 + // Ensure consistent rounding + qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * static_cast(targetRect.width()) : 0.; // 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..0c7acd917 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().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; + 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 05e19d3b3..dc00aae66 100644 --- a/cockatrice/src/game/cards/abstract_card_item.cpp +++ b/cockatrice/src/game/cards/abstract_card_item.cpp @@ -26,6 +26,13 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, connect(&SettingsCache::instance(), &SettingsCache::displayCardNamesChanged, this, [this] { update(); }); refreshCardInfo(); + + connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { + Q_UNUSED(_roundCardCorners); + + prepareGeometryChange(); + update(); + }); } AbstractCardItem::~AbstractCardItem() @@ -41,7 +48,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().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; + 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 a9bd08051..41c6ed45a 100644 --- a/cockatrice/src/game/deckview/deck_view.cpp +++ b/cockatrice/src/game/deckview/deck_view.cpp @@ -74,6 +74,12 @@ 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 +97,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().getRoundCardCorners() ? 0.05 * (CARD_WIDTH - 3) : 0.0; painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius); painter->restore(); } @@ -525,4 +531,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 08ee3d28e..ba23560c9 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().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; + shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); return shape; } diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index 52e6af104..87215aefb 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(); @@ -1294,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 5986b07a7..c33efad6d 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(); @@ -83,6 +84,7 @@ signals: void downloadSpoilerTimeIndexChanged(); void downloadSpoilerStatusChanged(); void useTearOffMenusChanged(bool state); + void roundCardCornersChanged(bool roundCardCorners); private: QSettings *settings; @@ -203,6 +205,7 @@ private: bool rememberGameSettings; QList releaseChannels; bool isPortableBuild; + bool roundCardCorners; public: SettingsCache(); @@ -733,6 +736,10 @@ public: { return mbDownloadSpoilers; } + bool getRoundCardCorners() const + { + return roundCardCorners; + } static SettingsCache &instance(); void resetPaths(); @@ -841,6 +848,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 06889d2b3..f2d4b7566 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -387,6 +387,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */) void SettingsCache::setMaxFontSize(int /* _max */) { } +void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */) +{ +} void PictureLoader::clearPixmapCache(CardInfoPtr /* card */) { diff --git a/tests/carddatabase/mocks.cpp b/tests/carddatabase/mocks.cpp index 78b95cc1c..944254d74 100644 --- a/tests/carddatabase/mocks.cpp +++ b/tests/carddatabase/mocks.cpp @@ -391,6 +391,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */) void SettingsCache::setMaxFontSize(int /* _max */) { } +void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */) +{ +} void PictureLoader::clearPixmapCache(CardInfoPtr /* card */) {