mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
b9d04c0cf4
This code hoocks the pictures with the preferences change. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#include "divepixmapitem.h"
|
|
#include "animationfunctions.h"
|
|
#include <divepicturewidget.h>
|
|
#include <preferences.h>
|
|
|
|
#include <QPen>
|
|
#include <QBrush>
|
|
#include <QGraphicsDropShadowEffect>
|
|
#include <QDesktopServices>
|
|
#include <QUrl>
|
|
|
|
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
|
{
|
|
}
|
|
|
|
DivePictureItem::DivePictureItem(int row, QObject *parent): DivePixmapItem(parent)
|
|
{
|
|
setFlag(ItemIgnoresTransformations);
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
setAcceptsHoverEvents(true);
|
|
#else
|
|
setAcceptHoverEvents(true);
|
|
#endif
|
|
rowOnModel = row;
|
|
setScale(0.2);
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
|
setVisible(prefs.show_pictures_in_profile);
|
|
}
|
|
|
|
void DivePictureItem::settingsChanged()
|
|
{
|
|
setVisible(prefs.show_pictures_in_profile);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|
{
|
|
Animations::scaleTo(this, 1.0);
|
|
setZValue(5);
|
|
}
|
|
|
|
void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|
{
|
|
Animations::scaleTo(this, 0.2);
|
|
setZValue(0);
|
|
}
|
|
|
|
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
{
|
|
QString filePath = DivePictureModel::instance()->index(rowOnModel,0).data(Qt::ToolTipRole).toString();
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
|
}
|