diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-02 12:01:47 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-02 12:01:47 -0300 |
commit | 23b29bd3cd0982eb921dc5cbf8f9e13074fe9e32 (patch) | |
tree | 072fbc915a8ad5d11df35425ca4dd657c5c48916 | |
parent | 43664d7cd5468aa579fc48179f1b5c407a01b83f (diff) | |
download | subsurface-23b29bd3cd0982eb921dc5cbf8f9e13074fe9e32.tar.gz |
Use the same profile colors on the planer for the Time and Depth
Use the same profile colors on the planner for the Time and Depth
rulers. this needed a new method on the rulers - setColor, that
will call the setPen method and make everything behave properly.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/diveplanner.cpp | 27 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 1 |
2 files changed, 22 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 2bdec9b74..d0ba86f94 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -56,6 +56,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) ); timeLine->setOrientation(Qt::Horizontal); timeLine->setTickSize(fromPercent(1, Qt::Vertical)); + timeLine->setColor(profile_color[TIME_GRID].at(0)); timeLine->updateTicks(); scene()->addItem(timeLine); @@ -63,16 +64,15 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) depthLine->setMinimum(0); depthLine->setMaximum(40); depthLine->setTickInterval(10); - depthLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(10, Qt::Vertical), fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical) ); - depthLine->setOrientation(Qt::Vertical); depthLine->setTickSize(fromPercent(1, Qt::Horizontal)); + depthLine->setColor(profile_color[DEPTH_GRID].at(0)); depthLine->updateTicks(); scene()->addItem(depthLine); @@ -405,22 +405,32 @@ void Ruler::updateTicks() qDeleteAll(ticks); ticks.clear(); QLineF m = line(); + QGraphicsLineItem *item = NULL; + if (orientation == Qt::Horizontal) { double steps = (max - min) / interval; double stepSize = (m.x2() - m.x1()) / steps; qreal pos; for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) { - ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this)); + item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this); + item->setPen(pen()); + ticks.push_back(item); } - ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this)); + item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this); + item->setPen(pen()); + ticks.push_back(item); } else { double steps = (max - min) / interval; double stepSize = (m.y2() - m.y1()) / steps; qreal pos; for (pos = m.y1(); pos < m.y2(); pos += stepSize) { - ticks.push_back(new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this)); + item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this); + item->setPen(pen()); + ticks.push_back(item); } - ticks.push_back(new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this)); + item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this); + item->setPen(pen()); + ticks.push_back(item); } } @@ -469,6 +479,11 @@ double Ruler::minimum() const return min; } +void Ruler::setColor(const QColor& color) +{ + setPen(QPen(color)); +} + Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem() { icon = new QGraphicsPixmapItem(this); diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index da3e6a4f1..41b4e5c89 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -43,6 +43,7 @@ public: double maximum() const; qreal valueAt(const QPointF& p); qreal posAtValue(qreal value); + void setColor(const QColor& color); private: Qt::Orientation orientation; |