summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-10-11 14:21:14 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-11 10:32:11 -0700
commitd0d83d5d7d2d148dfd572c4e5b325f04d93c6b69 (patch)
tree06b016cc6d36fe615cf2021566ed1959d6ce40c0 /qt-ui
parent11e38710e480fc735607dd1ae218a1c9dbc4135f (diff)
downloadsubsurface-d0d83d5d7d2d148dfd572c4e5b325f04d93c6b69.tar.gz
profilewidget2: fix line width when printing on OSX and Linux
On OSX and Linux only, the cosmetic width of the QPen on profile axes does not work and is weirdly dependent on the fact if a printer is installed or not. Possible Qt bugs at hand. The same is not present on Win32. To solve the issues we add setPrintMode() in DiveCartesianAxis and call it for all instances of the class in ProfileWidget2. This patch also moves gridPen() as a private member function of PartialGasPressureAxis as it now needs to access member variables. Fixes #943 Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/divecartesianaxis.cpp29
-rw-r--r--qt-ui/profile/divecartesianaxis.h4
-rw-r--r--qt-ui/profile/profilewidget2.cpp10
3 files changed, 35 insertions, 8 deletions
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index 46f1a9656..bf5a5380c 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -8,11 +8,14 @@
#include "divelineitem.h"
#include "profilewidget2.h"
-static QPen gridPen()
+QPen DiveCartesianAxis::gridPen()
{
QPen pen;
pen.setColor(getColor(TIME_GRID));
- pen.setWidth(2);
+ /* cosmetic width() == 0 for lines in printMode
+ * having setCosmetic(true) and width() > 0 does not work when
+ * printing on OSX and Linux */
+ pen.setWidth(DiveCartesianAxis::printMode ? 0 : 2);
pen.setCosmetic(true);
return pen;
}
@@ -33,6 +36,18 @@ void DiveCartesianAxis::setFontLabelScale(qreal scale)
changed = true;
}
+void DiveCartesianAxis::setPrintMode(bool mode)
+{
+ printMode = mode;
+ // update the QPen of all lines depending on printMode
+ QPen newPen = gridPen();
+ QColor oldColor = pen().brush().color();
+ newPen.setBrush(oldColor);
+ setPen(newPen);
+ Q_FOREACH (DiveLineItem *item, lines)
+ item->setPen(pen());
+}
+
void DiveCartesianAxis::setMaximum(double maximum)
{
if (IS_FP_SAME(max, maximum))
@@ -57,6 +72,7 @@ void DiveCartesianAxis::setTextColor(const QColor &color)
DiveCartesianAxis::DiveCartesianAxis() : QObject(),
QGraphicsLineItem(),
+ printMode(false),
unitSystem(0),
orientation(LeftToRight),
min(0),
@@ -220,10 +236,8 @@ void DiveCartesianAxis::updateTicks(color_indice_t color)
childPos = begin - i * stepSize;
}
DiveLineItem *line = new DiveLineItem(this);
- QPen pen;
+ QPen pen = gridPen();
pen.setBrush(getColor(color));
- pen.setCosmetic(true);
- pen.setWidthF(2);
line->setPen(pen);
line->setZValue(0);
lines.push_back(line);
@@ -340,11 +354,10 @@ double DiveCartesianAxis::fontLabelScale() const
void DiveCartesianAxis::setColor(const QColor &color)
{
- QPen defaultPen(color);
+ QPen defaultPen = gridPen();
+ defaultPen.setColor(color);
defaultPen.setJoinStyle(Qt::RoundJoin);
defaultPen.setCapStyle(Qt::RoundCap);
- defaultPen.setWidth(2);
- defaultPen.setCosmetic(true);
setPen(defaultPen);
}
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index 15155692e..27cfa62d8 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -16,6 +16,9 @@ class DiveCartesianAxis : public QObject, public QGraphicsLineItem {
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
Q_PROPERTY(qreal x WRITE setX READ x)
Q_PROPERTY(qreal y WRITE setY READ y)
+private:
+ bool printMode;
+ QPen gridPen();
public:
enum Orientation {
TopToBottom,
@@ -25,6 +28,7 @@ public:
};
DiveCartesianAxis();
virtual ~DiveCartesianAxis();
+ void setPrintMode(bool mode);
void setMinimum(double minimum);
void setMaximum(double maximum);
void setTickInterval(double interval);
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index ab9ae2c0d..3ccd1bb6d 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1479,6 +1479,16 @@ void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
{
printMode = mode;
resetZoom();
+
+ // set printMode for axes
+ profileYAxis->setPrintMode(mode);
+ gasYAxis->setPrintMode(mode);
+ temperatureAxis->setPrintMode(mode);
+ timeAxis->setPrintMode(mode);
+ cylinderPressureAxis->setPrintMode(mode);
+ heartBeatAxis->setPrintMode(mode);
+ percentageAxis->setPrintMode(mode);
+
isGrayscale = mode ? grayscale : false;
mouseFollowerHorizontal->setVisible(!mode);
mouseFollowerVertical->setVisible(!mode);