From ef6c41057471245be863636ae00a841326a44f6c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 19 Jun 2014 15:58:27 -0300 Subject: [PATCH] Added keyboard navigation to the calendar date picker. Wee. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 15 ++++++++++++++- qt-ui/simplewidgets.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index fe9b8f592..eff3f668b 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -374,4 +374,17 @@ void DateWidget::focusInEvent(QFocusEvent *event) void DateWidget::focusOutEvent(QFocusEvent *event) { QWidget::focusOutEvent(event); -} \ No newline at end of file +} + +void DateWidget::keyPressEvent(QKeyEvent *event) +{ + if ( event->key() == Qt::Key_Return || + event->key() == Qt::Key_Enter || + event->key() == Qt::Key_Space){ + calendarWidget->move(mapToGlobal(QPoint(0,64))); + calendarWidget->show(); + event->setAccepted(true); + }else{ + QWidget::keyPressEvent(event); + } +} diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 445dfebd4..6587c2739 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -102,6 +102,7 @@ protected: void mousePressEvent(QMouseEvent *event); void focusInEvent(QFocusEvent *); void focusOutEvent(QFocusEvent *); + void keyPressEvent(QKeyEvent *); signals: void dateChanged(const QDate& date); private: