Bug 144185

Summary: Adjust date-time tool should remember previous fixed date
Product: [Applications] digikam Reporter: bcr
Component: Plugin-Generic-TimeAdjustAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 0.1.0
Sentry Crash Report:

Description bcr 2007-04-13 19:37:21 UTC
Version:           0.9.2-SVN (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

The new date-time feature that allows you to specify a fixed time and date is great however when you are adjusting a number of images over time it becomes irritating to have to continually reset the date entry field to something other than the current date. 

If a checkbox could be added beside that dialog, something like:

  [x] Current date

If unchecked the field would remember the previous setting between uses otherwise it would just adjust to the current date.
Comment 1 caulier.gilles 2007-06-09 11:06:33 UTC
SVN commit 673178 by cgilles:

kipi-plugins from KDE3 branch : TimeAdjust : remember the custom date set by user between session. Add button to reset custom date to current date.
BUG: 144185


 M  +34 -9     timeadjustdialog.cpp  
 M  +6 -6      timeadjustdialog.h  


--- branches/extragear/kde3/libs/kipi-plugins/timeadjust/timeadjustdialog.cpp #673177:673178
@@ -30,6 +30,7 @@
 
 // Qt includes.
 
+#include <qtooltip.h>
 #include <qlayout.h>
 #include <qlabel.h>
 #include <qvbuttongroup.h>
@@ -43,9 +44,11 @@
 #include <qgrid.h>
 #include <qpushbutton.h>
 #include <qframe.h>
+#include <qtoolbutton.h>
 
 // KDE includes.
 
+#include <kiconloader.h>
 #include <kdebug.h>
 #include <klocale.h>
 #include <kapplication.h>
@@ -104,6 +107,7 @@
         dateCreatedSel    = 0;
         interface         = 0;
         about             = 0;
+        todayBtn          = 0;
     }
 
     QRadioButton             *add;
@@ -111,6 +115,8 @@
     QRadioButton             *exif;
     QRadioButton             *custom;
 
+    QToolButton              *todayBtn;
+
     QCheckBox                *syncEXIFDateCheck;
     QCheckBox                *syncIPTCDateCheck;
 
@@ -195,22 +201,26 @@
     // -- Adjustment type ------------------------------------------------------------
 
     QVGroupBox *adjGB = new QVGroupBox(i18n("Adjustment Type"), plainPage());
-    d->adjustTypeGrp   = new QButtonGroup(1, Qt::Horizontal, adjGB);
-    d->add             = new QRadioButton(i18n("Add"), d->adjustTypeGrp);
-    d->subtract        = new QRadioButton(i18n("Subtract"), d->adjustTypeGrp);
-    d->exif            = new QRadioButton(i18n("Set file date to EXIF/IPTC creation date"), d->adjustTypeGrp);
-    d->custom          = new QRadioButton(i18n("Custom date"), d->adjustTypeGrp);
+    d->adjustTypeGrp  = new QButtonGroup(1, Qt::Horizontal, adjGB);
+    d->add            = new QRadioButton(i18n("Add"), d->adjustTypeGrp);
+    d->subtract       = new QRadioButton(i18n("Subtract"), d->adjustTypeGrp);
+    d->exif           = new QRadioButton(i18n("Set file date to EXIF/IPTC creation date"), d->adjustTypeGrp);
+    d->custom         = new QRadioButton(i18n("Custom date"), d->adjustTypeGrp);
 
     d->adjustTypeGrp->setFrameStyle(QFrame::NoFrame);
     d->adjustTypeGrp->setInsideMargin(0); 
     d->adjustTypeGrp->setRadioButtonExclusive(true);
 
     QHBox *hbox       = new QHBox(d->adjustTypeGrp);
-    QLabel *space     = new QLabel(hbox);
+    QLabel *space1     = new QLabel(hbox);
+    space1->setFixedWidth(15);
     d->dateCreatedSel = new KDateTimeWidget(hbox);
+    QLabel *space2     = new QLabel(hbox);
+    space2->setFixedWidth(15);
+    d->todayBtn       = new QToolButton(hbox);   
+    d->todayBtn->setIconSet(SmallIcon("today"));
+    QToolTip::add(d->todayBtn, i18n("Reset to current date"));
     new QLabel(hbox);
