mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
* Have CardDatabase::getPreferredPrintingInfo respect card provider ID overrides (pinned printings)
Took 13 minutes
Took 37 seconds
Took 10 seconds
Took 10 seconds
# Commit time for manual adjustment:
# Took 30 seconds
Took 15 seconds
Took 8 minutes
Took 21 seconds
* Move settings cache and settings card preference provider out of libcockatrice_settings and into cockatrice
Took 52 minutes
Took 9 minutes
Took 1 minute
* Temp cache.
Took 16 minutes
* Dependency Injection for SettingsCache
* Turn SettingsCache into a QSharedPointer.
* Implement interfaces for settings that need it
Took 2 hours 38 minutes
* Adjust oracle.
Took 5 minutes
* Move abstract/noop interfaces to libcockatrice_interfaces so they can be linked against independently.
Took 52 minutes
* Clean up some links.
Took 3 minutes
* Cleanup two includes.
Took 3 minutes
* More fixes.
Took 7 minutes
* More includes that slipped past.
Took 3 minutes
* Stop mocking and start injecting for tests.
Took 15 minutes
* I don't know why remote_client was including main.
Took 4 minutes
* Include.
Took 3 minutes
* Lint.
Took 2 minutes
* Don't use Qt pointers.
Took 1 hour 7 minutes
* Make parser use CardSettingsInterface
Took 13 minutes
* Also adjust constructor lol.
Took 8 minutes
* Lint.
Took 32 minutes
* Revert "Lint."
This reverts commit ecb596c39e.
Took 3 minutes
* Test.
Took 3 minutes
---------
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
#include "abstract_card_drag_item.h"
|
|
|
|
#include "../../client/settings/cache_settings.h"
|
|
|
|
#include <QCursor>
|
|
#include <QDebug>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QPainter>
|
|
|
|
static const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
|
|
static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
|
|
const QColor GHOST_MASK = QColor(255, 255, 255, 50);
|
|
|
|
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
|
|
const QPointF &_hotSpot,
|
|
AbstractCardDragItem *parentDrag)
|
|
: QGraphicsItem(), item(_item), hotSpot(_hotSpot)
|
|
{
|
|
if (parentDrag) {
|
|
parentDrag->addChildDrag(this);
|
|
setZValue(2000000007 + hotSpot.x() * 1000000 + hotSpot.y() * 1000 + 1000);
|
|
connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
|
|
} else {
|
|
hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast<qreal>(CARD_WIDTH - 1)),
|
|
qBound(0.0, hotSpot.y(), static_cast<qreal>(CARD_HEIGHT - 1))};
|
|
setCursor(Qt::ClosedHandCursor);
|
|
setZValue(2000000007);
|
|
}
|
|
if (item->getTapped())
|
|
setTransform(QTransform()
|
|
.translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF)
|
|
.rotate(90)
|
|
.translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF));
|
|
|
|
setCacheMode(DeviceCoordinateCache);
|
|
|
|
connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
|
|
Q_UNUSED(_roundCardCorners);
|
|
|
|
prepareGeometryChange();
|
|
update();
|
|
});
|
|
|
|
connect(item, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
|
|
}
|
|
|
|
QPainterPath AbstractCardDragItem::shape() const
|
|
{
|
|
QPainterPath shape;
|
|
qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
|
|
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
|
|
return shape;
|
|
}
|
|
|
|
void AbstractCardDragItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
{
|
|
item->paint(painter, option, widget);
|
|
|
|
// adds a mask to the card so it looks like the card hasnt been placed yet
|
|
painter->fillPath(shape(), GHOST_MASK);
|
|
}
|
|
|
|
void AbstractCardDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
{
|
|
event->accept();
|
|
updatePosition(event->scenePos());
|
|
}
|
|
|
|
void AbstractCardDragItem::addChildDrag(AbstractCardDragItem *child)
|
|
{
|
|
childDrags << child;
|
|
}
|