diff options
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 17 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 1 |
2 files changed, 18 insertions, 0 deletions
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}; |