From ff49cb192956ed1dcfe8571fa9e7e39690963c71 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 15 Jan 2014 12:55:33 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 17 +++++++++++++++++ qt-ui/profile/profilewidget2.h | 1 + 2 files changed, 18 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 5bd738da3..3ec88e320 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -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) diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 43d2e2b3d..0a5ec4855 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -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}; -- cgit v1.2.3-70-g09d2