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 | |
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')
-rw-r--r-- | qt-ui/simplewidgets.cpp | 17 | ||||
-rw-r--r-- | qt-ui/simplewidgets.h | 11 |
2 files changed, 24 insertions, 4 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(); } + diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index ba8a23360..3600f59b7 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -88,18 +88,23 @@ private: time_t dcImageEpoch; }; +class QCalendarWidget; + class DateWidget : public QWidget { Q_OBJECT public: DateWidget(QWidget *parent = 0); - void setDate(const QDate& date); QDate date() const; +public slots: + void setDate(const QDate& date); protected: void paintEvent(QPaintEvent *event); - + void mousePressEvent(QMouseEvent *event); +signals: + void dateChanged(const QDate& date); private: QDate mDate; - + QCalendarWidget *calendarWidget; }; bool isGnome3Session(); |