From 70c8bbcc915c31e850bdaf350bf913c4508e5a6a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 19 Jun 2014 15:42:05 -0300 Subject: Added the calendar widget to change the calendar date. Added a popup widget to change the calendar date, just like the old QDateTimeEdit. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'qt-ui/simplewidgets.cpp') diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 32175d218..79f12101d 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "exif.h" #include "dive.h" #include "file.h" @@ -299,16 +300,24 @@ bool isGnome3Session() #endif } -DateWidget::DateWidget(QWidget *parent) : QWidget(parent) +DateWidget::DateWidget(QWidget *parent) : QWidget(parent), + calendarWidget(new QCalendarWidget()) { setDate(QDate::currentDate()); setMinimumSize(QSize(64,64)); + calendarWidget->setWindowFlags(Qt::FramelessWindowHint); + + connect(calendarWidget, SIGNAL(activated(QDate)), calendarWidget, SLOT(hide())); + connect(calendarWidget, SIGNAL(clicked(QDate)), calendarWidget, SLOT(hide())); + connect(calendarWidget, SIGNAL(activated(QDate)), this, SLOT(setDate(QDate))); + connect(calendarWidget, SIGNAL(clicked(QDate)), this, SLOT(setDate(QDate))); } void DateWidget::setDate(const QDate& date) { mDate = date; update(); + emit dateChanged(mDate); } QDate DateWidget::date() const @@ -343,5 +352,11 @@ void DateWidget::paintEvent(QPaintEvent *event) painter.setBrush(Qt::black); painter.setFont(font); painter.drawText(QPoint(32 - metrics.width(day)/2, 45), day); +} +void DateWidget::mousePressEvent(QMouseEvent *event) +{ + calendarWidget->move(event->globalPos()); + calendarWidget->show(); } + -- cgit v1.2.3-70-g09d2