Package: confclerk
Version: 0.5.2-1
Severity: wishlist
Tag: patch

Hi Gregor,

I just came up with the attached patch for a little added convenience.
src/icons/today.png is not included, I would suggest
/usr/share/icons/gnome/32x32/mimetypes/x-office-calendar.png for this.

Apply as you wish :-)

Cheers,
-- 
Michael Schutte                   | michi@{uiae.at,debian.org}
Innsbruck, Austria                | happily accepting encrypted mail
OpenPGP: 0x16fb 517b a866 c3f6 8f11 1485 f3e4 122f 1D8C 261A
Index: src/icons.qrc
===================================================================
--- src/icons.qrc	(Revision 2605)
+++ src/icons.qrc	(Arbeitskopie)
@@ -9,5 +9,6 @@
     <file>icons/emblem-new.png</file>
     <file>icons/dialog-warning.png</file>
     <file>icons/search.png</file>
+    <file>icons/today.png</file>
   </qresource>
 </RCC>
Index: src/gui/daynavigatorwidget.h
===================================================================
--- src/gui/daynavigatorwidget.h	(Revision 2605)
+++ src/gui/daynavigatorwidget.h	(Arbeitskopie)
@@ -79,7 +79,9 @@
         void setDates(const QDate &aStartDate, const QDate &aEndDate);
     protected:
         void paintEvent(QPaintEvent *);
+        void configureNavigation();
     private slots:
+        void todayButtonClicked();
         void prevDayButtonClicked();
         void nextDayButtonClicked();
     signals:
Index: src/gui/daynavigatorwidget.cpp
===================================================================
--- src/gui/daynavigatorwidget.cpp	(Revision 2605)
+++ src/gui/daynavigatorwidget.cpp	(Arbeitskopie)
@@ -34,6 +34,7 @@
     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::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 @@
     if(mCurDate<mEndDate)
     {
         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();
+    }
+}
 
+void DayNavigatorWidget::todayButtonClicked()
+{
+    QDate targetDate = QDate::currentDate();
+    if (targetDate>mStartDate && targetDate<mEndDate)
+    {
+        mCurDate = targetDate;
+        configureNavigation();
         emit(dateChanged(mCurDate));
         selectedDate->update();
     }
Index: src/gui/daynavigatorwidget.ui
===================================================================
--- src/gui/daynavigatorwidget.ui	(Revision 2605)
+++ src/gui/daynavigatorwidget.ui	(Arbeitskopie)
@@ -61,14 +61,31 @@
        </property>
       </widget>
      </item>
+     <item>
+      <widget class="QToolButton" name="todayButton">
+       <property name="text">
+        <string>...</string>
+       </property>
+       <property name="icon">
+        <iconset resource="../icons.qrc">
+         <normaloff>:/icons/today.png</normaloff>:/icons/today.png</iconset>
+       </property>
+       <property name="autoRaise">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
   </layout>
  </widget>
- <resources/>
+ <resources>
+  <include location="../icons.qrc"/>
+ </resources>
  <connections/>
  <slots>
   <slot>prevDayButtonClicked()</slot>
   <slot>nextDayButtonClicked()</slot>
+  <slot>todayButtonClicked()</slot>
  </slots>
 </ui>

Attachment: signature.asc
Description: Digital signature

Reply via email to