diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-15 12:55:33 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 10:12:30 +0700 |
commit | ff49cb192956ed1dcfe8571fa9e7e39690963c71 (patch) | |
tree | cf947f8f07820867db3191951a0d5f24b1682500 /qt-ui | |
parent | 816f6db35644d419ac09e359ec61afc36592686c (diff) | |
download | subsurface-ff49cb192956ed1dcfe8571fa9e7e39690963c71.tar.gz |
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>
Diffstat (limited to 'qt-ui')
-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}; |