summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-12-04 23:12:07 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-04 19:31:10 -0800
commitd3a56c137be5cb8fb49e9d7b4ae4568759946e26 (patch)
tree386dc4fbec9aa3004a5384e2d021e11bb698b00b /qt-ui
parent20d924a16ef221bf366c6cb037d365f0f76e001e (diff)
downloadsubsurface-d3a56c137be5cb8fb49e9d7b4ae4568759946e26.tar.gz
Fixes positioning of the legend in View and Print modes.
This patch makes a better assumption of the location for the legend in both View and Print modes. It also fixes a few oddities that we used to have ( like hardcoded spacing ). We are taking the scene().sceneRect() now into consideration to better place it on canvas. Fixes: #322 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profilegraphics.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 00eb9edbe..bdbc00346 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -589,7 +589,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
setup_pp_limits(&gc);
QColor c;
QPointF from, to;
- QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - 15);
+ QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - scene()->sceneRect().height()*0.02);
if (prefs.pp_graphs.pn2) {
c = getColor(PN2);
@@ -669,16 +669,20 @@ void ProfileGraphicsView::plot_pp_gas_profile()
void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF& legendPos)
{
- QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 16, 16);
- rect->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+ QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, scene()->sceneRect().width() * 0.01, scene()->sceneRect().width() * 0.01);
rect->setBrush(QBrush(c));
rect->setPos(legendPos);
+ rect->setPen(QPen(QColor(Qt::transparent)));
QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(title);
- text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() - 6);
- text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+ text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() );
scene()->addItem(rect);
scene()->addItem(text);
- legendPos.setX( legendPos.x() + 100);
+ legendPos.setX(text->pos().x() + text->boundingRect().width() + 20);
+ if(printMode){
+ QFont f = text->font();
+ f.setPointSizeF( f.pointSizeF() * 0.7);
+ text->setFont(f);
+ }
}
void ProfileGraphicsView::plot_deco_text()