From 3534e29ae2165aab491c2e0cdecd667dd8cf50e8 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 18:37:37 +0300 Subject: [PATCH] Port writing of date and time to new classes After splitting dive computer configuration classes, the date/time setting had not been ported. This adds the same to the classes. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 1 + qt-ui/configuredivecomputerdialog.ui | 95 ++++++++++++++------------ qt-ui/configuredivecomputerthreads.cpp | 15 ++++ qt-ui/devicedetails.cpp | 10 +++ qt-ui/devicedetails.h | 4 ++ 5 files changed, 81 insertions(+), 44 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index ea5e764dc..973243af7 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -204,6 +204,7 @@ void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); getDeviceData(); config->saveDeviceDetails(deviceDetails, &device_data); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 4f1c7a8af..580f86159 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 343 - 390 + 364 + 416 @@ -93,6 +93,41 @@ + + + + Brightness: + + + + + + + Serial No. + + + + + + + Custom Text: + + + + + + + true + + + + + + + Language: + + + @@ -146,48 +181,6 @@ - - - - Brightness: - - - - - - - true - - - - - - - Custom Text: - - - - - - - Serial No. - - - - - - - Language: - - - - - - - true - - - @@ -214,6 +207,20 @@ + + + + true + + + + + + + Sync dive computer time with PC + + + diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index 5d9f0e8b0..bddced474 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -1,6 +1,7 @@ #include "configuredivecomputerthreads.h" #include "libdivecomputer/hw.h" #include +#include ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) @@ -95,6 +96,20 @@ void WriteSettingsThread::run() hw_ostc3_device_config_write(m_data->device, 0x32, data, sizeof(data)); data[0] = m_deviceDetails->dateFormat(); hw_ostc3_device_config_write(m_data->device, 0x33, data, sizeof(data)); + + //sync date and time + if (m_deviceDetails->syncTime()) { + QDateTime timeToSet = QDateTime::currentDateTime(); + dc_datetime_t time; + time.year = timeToSet.date().year(); + time.month = timeToSet.date().month(); + time.day = timeToSet.date().day(); + time.hour = timeToSet.time().hour(); + time.minute = timeToSet.time().minute(); + time.second = timeToSet.time().second(); + hw_ostc3_device_clock(m_data->device, &time); + } + break; } diff --git a/qt-ui/devicedetails.cpp b/qt-ui/devicedetails.cpp index e5a90b9da..7d6212f18 100644 --- a/qt-ui/devicedetails.cpp +++ b/qt-ui/devicedetails.cpp @@ -86,3 +86,13 @@ void DeviceDetails::setLastDeco(int lastDeco) { m_lastDeco = lastDeco; } +bool DeviceDetails::syncTime() const +{ + return m_syncTime; +} + +void DeviceDetails::setSyncTime(bool syncTime) +{ + m_syncTime = syncTime; +} + diff --git a/qt-ui/devicedetails.h b/qt-ui/devicedetails.h index 9f5e7c1dd..a0d0f18c2 100644 --- a/qt-ui/devicedetails.h +++ b/qt-ui/devicedetails.h @@ -38,6 +38,9 @@ public: int lastDeco() const; void setLastDeco(int lastDeco); + bool syncTime() const; + void setSyncTime(bool syncTime); + private: device_data_t *m_data; QString m_serialNo; @@ -48,6 +51,7 @@ private: int m_language; int m_dateFormat; int m_lastDeco; + bool m_syncTime; };