diff options
author | Tim Segers <tsegers@pm.me> | 2021-09-10 21:23:42 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-09-22 09:09:12 -0700 |
commit | 6ea4cfcc02f3af97d41018c80e16462216e382a8 (patch) | |
tree | ffbe07671750a85c0e6449cd276f65503cdb0611 | |
parent | 8525b2e274cc250d7345816423c3ffa0c4e50108 (diff) | |
download | subsurface-6ea4cfcc02f3af97d41018c80e16462216e382a8.tar.gz |
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>
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 19 | ||||
-rw-r--r-- | 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); |