Summary: | prefix for image filename in camera dialog not working | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | peter kreutzer <peter.kreutzer> |
Component: | AdvancedRename-Import | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | caulier.gilles |
Priority: | NOR | ||
Version: | 0.9.0 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 0.9.0 | |
Sentry Crash Report: | |||
Attachments: | Camera UI and Advanced Date and Time dialog opened |
Description
peter kreutzer
2006-09-17 19:00:48 UTC
This part was rewritten because the C functions used could not handle UTF8 strings, umlauts were broken, so now we use Qt's functions (QDateTime::toString). And the prefix and suffix is now longer parsed by toString. So, - was this an official feature? - do we want configurable date format? I can understand that there is no default everyone can agree with. - so should we provide a GUI to change the date string (currently yyyyMMddThhmmss, QDateTime syntax?) Marcel, Look my code about 'Date format' from 'Auto-creation of album' settings. i think it's can be enough to provide a similar option into 'Renaming' settings. Also this way will give an homogenous interface. If the user use 'Local Settings' option, the user will use the date format set into the KDE control panel. Gilles This is how Krename is working. You define the date formate in KDE control panel and use the EXIF date and time to rename the files according the EXIF information provided by the image. From the user point of view I would like to insert the images into the image database from the beginning with the right naming concept without an additional process step to rename them outside digikam. I have now some code ready which adds said combination of label+combobox. In the combobox, default is "Standard" which represents the default date format used by digikam previously (and is still the default), then ISO, User Readable, Local, and Advanced. When advanced is chosen, an input dialog pops up which allows to enter a custom string in QDateTime syntax (shortly explained there). I feel with date and time there is much greater variability, some users will want only date, other only time, in an endless number of differing formats (which leads to creating bug reports). So I think its a good idea to offer flexibility. What I am unsure, currently, is how provide a way to open the dialog. Currently, it is opened only when "Advanced..." is newly activated. I also tried a) a hidden pushbutton which is shown when "Advanced" is chosen - triggers relayouting b) a disabled pushbutton which is then enabled - clutters interface Viewpoints? I think that button need to be in the sidebar, near the combobox option. There is no space available outside the sidebar for that. Also, the button option is only used with the advanced settings. I think it's a non-sence to place it outside this side bar tab. Are you do 2 buttons ? one for the renaming files options and one for the albums naming options... Perhaps a common widget including the combobox and the button can be more simple in this case. Gilles What I meant was a small button (text "..." or "Configure...") immediately next to the combo box, in the same QHBox, and only enabled/visible when "Advanced..." is chosen. Alternatively, there is no button, and the advanced settings (KInputDialog) are only accessible when "Advanced..." is newly activated in the combo box. Initially I planned to use the same combo box to specify both date formats, then I at least tried to create a common widget. But the two options differ: One is only for date, the other for date&time. The latter offers two more options in the combo box. The QWhatThis differs. So now, there are two combo boxes. The new one is just added where previously was only the date&time checkbox. > small button Well, to reduce to max the sapce used, just use a button with a kde "configure" icon. Have you a screenshot of the settings sidebar tab modified ? > only the date&time checkbox Right. I have forget this difference. Gilles Created attachment 17850 [details]
Camera UI and Advanced Date and Time dialog opened
The icon was just the solution I was looking for!
In the attached screenshot you can see the date and time settings on the
sidebar. Advanced in chosen, so the button is enabled. On the left you can see
the dialog that appears when the button is clicked.
One problem: The whole dialog has a height of 750px here, max. is 600 in KDE
guidelines. So thats a bit too much.
The screenshot sound good for me. About the size of main dialog, i have already see this problem before but let's this problem in stand bye. I you want fix it, a possible solution is to use a QToolBox in the "Settings" sidebar tab to stack "Renaming Options", "Auto-creation of Albums", and "On the Fly Operations (JPEG only)" settings groups. Look into imageeffect_iccproof.cpp, i have already used this way with the Color Managment image plugin dialog. Gilles SVN commit 586866 by mwiesweg: Allow to configure date & time format. Choice is Standard (previous default), Iso, User readable, Local settings, Advanced. Advanced allows to specify the format in QDateTime syntax. BUG: 134224 M +154 -12 renamecustomizer.cpp M +4 -1 renamecustomizer.h --- trunk/extragear/graphics/digikam/utilities/cameragui/renamecustomizer.cpp #586865:586866 @@ -30,6 +30,7 @@ #include <qcombobox.h> #include <qhbox.h> #include <qlabel.h> +#include <qpushbutton.h> #include <qtimer.h> #include <qwhatsthis.h> @@ -38,9 +39,15 @@ #include <klocale.h> #include <kconfig.h> #include <kapplication.h> +#include <kiconloader.h> #include <klineedit.h> #include <knuminput.h> #include <kdialogbase.h> +#if KDE_IS_VERSION(3,2,0) +#include <kinputdialog.h> +#else +#include <klineeditdlg.h> +#endif // Local includes. @@ -53,6 +60,15 @@ { public: + enum DateFormatOptions + { + DigikamStandard = 0, + IsoDateFormat, + TextDateFormat, + LocalDateFormat, + Advanced + }; + RenameCustomizerPriv() { renameDefault = 0; @@ -66,11 +82,14 @@ addSeqNumberBox = 0; changedTimer = 0; renameCustomPrefix = 0; - renameCustomSuffix = 0; + renameCustomSuffix = 0; startIndexLabel = 0; startIndexInput = 0; focusedWidget = 0; - } + dateTimeButton = 0; + dateTimeLabel = 0; + dateTimeFormat = 0; +} QWidget *focusedWidget; @@ -84,13 +103,18 @@ QLabel *renameDefaultCase; QLabel *startIndexLabel; + QLabel *dateTimeLabel; QComboBox *renameDefaultCaseType; + QComboBox *dateTimeFormat; QCheckBox *addDateTimeBox; QCheckBox *addCameraNameBox; QCheckBox *addSeqNumberBox; + QPushButton *dateTimeButton; + QString dateTimeFormatString; + QTimer *changedTimer; KLineEdit *renameCustomPrefix; @@ -134,10 +158,10 @@ QWhatsThis::add( d->renameDefaultCaseType, i18n("<p>Set here the method to use to change case " "of image filenames.")); - QHBoxLayout* boxLayout = new QHBoxLayout( d->renameDefaultBox->layout() ); - boxLayout->addSpacing( 10 ); - boxLayout->addWidget( d->renameDefaultCase ); - boxLayout->addWidget( d->renameDefaultCaseType ); + QHBoxLayout* boxLayout1 = new QHBoxLayout( d->renameDefaultBox->layout() ); + boxLayout1->addSpacing( 10 ); + boxLayout1->addWidget( d->renameDefaultCase ); + boxLayout1->addWidget( d->renameDefaultCaseType ); mainLayout->addMultiCellWidget(d->renameDefaultBox, 1, 1, 0, 1); @@ -154,7 +178,7 @@ d->renameCustomBox->setColumnLayout(0, Qt::Vertical); QGridLayout* renameCustomBoxLayout = new QGridLayout(d->renameCustomBox->layout(), - 5, 2, KDialogBase::spacingHint()); + 6, 2, KDialogBase::spacingHint()); renameCustomBoxLayout->setColSpacing( 0, 10 ); QLabel* prefixLabel = new QLabel(i18n("Prefix:"), d->renameCustomBox); @@ -176,12 +200,40 @@ renameCustomBoxLayout->addMultiCellWidget(d->addDateTimeBox, 2, 2, 1, 2); QWhatsThis::add( d->addDateTimeBox, i18n("<p>Set this option to add the camera provided date and time.")); + QWidget *dateTimeWidget = new QWidget(d->renameCustomBox); + d->dateTimeLabel = new QLabel(i18n("Date format:"), dateTimeWidget); + d->dateTimeFormat = new QComboBox(dateTimeWidget); + d->dateTimeFormat->insertItem(i18n("Standard"), RenameCustomizerPriv::DigikamStandard); + d->dateTimeFormat->insertItem(i18n("ISO"), RenameCustomizerPriv::IsoDateFormat); + d->dateTimeFormat->insertItem(i18n("Full Text"), RenameCustomizerPriv::TextDateFormat); + d->dateTimeFormat->insertItem(i18n("Local Settings"), RenameCustomizerPriv::LocalDateFormat); + d->dateTimeFormat->insertItem(i18n("Advanced..."), RenameCustomizerPriv::Advanced); + QWhatsThis::add( d->dateTimeFormat, i18n("<p>Select here your preferred date format used to " + "create new albums. The options available are:</p>" + "<p><b>Standard</b>: the date format that has been used as a standard by digiKam." + "Ex.: <i>20060824T142618</i></p>" + "<p/><b>ISO</b>: the date format is in accordance with ISO 8601 " + "(YYYY-MM-DD). Ex.: <i>2006-08-24T14:26:18</i></p>" + "<p><b>Full Text</b>: the date format is in a user-readable string. " + "Ex.: <i>Thu Aug 24 14:26:18 2006</i></p>" + "<p><b>Local Settings</b>: the date format depending on KDE control panel settings.</p>" + "<p><b>Advanced:</b> allows to specify a custom date format.</p>")); + d->dateTimeButton = new QPushButton(SmallIcon("configure"), QString(), dateTimeWidget); + QSizePolicy policy = d->dateTimeButton->sizePolicy(); + policy.setHorData(QSizePolicy::Maximum); + d->dateTimeButton->setSizePolicy(policy); + QHBoxLayout *boxLayout2 = new QHBoxLayout(dateTimeWidget); + boxLayout2->addWidget(d->dateTimeLabel); + boxLayout2->addWidget(d->dateTimeFormat); + boxLayout2->addWidget(d->dateTimeButton); + renameCustomBoxLayout->addMultiCellWidget(dateTimeWidget, 3, 3, 1, 2); + d->addCameraNameBox = new QCheckBox( i18n("Add Camera Name"), d->renameCustomBox ); - renameCustomBoxLayout->addMultiCellWidget(d->addCameraNameBox, 3, 3, 1, 2); + renameCustomBoxLayout->addMultiCellWidget(d->addCameraNameBox, 4, 4, 1, 2); QWhatsThis::add( d->addCameraNameBox, i18n("<p>Set this option to add the camera name.")); d->addSeqNumberBox = new QCheckBox( i18n("Add Sequence Number"), d->renameCustomBox ); - renameCustomBoxLayout->addMultiCellWidget(d->addSeqNumberBox, 4, 4, 1, 2); + renameCustomBoxLayout->addMultiCellWidget(d->addSeqNumberBox, 5, 5, 1, 2); QWhatsThis::add( d->addSeqNumberBox, i18n("<p>Set this option to add a sequence number starting with the index set below.")); d->startIndexLabel = new QLabel( i18n("Start Index:"), d->renameCustomBox ); @@ -190,8 +242,8 @@ QWhatsThis::add( d->startIndexInput, i18n("<p>Set here the start index value used to rename picture " "files with a sequence number.")); - renameCustomBoxLayout->addMultiCellWidget(d->startIndexLabel, 5, 5, 1, 1); - renameCustomBoxLayout->addMultiCellWidget(d->startIndexInput, 5, 5, 2, 2); + renameCustomBoxLayout->addMultiCellWidget(d->startIndexLabel, 6, 6, 1, 1); + renameCustomBoxLayout->addMultiCellWidget(d->startIndexInput, 6, 6, 2, 2); mainLayout->addMultiCellWidget(d->renameCustomBox, 3, 3, 0, 1); @@ -224,9 +276,21 @@ connect(d->changedTimer, SIGNAL(timeout()), this, SIGNAL(signalChanged())); + connect(d->dateTimeButton, SIGNAL(clicked()), + this, SLOT(slotDateTimeButtonClicked())); + + connect(d->dateTimeFormat, SIGNAL(activated(int)), + this, SLOT(slotDateTimeFormatChanged(int))); + + connect(d->addDateTimeBox, SIGNAL(toggled(bool)), + this, SLOT(slotDateTimeBoxToggled(bool))); + // -- initial values --------------------------------------------------- readSettings(); + + // signal to this not yet connected when readSettings is called? Don't know + slotDateTimeBoxToggled(d->addDateTimeBox->isChecked()); } RenameCustomizer::~RenameCustomizer() @@ -255,7 +319,25 @@ QString name(d->renameCustomPrefix->text()); // use the "T" as a delimiter between date and time - QString date = dateTime.toString("yyyyMMddThhmmss"); + QString date; + switch (d->dateTimeFormat->currentItem()) + { + case RenameCustomizerPriv::DigikamStandard: + date = dateTime.toString("yyyyMMddThhmmss"); + break; + case RenameCustomizerPriv::TextDateFormat: + date = dateTime.toString(Qt::TextDate); + break; + case RenameCustomizerPriv::LocalDateFormat: + date = dateTime.toString(Qt::LocalDate); + break; + case RenameCustomizerPriv::IsoDateFormat: + date = dateTime.toString(Qt::ISODate); + break; + case RenameCustomizerPriv::Advanced: + date = dateTime.toString(d->dateTimeFormatString); + break; + } // it seems that QString::number does not support padding with zeros QString seq; @@ -318,6 +400,60 @@ d->changedTimer->start(500, true); } +void RenameCustomizer::slotDateTimeBoxToggled(bool on) +{ + d->dateTimeLabel->setEnabled(on); + d->dateTimeFormat->setEnabled(on); + d->dateTimeButton->setEnabled(on + && d->dateTimeFormat->currentItem() == RenameCustomizerPriv::Advanced); + slotRenameOptionsChanged(); +} + +void RenameCustomizer::slotDateTimeFormatChanged(int index) +{ + if (index == RenameCustomizerPriv::Advanced) + { + d->dateTimeButton->setEnabled(true); + //d->dateTimeButton->show(); + //slotDateTimeButtonClicked(); + } + else + { + d->dateTimeButton->setEnabled(false); + //d->dateTimeButton->hide(); + } + slotRenameOptionsChanged(); +} + +void RenameCustomizer::slotDateTimeButtonClicked() +{ + bool ok; + +#if KDE_IS_VERSION(3,2,0) + QString newFormat = KInputDialog::getText(i18n("Change Date & Time Format"), + i18n("<p>Enter the format for date and time.</p>" + "<p>Use <i>dd</i> for the day, <i>MM</i> for the month, <i>yyyy</i> for the year, " + "<i>hh</i> for the hour, <i>mm</i> for the minute, <i>ss</i> for the second.</p>" + "<p>Examples: <i>yyyyMMddThhmmss</i> for 20060824T142418,<br>" + "<i>yyyy-MM-dd hh:mm:ss</i> for 2006-08-24 14:24:18.</p>"), + d->dateTimeFormatString, &ok, this); +#else + QString newFormat = KLineEditDlg::getText(i18n("Change Date & Time Format"), + i18n("<p>Enter the format for date and time.</p>" + "<p>Use <i>dd</i> for the day, <i>MM</i> for the month, <i>yyyy</i> for the year, " + "<i>hh</i> for the hour, <i>mm</i> for the minute, <i>ss</i> for the second.</p>" + "<p>Examples: <i>yyyyMMddThhmmss</i> for 20060824T142418,<br>" + "<i>yyyy-MM-dd hh:mm:ss</i> for 2006-08-24 14:24:18.</p>"), + d->dateTimeFormatString, &ok, this); +#endif + + if (!ok) + return; + + d->dateTimeFormatString = newFormat; + slotRenameOptionsChanged(); +} + void RenameCustomizer::readSettings() { KConfig* config = kapp->config(); @@ -331,6 +467,8 @@ QString prefix = config->readEntry("Rename Prefix", i18n("photo")); QString suffix = config->readEntry("Rename Postfix", QString()); int startIndex = config->readNumEntry("Rename Start Index", 1); + int dateTime = config->readNumEntry("Date Time Format", RenameCustomizerPriv::IsoDateFormat); + QString format = config->readEntry("Date Time Format String", "yyyyMMddThhmmss"); if (def) { @@ -354,6 +492,8 @@ d->renameCustomPrefix->setText(prefix); d->renameCustomSuffix->setText(suffix); d->startIndexInput->setValue(startIndex); + d->dateTimeFormat->setCurrentItem(dateTime); + d->dateTimeFormatString = format; slotRenameOptionsChanged(); } @@ -370,6 +510,8 @@ config->writeEntry("Rename Prefix", d->renameCustomPrefix->text()); config->writeEntry("Rename Suffix", d->renameCustomSuffix->text()); config->writeEntry("Rename Start Index", d->startIndexInput->value()); + config->writeEntry("Date Time Format", d->dateTimeFormat->currentItem()); + config->writeEntry("Date Time Format String", d->dateTimeFormatString); config->sync(); } --- trunk/extragear/graphics/digikam/utilities/cameragui/renamecustomizer.h #586865:586866 @@ -53,7 +53,7 @@ void setUseDefault(bool val); bool useDefault() const; - QString newName(const QDateTime &date, int index, const QString &suffix) const; + QString newName(const QDateTime &date, int index, const QString &extension) const; Case changeCase() const; int startIndex() const; @@ -74,6 +74,9 @@ void slotRadioButtonClicked(int); void slotRenameOptionsChanged(); + void slotDateTimeBoxToggled(bool); + void slotDateTimeFormatChanged(int); + void slotDateTimeButtonClicked(); private: |