diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-06-27 18:00:42 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-27 20:37:11 -0700 |
commit | 3f98f024e484764e2bfa648d9eb072ce7472acf6 (patch) | |
tree | d04771bf8a78c6f4127e70fedeeff826ac91c9c9 /qt-ui | |
parent | 259b73335f3ba0597eb2bb21d948d33fcd61bbbe (diff) | |
download | subsurface-3f98f024e484764e2bfa648d9eb072ce7472acf6.tar.gz |
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>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divepixmapitem.cpp | 12 | ||||
-rw-r--r-- | qt-ui/profile/divepixmapitem.h | 5 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 7 | ||||
-rw-r--r-- | qt-ui/simplewidgets.cpp | 1 |
4 files changed, 18 insertions, 7 deletions
diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index 263a8023b..e0ce4f90a 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -1,21 +1,25 @@ #include "divepixmapitem.h" #include "animationfunctions.h" +#include <divepicturewidget.h> #include <QPen> #include <QBrush> #include <QGraphicsDropShadowEffect> +#include <QDesktopServices> +#include <QUrl> 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) setAcceptsHoverEvents(true); #else setAcceptHoverEvents(true); #endif + rowOnModel = row; setScale(0.2); } @@ -56,3 +60,9 @@ void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Animations::scaleTo(this, 0.2); this->setZValue(0); } + +void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + QString filePath = DivePictureModel::instance()->index(rowOnModel,0).data(Qt::ToolTipRole).toString(); + QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); +} diff --git a/qt-ui/profile/divepixmapitem.h b/qt-ui/profile/divepixmapitem.h index a0f542ea0..26aeeaf65 100644 --- a/qt-ui/profile/divepixmapitem.h +++ b/qt-ui/profile/divepixmapitem.h @@ -18,11 +18,14 @@ class DivePictureItem : public DivePixmapItem { Q_OBJECT Q_PROPERTY(qreal scale WRITE setScale READ scale) public: - DivePictureItem(QObject *parent = 0); + DivePictureItem(int row, QObject *parent = 0); void setPixmap(const QPixmap& pix); protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event); +private: + int rowOnModel; }; #endif // DIVEPIXMAPITEM_H diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 66d787242..d8764c461 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1325,16 +1325,15 @@ void ProfileWidget2::plotPictures() // information area. if (!pic->offset.seconds) continue; - DivePictureItem *item = new DivePictureItem(); + DivePictureItem *item = new DivePictureItem(i); 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 // not sure this is ideal, but it seems to look right. x = timeAxis->posAtValue(pic->offset.seconds); if (i == 0) y = 10; - else - if (fabs(x - lastX) < 4) - y = lastY + 3; + else if (fabs(x - lastX) < 4) + y = lastY + 3; lastX = x; lastY = y; item->setPos(x, y); diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 035e27806..643efd450 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -337,7 +337,6 @@ void DateWidget::paintEvent(QPaintEvent *event) QString year = mDate.toString("yyyy"); QString day = mDate.toString("dd"); - QFont font = QFont("monospace", 10); QFontMetrics metrics = QFontMetrics(font); painter.setFont(font); |