From 6ea4cfcc02f3af97d41018c80e16462216e382a8 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Fri, 10 Sep 2021 21:23:42 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- desktop-widgets/simplewidgets.cpp | 19 ++++++++----------- desktop-widgets/simplewidgets.h | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 366b57a84..e5b2d1012 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -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())); diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 409395265..8a7418e33 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -75,7 +75,6 @@ public: bool matchAll(); private slots: - void buttonClicked(QAbstractButton *button); void syncCameraClicked(); void dcDateTimeChanged(const QDateTime &); void timeEditChanged(const QTime &time); -- cgit v1.2.3-70-g09d2