diff options
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 5 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 2 | ||||
-rw-r--r-- | qt-ui/profile/ruleritem.cpp | 11 | ||||
-rw-r--r-- | qt-ui/profile/ruleritem.h | 7 |
4 files changed, 18 insertions, 7 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3104406cf..6b44dff18 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -499,11 +499,6 @@ void ProfileWidget2::settingsChanged() needReplot = true; } - if (currentState == PROFILE) { - rulerItem->setVisible(prefs.rulergraph); - } else { - rulerItem->setVisible(false); - } if (needReplot) replot(); } diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 4517cc144..a5d9eed27 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -68,6 +68,7 @@ public: virtual bool eventFilter(QObject *, QEvent *); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); void setPrintMode(bool mode, bool grayscale = false); + State currentState; public slots: // Necessary to call from QAction's signals. @@ -98,7 +99,6 @@ private: /*methods*/ private: DivePlotDataModel *dataModel; - State currentState; int zoomLevel; qreal zoomFactor; DivePixmapItem *background; diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 1c52c6ea4..f168da953 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -1,5 +1,7 @@ #include "ruleritem.h" #include "divetextitem.h" +#include "profilewidget2.h" +#include "../preferences.h" #include <QFont> #include <QFontMetrics> @@ -79,6 +81,15 @@ RulerItem2::RulerItem2() : source(new RulerNodeItem2()), textItemBack->setPen(QColor(Qt::white)); textItemBack->setFlag(QGraphicsItem::ItemIgnoresTransformations); setPen(QPen(QColor(Qt::black), 0.0)); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); +} + +void RulerItem2::settingsChanged() +{ + ProfileWidget2 *profWidget = NULL; + if(scene() && scene()->views().count()) + profWidget = qobject_cast<ProfileWidget2*>(scene()->views().first()); + setVisible(profWidget->currentState == ProfileWidget2::PROFILE ? prefs.rulergraph : false); } void RulerItem2::recalculate() diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h index d00e345dd..2ee1703a6 100644 --- a/qt-ui/profile/ruleritem.h +++ b/qt-ui/profile/ruleritem.h @@ -31,7 +31,8 @@ private: DiveCartesianAxis *depthAxis; }; -class RulerItem2 : public QGraphicsLineItem { +class RulerItem2 :public QObject, public QGraphicsLineItem { + Q_OBJECT public: explicit RulerItem2(); void recalculate(); @@ -41,6 +42,10 @@ public: RulerNodeItem2 *destNode() const; void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth); void setVisible(bool visible); + +public slots: + void settingsChanged(); + private: struct plot_info pInfo; QPointF startPoint, endPoint; |