From: gregor herrmann Date: Sun, 24 Jul 2011 11:41:14 +0000 (+0000) Subject: Add today button to date navigator. X-Git-Tag: 0.5.3~11 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/a6f4f3d1d27cb4f377acba137cffaf7da6329a58?ds=sidebyside Add today button to date navigator. TODO: date is not centered between prev/next arrows anymore. Cf. #29 --- diff --git a/NEWS b/NEWS index 086f7a6..c64f986 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ fosdem-schedule; cf. docs/fosdem-schedule for the historic documentation. Version 0.5.3 //! TODO +* Add "jump to today" button to date navigator. + Thanks to Michael Schutte for the patch. Version 0.5.2, 2011-07-23 * Show close button in conference dialog also if there are no conferences diff --git a/src/gui/daynavigatorwidget.cpp b/src/gui/daynavigatorwidget.cpp index 07d13bc..bf1f17a 100644 --- a/src/gui/daynavigatorwidget.cpp +++ b/src/gui/daynavigatorwidget.cpp @@ -34,6 +34,7 @@ DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent) setupUi(this); connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked())); connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked())); + connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked())); mFontMetrics = new QFontMetrics(QLabel().font()); } @@ -63,22 +64,26 @@ void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate } } +void DayNavigatorWidget::configureNavigation() +{ + // check start date + if(mCurDate==mStartDate || mStartDate==mEndDate) + prevDayButton->setDisabled(true); + else + prevDayButton->setDisabled(false); + // check end date + if(mCurDate==mEndDate || mStartDate==mEndDate) + nextDayButton->setDisabled(true); + else + nextDayButton->setDisabled(false); +} + void DayNavigatorWidget::prevDayButtonClicked() { if(mCurDate>mStartDate) { mCurDate = mCurDate.addDays(-1); - // check start date - if(mCurDate==mStartDate || mStartDate==mEndDate) - prevDayButton->setDisabled(true); - else - prevDayButton->setDisabled(false); - // check end date - if(mCurDate==mEndDate || mStartDate==mEndDate) - nextDayButton->setDisabled(true); - else - nextDayButton->setDisabled(false); - + configureNavigation(); emit(dateChanged(mCurDate)); selectedDate->update(); } @@ -89,17 +94,19 @@ void DayNavigatorWidget::nextDayButtonClicked() if(mCurDatesetDisabled(true); - else - prevDayButton->setDisabled(false); - // check end date - if(mCurDate==mEndDate || mStartDate==mEndDate) - nextDayButton->setDisabled(true); - else - nextDayButton->setDisabled(false); + configureNavigation(); + emit(dateChanged(mCurDate)); + selectedDate->update(); + } +} +void DayNavigatorWidget::todayButtonClicked() +{ + QDate targetDate = QDate::currentDate(); + if (targetDate>mStartDate && targetDateupdate(); } diff --git a/src/gui/daynavigatorwidget.h b/src/gui/daynavigatorwidget.h index da5846d..d4ddcea 100644 --- a/src/gui/daynavigatorwidget.h +++ b/src/gui/daynavigatorwidget.h @@ -79,7 +79,9 @@ class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget void setDates(const QDate &aStartDate, const QDate &aEndDate); protected: void paintEvent(QPaintEvent *); + void configureNavigation(); private slots: + void todayButtonClicked(); void prevDayButtonClicked(); void nextDayButtonClicked(); signals: diff --git a/src/gui/daynavigatorwidget.ui b/src/gui/daynavigatorwidget.ui index cd4f9dc..1436100 100644 --- a/src/gui/daynavigatorwidget.ui +++ b/src/gui/daynavigatorwidget.ui @@ -61,14 +61,31 @@ + + + + ... + + + + :/icons/today.png:/icons/today.png + + + true + + + - + + + prevDayButtonClicked() nextDayButtonClicked() + todayButtonClicked() diff --git a/src/icons.qrc b/src/icons.qrc index 8f472ed..193c23f 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -9,5 +9,6 @@ icons/emblem-new.png icons/dialog-warning.png icons/search.png + icons/today.png diff --git a/src/icons/today.png b/src/icons/today.png new file mode 100644 index 0000000..cec3de3 Binary files /dev/null and b/src/icons/today.png differ