aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/divetextitem.cpp
blob: 7f9adf181f655a566f865d0387348a802528e574 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "divetextitem.h"
#include "animationfunctions.h"
#include <QPropertyAnimation>

DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsSimpleTextItem(parent)
{
	setFlag(ItemIgnoresTransformations);
}

void DiveTextItem::setAlignment(int alignFlags)
{
	internalAlignFlags = alignFlags;
	update();
}

void DiveTextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
	/* This block of code corrects paints the Text on the
	 * alignment choosed, but it created artifacts on the screen,
	 * so I'm leaving this disabled for the time being.
	 */
// 	QRectF rect = boundingRect();
// 	if (internalAlignFlags & Qt::AlignTop)
// 		painter->translate(0, -rect.height());
// // 	else if (internalAlignFlags & Qt::AlignBottom)
// // 		painter->translate(0, rect.height()); this is the default, uneeded.
// 	else if (internalAlignFlags & Qt::AlignVCenter)
// 		painter->translate(0, -rect.height() / 2);
//
// // 	if (internalAlignFlags & Qt::AlignLeft )
// // 		painter->translate(); // This is the default, uneeded.
// 	if(internalAlignFlags & Qt::AlignHCenter)
// 		painter->translate(-rect.width()/2, 0);
// 	else if(internalAlignFlags & Qt::AlignRight)
// 		painter->translate(-rect.width(), 0);

	QGraphicsSimpleTextItem::paint(painter, option, widget);
}

void DiveTextItem::animatedHide()
{
	Animations::hide(this);
}

void DiveTextItem::animateMoveTo(qreal x, qreal y)
{
	Animations::moveTo(this, x, y);
}