-    space->setFixedWidth(15);
-    d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
     
     d->syncEXIFDateCheck = new QCheckBox(i18n("Update Exif creation date"), d->adjustTypeGrp);
     d->syncIPTCDateCheck = new QCheckBox(i18n("Update IPTC creation date"), d->adjustTypeGrp);
@@ -291,6 +301,9 @@
     connect(d->years, SIGNAL( valueChanged( int ) ),
             this, SLOT( slotUpdateExample() ));
 
+    connect(d->todayBtn, SIGNAL(clicked()),
+            this, SLOT(slotResetDateToCurrent()));
+
     // -----------------------------------------------------------------------
 
     readSettings();
@@ -308,6 +321,11 @@
     KApplication::kApplication()->invokeHelp("timeadjust", "kipi-plugins");
 }
 
+void TimeAdjustDialog::slotResetDateToCurrent()
+{
+    d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
+}
+
 void TimeAdjustDialog::closeEvent(QCloseEvent *e)
 {
     if (!e) return;
@@ -332,6 +350,9 @@
     if (adjType == 2) d->exif->setChecked(true);
     if (adjType == 3) d->custom->setChecked(true);
 
+    QDateTime current = QDateTime::currentDateTime();
+    d->dateCreatedSel->setDateTime(config.readDateTimeEntry("Custom Date", &current));
+
     d->syncEXIFDateCheck->setChecked(config.readBoolEntry("Sync EXIF Date", true));
     d->syncIPTCDateCheck->setChecked(config.readBoolEntry("Sync IPTC Date", true));
     resize(configDialogSize(config, QString("Time Adjust Dialog")));
@@ -348,6 +369,8 @@
     if (d->custom->isChecked())   adjType = 3;
     config.writeEntry("Adjustment Type", adjType);
 
+    config.writeEntry("Custom Date", d->dateCreatedSel->dateTime());
+
     config.writeEntry("Sync EXIF Date", d->syncEXIFDateCheck->isChecked());
     config.writeEntry("Sync IPTC Date", d->syncIPTCDateCheck->isChecked());
     saveDialogSize(config, QString("Time Adjust Dialog"));
@@ -402,7 +425,7 @@
     QString newDate = date.toString(Qt::LocalDate);
     d->exampleAdj->setText(i18n("<b>%1</b><br>would, for example, "
                                "change into<br><b>%2</b>")
-                          .arg(oldDate).arg(newDate));
+                           .arg(oldDate).arg(newDate));
 }
 
 void TimeAdjustDialog::slotAdjustmentTypeChanged()
@@ -410,6 +433,7 @@
     d->exampleBox->setEnabled(false);
     d->adjustValGrp->setEnabled(false);
     d->dateCreatedSel->setEnabled(false);
+    d->todayBtn->setEnabled(false);
     d->syncEXIFDateCheck->setEnabled(false);
     d->syncIPTCDateCheck->setEnabled(false);
 
@@ -423,6 +447,7 @@
     else if (d->custom->isChecked())
     {
         d->dateCreatedSel->setEnabled(true);
+        d->todayBtn->setEnabled(true);
         d->syncEXIFDateCheck->setEnabled(true);
         d->syncIPTCDateCheck->setEnabled(true);
     }
--- branches/extragear/kde3/libs/kipi-plugins/timeadjust/timeadjustdialog.h #673177:673178
@@ -54,18 +54,19 @@
     
     void setImages(const KURL::List& images);
 
-protected slots:
+protected:
 
+    void closeEvent(QCloseEvent *);
+
+private slots:
+
     void slotUpdateExample();
     void slotAdjustmentTypeChanged();
     void slotOk();
     void slotCancel();
     void slotHelp();
+    void slotResetDateToCurrent();
 
-protected:
-
-    void closeEvent(QCloseEvent *);
-
 private:
 
     void readSettings();
@@ -75,7 +76,6 @@
 private:
 
     TimeAdjustDialogPrivate *d;
-
 };
 
 }  // NameSpace KIPITimeAdjustPlugin