mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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 <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
parent
20eb62a98a
commit
3534e29ae2
5 changed files with 81 additions and 44 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>343</width>
|
||||
<height>390</height>
|
||||
<width>364</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -93,6 +93,41 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Brightness:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Serial No.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Custom Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serialNoLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="customTextLlineEdit"/>
|
||||
</item>
|
||||
|
@ -146,48 +181,6 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Brightness:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serialNoLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Custom Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Serial No.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="firmwareVersionLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
|
@ -214,6 +207,20 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="firmwareVersionLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="dateTimeSyncCheckBox">
|
||||
<property name="text">
|
||||
<string>Sync dive computer time with PC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "configuredivecomputerthreads.h"
|
||||
#include "libdivecomputer/hw.h"
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue