diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-06-19 15:42:05 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-20 15:41:50 -0700 |
commit | 70c8bbcc915c31e850bdaf350bf913c4508e5a6a (patch) | |
tree | 175973b986fc0cf952effffa35a78cfde1b529d0 /qt-ui/simplewidgets.cpp | |
parent | 1fc22c665310bb37258aacb3d5e6863f52f5662d (diff) | |
download | subsurface-70c8bbcc915c31e850bdaf350bf913c4508e5a6a.tar.gz |
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 <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.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
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 <QFileDialog> #include <QDateTime> #include <QShortcut> +#include <QCalendarWidget> #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(); } + |