mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Open picture manager when clicking on the picture at the profile
This patch makes the click on pic == open picture browser works also on the profile instead of only on the list view.. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
259b73335f
commit
3f98f024e4
4 changed files with 18 additions and 7 deletions
|
@ -1,21 +1,25 @@
|
||||||
#include "divepixmapitem.h"
|
#include "divepixmapitem.h"
|
||||||
#include "animationfunctions.h"
|
#include "animationfunctions.h"
|
||||||
|
#include <divepicturewidget.h>
|
||||||
|
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent)
|
DivePictureItem::DivePictureItem(int row, QObject *parent): DivePixmapItem(parent)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
#else
|
#else
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
#endif
|
#endif
|
||||||
|
rowOnModel = row;
|
||||||
setScale(0.2);
|
setScale(0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,3 +60,9 @@ void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
Animations::scaleTo(this, 0.2);
|
Animations::scaleTo(this, 0.2);
|
||||||
this->setZValue(0);
|
this->setZValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
QString filePath = DivePictureModel::instance()->index(rowOnModel,0).data(Qt::ToolTipRole).toString();
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||||
|
}
|
||||||
|
|
|
@ -18,11 +18,14 @@ class DivePictureItem : public DivePixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(qreal scale WRITE setScale READ scale)
|
Q_PROPERTY(qreal scale WRITE setScale READ scale)
|
||||||
public:
|
public:
|
||||||
DivePictureItem(QObject *parent = 0);
|
DivePictureItem(int row, QObject *parent = 0);
|
||||||
void setPixmap(const QPixmap& pix);
|
void setPixmap(const QPixmap& pix);
|
||||||
protected:
|
protected:
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
private:
|
||||||
|
int rowOnModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVEPIXMAPITEM_H
|
#endif // DIVEPIXMAPITEM_H
|
||||||
|
|
|
@ -1325,16 +1325,15 @@ void ProfileWidget2::plotPictures()
|
||||||
// information area.
|
// information area.
|
||||||
if (!pic->offset.seconds)
|
if (!pic->offset.seconds)
|
||||||
continue;
|
continue;
|
||||||
DivePictureItem *item = new DivePictureItem();
|
DivePictureItem *item = new DivePictureItem(i);
|
||||||
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
|
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
|
||||||
// let's put the picture at the correct time, but at a fixed "depth" on the profile
|
// let's put the picture at the correct time, but at a fixed "depth" on the profile
|
||||||
// not sure this is ideal, but it seems to look right.
|
// not sure this is ideal, but it seems to look right.
|
||||||
x = timeAxis->posAtValue(pic->offset.seconds);
|
x = timeAxis->posAtValue(pic->offset.seconds);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
y = 10;
|
y = 10;
|
||||||
else
|
else if (fabs(x - lastX) < 4)
|
||||||
if (fabs(x - lastX) < 4)
|
y = lastY + 3;
|
||||||
y = lastY + 3;
|
|
||||||
lastX = x;
|
lastX = x;
|
||||||
lastY = y;
|
lastY = y;
|
||||||
item->setPos(x, y);
|
item->setPos(x, y);
|
||||||
|
|
|
@ -337,7 +337,6 @@ void DateWidget::paintEvent(QPaintEvent *event)
|
||||||
QString year = mDate.toString("yyyy");
|
QString year = mDate.toString("yyyy");
|
||||||
QString day = mDate.toString("dd");
|
QString day = mDate.toString("dd");
|
||||||
|
|
||||||
|
|
||||||
QFont font = QFont("monospace", 10);
|
QFont font = QFont("monospace", 10);
|
||||||
QFontMetrics metrics = QFontMetrics(font);
|
QFontMetrics metrics = QFontMetrics(font);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
|
|
Loading…
Add table
Reference in a new issue