mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add option to disable card rounding (#5760)
* Add option to disable card rounding * Effing mocks * format * Get rid of cardCornerRadius property
This commit is contained in:
parent
0ae7d01234
commit
c71685b261
12 changed files with 93 additions and 17 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "card_info_picture_enlarged_widget.h"
|
||||
|
||||
#include "../../../../settings/cache_settings.h"
|
||||
#include "../../picture_loader/picture_loader.h"
|
||||
|
||||
#include <QPainterPath>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<qreal>(targetRect.width()); // Ensure consistent rounding
|
||||
// Ensure consistent rounding
|
||||
qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * static_cast<qreal>(targetRect.width()) : 0.;
|
||||
|
||||
// Draw the pixmap with rounded corners
|
||||
QStylePainter painter(this);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <QStackedWidget>
|
||||
#include <QToolBar>
|
||||
#include <QTranslator>
|
||||
#include <qabstractbutton.h>
|
||||
|
||||
#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:"));
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ private:
|
|||
QCheckBox overrideAllCardArtWithPersonalPreferenceCheckBox;
|
||||
QCheckBox bumpSetsWithCardsInDeckToTopCheckBox;
|
||||
QCheckBox cardScalingCheckBox;
|
||||
QCheckBox roundCardCornersCheckBox;
|
||||
QLabel verticalCardOverlapPercentLabel;
|
||||
QSpinBox verticalCardOverlapPercentBox;
|
||||
QLabel cardViewInitialRowsMaxLabel;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "abstract_card_drag_item.h"
|
||||
|
||||
#include "card_database.h"
|
||||
#include "../../settings/cache_settings.h"
|
||||
|
||||
#include <QCursor>
|
||||
#include <QDebug>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<ReleaseChannel *> 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
|
||||
|
|
|
|||
|
|
@ -387,6 +387,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
|
|||
void SettingsCache::setMaxFontSize(int /* _max */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */)
|
||||
{
|
||||
}
|
||||
|
||||
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -391,6 +391,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
|
|||
void SettingsCache::setMaxFontSize(int /* _max */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */)
|
||||
{
|
||||
}
|
||||
|
||||
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue