Fix the size of the scene on screen and Background improvements.

It seems that I forgot to add the background pixmap, but this is being
done right now by luisa. This patch fixes the size of the scene by
scaling everything to the size of the viewport as soon as a resize is
done, and it also fixes the size of the - to be included - background
pixmap.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-01-15 12:55:33 -02:00 committed by Dirk Hohndel
parent 816f6db356
commit ff49cb1929
2 changed files with 18 additions and 0 deletions

View file

@ -196,7 +196,24 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event)
void ProfileWidget2::resizeEvent(QResizeEvent* event)
{
QGraphicsView::resizeEvent(event);
fitInView(sceneRect(), Qt::IgnoreAspectRatio);
if(!stateMachine->configuration().count())
return;
if ((*stateMachine->configuration().begin())->objectName() == "Empty State"){
fixBackgroundPos();
}
}
void ProfileWidget2::fixBackgroundPos()
{
QPixmap p = QPixmap(":background").scaledToHeight(viewport()->height());
int x = viewport()->width()/2 - p.width()/2;
DivePixmapItem *bg = background;
bg->setPixmap(p);
bg->setX(mapToScene(x, 0).x());
}
void ProfileWidget2::showEvent(QShowEvent* event)

View file

@ -26,6 +26,7 @@ struct QStateMachine;
class ProfileWidget2 : public QGraphicsView {
Q_OBJECT
void fixBackgroundPos();
public:
enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
enum Items{BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};