Commit c5453b78 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

polish

parent 74f1e934
......@@ -53,6 +53,7 @@
#include "kpimagedialog.h"
#include "kpmetadata.h"
#include "kppreviewmanager.h"
#include "timeadjustsettings.h"
using namespace KIPIPlugins;
......@@ -70,6 +71,8 @@ public:
imagePreview = 0;
}
DeltaTime deltaValues;
QDateTimeEdit* calendar;
QDateTime photoDateTime;
......@@ -79,13 +82,6 @@ public:
ClockPhotoDialog::ClockPhotoDialog(QWidget* const parent)
: KDialog(parent), d(new ClockPhotoDialogPrivate)
{
// Initialize the variables.
m_deltaNegative = false;
m_deltaDays = 0;
m_deltaHours = 0;
m_deltaMinutes = 0;
m_deltaSeconds = 0;
// This dialog should be modal with three buttons: Ok, Cancel, and load
// photo. For this third button, the User1 button from KDialog is used.
// The Ok button is only enable when a photo is loaded.
......@@ -142,9 +138,7 @@ ClockPhotoDialog::ClockPhotoDialog(QWidget* const parent)
this, SLOT(slotCancel()));
// Show the window.
KConfig config("kipirc");
KConfigGroup group = config.group(QString("Clock Photo Dialog"));
restoreDialogSize(group);
loadSettings();
show();
// Upon initialization, present the user with a photo loading dialog. This
......@@ -157,6 +151,11 @@ ClockPhotoDialog::~ClockPhotoDialog()
delete d;
}
DeltaTime ClockPhotoDialog::deltaValues() const
{
return d->deltaValues;
}
bool ClockPhotoDialog::setImage(const KUrl& imageFile)
{
bool success = false;
......@@ -205,7 +204,14 @@ bool ClockPhotoDialog::setImage(const KUrl& imageFile)
return success;
}
void ClockPhotoDialog::saveSize()
void ClockPhotoDialog::loadSettings()
{
KConfig config("kipirc");
KConfigGroup group = config.group(QString("Clock Photo Dialog"));
restoreDialogSize(group);
}
void ClockPhotoDialog::saveSettings()
{
KConfig config("kipirc");
KConfigGroup group = config.group(QString("Clock Photo Dialog"));
......@@ -245,33 +251,33 @@ void ClockPhotoDialog::slotOk()
// subtraction.
if (delta < 0)
{
m_deltaNegative = true;
delta *= -1;
d->deltaValues.deltaNegative = true;
delta *= -1;
}
else
{
m_deltaNegative = false;
d->deltaValues.deltaNegative = false;
}
// Calculate the number of days, hours, minutes and seconds.
m_deltaDays = delta / 86400;
delta = delta % 86400;
m_deltaHours = delta / 3600;
delta = delta % 3600;
m_deltaMinutes = delta / 60;
delta = delta % 60;
m_deltaSeconds = delta;
d->deltaValues.deltaDays = delta / 86400;
delta = delta % 86400;
d->deltaValues.deltaHours = delta / 3600;
delta = delta % 3600;
d->deltaValues.deltaMinutes = delta / 60;
delta = delta % 60;
d->deltaValues.deltaSeconds = delta;
// Accept the dialog.
saveSize();
saveSettings();
accept();
}
/** If the cancel button is clicked, reject the dialog.
*/
*/
void ClockPhotoDialog::slotCancel()
{
saveSize();
saveSettings();
reject();
}
......
......@@ -32,6 +32,8 @@
namespace KIPITimeAdjustPlugin
{
class DeltaTime;
class ClockPhotoDialog : public KDialog
{
Q_OBJECT
......@@ -47,15 +49,7 @@ public:
*/
bool setImage(const KUrl&);
public:
/** The public variables that hold the time difference.
*/
bool m_deltaNegative;
int m_deltaDays;
int m_deltaHours;
int m_deltaMinutes;
int m_deltaSeconds;
DeltaTime deltaValues() const;
private Q_SLOTS:
......@@ -65,7 +59,8 @@ private Q_SLOTS:
private:
void saveSize();
void loadSettings();
void saveSettings();
private:
......
......@@ -498,11 +498,12 @@ void SettingsWidget::slotDetAdjustmentByClockPhoto()
if (result == QDialog::Accepted)
{
if (dlg->m_deltaDays == 0 && dlg->m_deltaHours == 0 && dlg->m_deltaMinutes == 0 && dlg->m_deltaSeconds == 0)
DeltaTime dvalues = dlg->deltaValues();
if (dvalues.isNull())
{
d->adjTypeChooser->setCurrentIndex(TimeAdjustSettings::COPYVALUE);
}
else if (dlg->m_deltaNegative)
else if (dvalues.deltaNegative)
{
d->adjTypeChooser->setCurrentIndex(TimeAdjustSettings::SUBVALUE);
}
......@@ -511,9 +512,9 @@ void SettingsWidget::slotDetAdjustmentByClockPhoto()
d->adjTypeChooser->setCurrentIndex(TimeAdjustSettings::ADDVALUE);
}
d->adjDaysInput->setValue(dlg->m_deltaDays);
d->adjDaysInput->setValue(dvalues.deltaDays);
QTime deltaTime;
deltaTime.setHMS(dlg->m_deltaHours, dlg->m_deltaMinutes, dlg->m_deltaSeconds);
deltaTime.setHMS(dvalues.deltaHours, dvalues.deltaMinutes, dvalues.deltaSeconds);
d->adjTimeInput->setTime(deltaTime);
}
......
......@@ -26,6 +26,8 @@
namespace KIPITimeAdjustPlugin
{
/** Container that store all timestamp adjustments.
*/
class TimeAdjustSettings
{
......@@ -85,7 +87,7 @@ public:
};
/// Check if at least one option is selected
bool atLeastOneUpdateToProcess()
bool atLeastOneUpdateToProcess() const
{
return (updAppDate ||
updFileModDate ||
......@@ -113,6 +115,47 @@ public:
int fileDateSource;
};
// -------------------------------------------------------------------
/** Container that hold the time difference for clock photo dialog.
*/
class DeltaTime
{
public:
DeltaTime()
{
deltaNegative = false;
deltaDays = 0;
deltaHours = 0;
deltaMinutes = 0;
deltaSeconds = 0;
};
~DeltaTime()
{
};
/// Check if at least one option is selected
bool isNull() const
{
return (deltaDays == 0 &&
deltaHours == 0 &&
deltaMinutes == 0 &&
deltaSeconds == 0);
}
public:
bool deltaNegative;
int deltaDays;
int deltaHours;
int deltaMinutes;
int deltaSeconds;
};
} // namespace KIPITimeAdjustPlugin
#endif // TIMEADJUSTSETTING_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment