aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/divetextitem.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-15 07:03:41 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-15 07:06:09 -0800
commit980737221d471bb73e50946de40b2b7e303f286b (patch)
treec42c6e20e3a5d0aebba92ad4601e8f902b14eb9f /qt-ui/profile/divetextitem.cpp
parentcb5ab4bc8e192e65dded3bc3f3bfb703441e5436 (diff)
downloadsubsurface-980737221d471bb73e50946de40b2b7e303f286b.tar.gz
New Profile: make axis labels smaller
Previously all text in the new profile was deawn in the same font. With this change the labels on all axes are smaller. It might be even better to allow per-axis configuration of the label size as along the time axis the bigger size looked better. But especially for partial pressures this looks much better. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/divetextitem.cpp')
-rw-r--r--qt-ui/profile/divetextitem.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp
index bc19d070a..10116e19f 100644
--- a/qt-ui/profile/divetextitem.cpp
+++ b/qt-ui/profile/divetextitem.cpp
@@ -13,7 +13,8 @@ DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
textBackgroundItem(NULL),
textItem(NULL),
- colorIndex(SAC_DEFAULT)
+ colorIndex(SAC_DEFAULT),
+ scale(1.0)
{
setFlag(ItemIgnoresTransformations);
}
@@ -30,6 +31,11 @@ void DiveTextItem::setBrush(const QBrush& b)
updateText();
}
+void DiveTextItem::setScale(double newscale)
+{
+ scale = newscale;
+}
+
void DiveTextItem::setText(const QString& t)
{
internalText = t;
@@ -43,6 +49,7 @@ const QString& DiveTextItem::text()
void DiveTextItem::updateText()
{
+ double size;
delete textItem;
textItem = NULL;
delete textBackgroundItem;
@@ -52,6 +59,15 @@ void DiveTextItem::updateText()
}
QFont fnt(qApp->font());
+ if ((size = fnt.pixelSize()) > 0) {
+ // set in pixels - so the scale factor may not make a difference if it's too close to 1
+ size *= scale;
+ fnt.setPixelSize(size);
+ } else {
+ size = fnt.pointSizeF();
+ size *= scale;
+ fnt.setPointSizeF(size);
+ }
QFontMetrics fm(fnt);
QPainterPath textPath;