mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
a70a0662f5
Subtle change in function name from Qt4 to Qt5 setAcceptsHoverEvents -> setAcceptHoverEvents Now Subsurface builds with Qt5 again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "divepixmapitem.h"
|
|
#include "animationfunctions.h"
|
|
|
|
#include <QPen>
|
|
#include <QBrush>
|
|
#include <QGraphicsDropShadowEffect>
|
|
|
|
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
|
{
|
|
}
|
|
|
|
DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent)
|
|
{
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
setAcceptsHoverEvents(true);
|
|
#else
|
|
setAcceptHoverEvents(true);
|
|
#endif
|
|
setScale(0.2);
|
|
}
|
|
|
|
void DivePictureItem::setPixmap(const QPixmap &pix)
|
|
{
|
|
DivePixmapItem::setPixmap(pix);
|
|
QRectF r = boundingRect();
|
|
QGraphicsRectItem *rect = new QGraphicsRectItem(0 - 10, 0 -10, r.width() + 20, r.height() + 20, this);
|
|
rect->setPen(Qt::NoPen);
|
|
rect->setBrush(QColor(Qt::white));
|
|
rect->setFlag(ItemStacksBehindParent);
|
|
rect->setZValue(-1);
|
|
|
|
QGraphicsRectItem *shadow = new QGraphicsRectItem(rect->boundingRect(), this);
|
|
shadow->setPos(5,5);
|
|
shadow->setPen(Qt::NoPen);
|
|
shadow->setBrush(QColor(Qt::lightGray));
|
|
shadow->setFlag(ItemStacksBehindParent);
|
|
shadow->setZValue(-2);
|
|
|
|
setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2);
|
|
|
|
qreal angle = qrand() % 5;
|
|
if (rand() % 2)
|
|
angle *= -1;
|
|
|
|
setRotation(angle);
|
|
}
|
|
|
|
void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|
{
|
|
Animations::scaleTo(this, 1.0);
|
|
}
|
|
|
|
void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|
{
|
|
Animations::scaleTo(this, 0.2);
|
|
}
|