desktop: add support for camera sync delta of more than 24h

When using the camera sync feature to sync media to the dive timeline,
the calculated time difference was considered invalid if it was more
than 24 hours.

To prevent this, this commit disables the manual time offset input
fields when the camera sync button is clicked. It then uses the epoch
difference in the final offset calculation, enabling arbitrary time
differences between camera and divecomputer.

Signed-off-by: Tim Segers <tsegers@pm.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tim Segers 2021-09-10 21:23:42 +02:00 committed by Dirk Hohndel
parent 8525b2e274
commit 6ea4cfcc02
2 changed files with 8 additions and 12 deletions

View file

@ -122,15 +122,6 @@ ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : QDialog(parent),
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
}
void ShiftImageTimesDialog::buttonClicked(QAbstractButton *button)
{
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
m_amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60;
if (ui.backwards->isChecked())
m_amount *= -1;
}
}
void ShiftImageTimesDialog::syncCameraClicked()
{
QPixmap picture;
@ -141,6 +132,10 @@ void ShiftImageTimesDialog::syncCameraClicked()
if (fileNames.isEmpty())
return;
ui.timeEdit->setEnabled(false);
ui.backwards->setEnabled(false);
ui.forward->setEnabled(false);
picture.load(fileNames.at(0));
ui.displayDC->setEnabled(true);
QGraphicsScene *scene = new QGraphicsScene(this);
@ -160,7 +155,10 @@ void ShiftImageTimesDialog::dcDateTimeChanged(const QDateTime &newDateTime)
if (!dcImageEpoch)
return;
newtime.setTimeSpec(Qt::UTC);
setOffset(dateTimeToTimestamp(newtime) - dcImageEpoch);
m_amount = dateTimeToTimestamp(newtime) - dcImageEpoch;
if (m_amount)
updateInvalid();
}
void ShiftImageTimesDialog::matchAllImagesToggled(bool state)
@ -179,7 +177,6 @@ ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNa
matchAllImages(false)
{
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
connect(ui.syncCamera, SIGNAL(clicked()), this, SLOT(syncCameraClicked()));
connect(ui.timeEdit, SIGNAL(timeChanged(const QTime &)), this, SLOT(timeEditChanged(const QTime &)));
connect(ui.backwards, SIGNAL(toggled(bool)), this, SLOT(timeEditChanged()));

View file

@ -75,7 +75,6 @@ public:
bool matchAll();
private
slots:
void buttonClicked(QAbstractButton *button);
void syncCameraClicked();
void dcDateTimeChanged(const QDateTime &);
void timeEditChanged(const QTime &time);