diff options
author | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-11-05 00:36:53 -0300 |
---|---|---|
committer | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-11-05 00:42:10 -0300 |
commit | 339b7b9737984b31d7d2d09cab174beafe2489e9 (patch) | |
tree | 5f4aec3290e4f6cca68da695f17c1bad50debb8f /weather | |
parent | 7a36099c384a90acfbb6ca0e49eabade2f48701d (diff) |
Weather: left and right key handling.
Signed-off-by: Luiz Agostini <luiz.agostini@openbossa.org>
Diffstat (limited to 'weather')
-rw-r--r-- | weather/citycarroussel.cpp | 2 | ||||
-rw-r--r-- | weather/mainview.cpp | 13 | ||||
-rw-r--r-- | weather/mainview.h | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/weather/citycarroussel.cpp b/weather/citycarroussel.cpp index f018c27..199f65f 100644 --- a/weather/citycarroussel.cpp +++ b/weather/citycarroussel.cpp @@ -256,6 +256,7 @@ static const qreal backgroundWidthRef = 635.0 / 480.0; CityCarroussel::CityCarroussel(QGraphicsItem *parent) : QGraphicsItem(parent) + , m_displacement(0.0) , m_gestureBox(new CityCarrousselGesture(*this, this)) , m_boundingRect(QPointF(0.0, 0.0), Settings::windowSize()) , m_backgroundWidth(backgroundWidthRef * m_boundingRect.width()) @@ -395,6 +396,7 @@ void CityCarroussel::updateBackground(int idx) void CityCarroussel::moveEnd(int direction) { + m_displacement = 0.0; m_gestureBox->setActive(true); if (direction) { m_carroussel.move(-direction); diff --git a/weather/mainview.cpp b/weather/mainview.cpp index 13d3f72..d3032d8 100644 --- a/weather/mainview.cpp +++ b/weather/mainview.cpp @@ -104,6 +104,10 @@ void MainView::showCarroussel() QList<ForecastData> data = m_bootManager->data(); m_carroussel = new CityCarroussel(); connect(m_carroussel, SIGNAL(cityNameClicked()), this, SLOT(cityNameClicked())); + + connect(this, SIGNAL(moveLeft()), m_carroussel, SLOT(moveLeft())); + connect(this, SIGNAL(moveRight()), m_carroussel, SLOT(moveRight())); + foreach (const ForecastData &forecast, data) m_carroussel->add(new MyCityForecastData(forecast)); m_carroussel->setPos(0.0, 0.0); @@ -140,3 +144,12 @@ void MainView::closeCityManager() disconnect(m_manager, SIGNAL(terminated()), this, SLOT(closeCityManager())); m_carroussel->setActive(true); } + +void MainView::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Left) + emit moveLeft(); + if (event->key() == Qt::Key_Right) + emit moveRight(); + QGraphicsView::keyPressEvent(event); +} diff --git a/weather/mainview.h b/weather/mainview.h index 9c80b67..7501675 100644 --- a/weather/mainview.h +++ b/weather/mainview.h @@ -51,6 +51,9 @@ public: MainView(QWidget *parent = 0); ~MainView(); +protected: + void keyPressEvent(QKeyEvent* event); + signals: void moveLeft(); void moveRight(); |