diff --git a/icons/ruler.svg b/icons/ruler.svg
new file mode 100644
index 000000000..27e88bb44
--- /dev/null
+++ b/icons/ruler.svg
@@ -0,0 +1,91 @@
+
+
+
+
diff --git a/icons/scale.svg b/icons/scale.svg
new file mode 100644
index 000000000..143e870e9
--- /dev/null
+++ b/icons/scale.svg
@@ -0,0 +1,71 @@
+
+
+
+
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index c0f1431b7..f6550a7d8 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -15,6 +15,7 @@
#include
#include
#include
+#include
#include
#include
@@ -44,7 +45,7 @@ extern struct ev_select *ev_namelist;
extern int evn_allocated;
extern int evn_used;
-ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0), rulerItem(0)
+ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0), rulerItem(0), toolBarProxy(0)
{
printMode = false;
isGrayscale = false;
@@ -182,6 +183,11 @@ void ProfileGraphicsView::clear()
toolTip->deleteLater();
toolTip = 0;
}
+ if(toolBarProxy) {
+ scene()->removeItem(toolBarProxy);
+ toolBarProxy->deleteLater();
+ toolBarProxy = 0;
+ }
if(rulerItem) {
remove_ruler();
rulerItem->destNode()->deleteLater();
@@ -349,6 +355,9 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
scene()->addItem(timeEditor);
}
+ if (!printMode)
+ addControlItems();
+
if (rulerEnabled && !printMode)
add_ruler();
}
@@ -383,6 +392,23 @@ void ProfileGraphicsView::plot_depth_scale()
depthMarkers->setPos(depthMarkers->pos().x() - 10, 0);
}
+void ProfileGraphicsView::addControlItems()
+{
+ QAction *scaleAction = new QAction(QIcon(":scale"), tr("Scale"), this);
+ QAction *rulerAction = new QAction(QIcon(":ruler"), tr("Ruler"), this);
+ QToolBar *toolBar = new QToolBar("", 0);
+ toolBar->addAction(rulerAction);
+ toolBar->addAction(scaleAction);
+ //make toolbar transparent
+ toolBar->setStyleSheet(QString::fromUtf8 ("background-color: rgba(255,255,255,0);"));
+
+ connect(scaleAction, SIGNAL(triggered()), this, SLOT(on_scaleAction()));
+ connect(rulerAction, SIGNAL(triggered()), this, SLOT(on_rulerAction()));
+ toolBarProxy = scene()->addWidget(toolBar);
+ //Put it into the lower right corner of the profile
+ toolBarProxy->setPos(gc.maxx-toolBar->width(), gc.maxy-toolBar->height());
+}
+
void ProfileGraphicsView::plot_pp_text()
{
double pp, dpp, m;
@@ -1241,6 +1267,18 @@ void ProfileGraphicsView::edit_dive_time(const QString& time)
refresh();
}
+void ProfileGraphicsView::on_rulerAction()
+{
+ rulerEnabled = !rulerEnabled;
+ refresh();
+}
+
+void ProfileGraphicsView::on_scaleAction()
+{
+ zoomed_plot = !zoomed_plot;
+ refresh();
+}
+
void ToolTipItem::addToolTip(const QString& toolTip, const QIcon& icon)
{
QGraphicsPixmapItem *iconItem = 0;
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index deb729023..7cbc53e15 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -149,6 +149,8 @@ protected:
public slots:
void refresh();
void edit_dive_time(const QString& time);
+ void on_rulerAction();
+ void on_scaleAction();
private:
void plot_depth_profile();
@@ -171,6 +173,9 @@ private:
void plot_pp_text();
void plot_depth_scale();
+
+ void addControlItems();
+
void create_ruler();
void add_ruler();
void remove_ruler();
@@ -197,6 +202,7 @@ private:
QGraphicsItem* depthMarkers;
QGraphicsItem* diveComputer;
RulerItem *rulerItem;
+ QGraphicsProxyWidget *toolBarProxy;
// For 'Plan' mode.:
GraphicsTextEditor *depthEditor;
diff --git a/subsurface.qrc b/subsurface.qrc
index 4e9e8ff84..cda15944c 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -12,5 +12,7 @@
icons/average.svg
icons/warning.png
qt-ui/css/tableviews.css
+ icons/scale.svg
+ icons/ruler.svg