aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-06-19 15:52:30 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-20 15:41:53 -0700
commita7240cd83f24c64d4a65d5f2ed22d1f61d810769 (patch)
tree2c4944fac6cb06a6f65efb6608b1bc0402bb3a7c /qt-ui/simplewidgets.cpp
parent70c8bbcc915c31e850bdaf350bf913c4508e5a6a (diff)
downloadsubsurface-a7240cd83f24c64d4a65d5f2ed22d1f61d810769.tar.gz
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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r--qt-ui/simplewidgets.cpp15
1 files changed, 15 insertions, 0 deletions
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