From a7240cd83f24c64d4a65d5f2ed22d1f61d810769 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 19 Jun 2014 15:52:30 -0300 Subject: Added focus handling to the Date Picker. Added focus handling for the date picker, this way the user can use the keyboard to change the date. ( still not implemented ) Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.ui | 24 ++++++++++++++---------- qt-ui/simplewidgets.cpp | 15 +++++++++++++++ qt-ui/simplewidgets.h | 2 ++ 3 files changed, 31 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index ad654581e..899854f86 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -19,9 +19,7 @@ - - scrollArea - + @@ -248,7 +246,11 @@ - + + + Qt::StrongFocus + + @@ -280,8 +282,8 @@ 0 0 - 662 - 642 + 100 + 30 @@ -360,8 +362,8 @@ 0 0 - 662 - 642 + 548 + 395 @@ -670,8 +672,8 @@ 0 0 - 662 - 642 + 468 + 229 @@ -923,6 +925,7 @@ scrollArea + dateEdit airtemp watertemp location @@ -937,6 +940,7 @@ scrollArea_2 scrollArea_3 scrollArea_4 + photosView diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 79f12101d..fe9b8f592 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -305,6 +305,7 @@ DateWidget::DateWidget(QWidget *parent) : QWidget(parent), { setDate(QDate::currentDate()); setMinimumSize(QSize(64,64)); + setFocusPolicy(Qt::StrongFocus); calendarWidget->setWindowFlags(Qt::FramelessWindowHint); connect(calendarWidget, SIGNAL(activated(QDate)), calendarWidget, SLOT(hide())); @@ -352,6 +353,9 @@ void DateWidget::paintEvent(QPaintEvent *event) painter.setBrush(Qt::black); painter.setFont(font); painter.drawText(QPoint(32 - metrics.width(day)/2, 45), day); + + if(hasFocus()) + painter.drawLine(0, 63, 63, 63); } void DateWidget::mousePressEvent(QMouseEvent *event) @@ -360,3 +364,14 @@ void DateWidget::mousePressEvent(QMouseEvent *event) calendarWidget->show(); } + +void DateWidget::focusInEvent(QFocusEvent *event) +{ + setFocus(); + QWidget::focusInEvent(event); +} + +void DateWidget::focusOutEvent(QFocusEvent *event) +{ + QWidget::focusOutEvent(event); +} \ No newline at end of file diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 3600f59b7..445dfebd4 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -100,6 +100,8 @@ public slots: protected: void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *event); + void focusInEvent(QFocusEvent *); + void focusOutEvent(QFocusEvent *); signals: void dateChanged(const QDate& date); private: -- cgit v1.2.3-70-g09d2