[PATCH 2/9] Don't allow writing before we got data

Anton Lundin glance at acc.umu.se
Wed Oct 15 16:13:51 PDT 2014


Don't allow creation of backup files or writes to the computer before we
know we got some data, either from a backup file or from the actual
device.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/configuredivecomputerdialog.cpp |  8 ++++++++
 qt-ui/configuredivecomputerdialog.ui  | 12 ++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index 7a1ce24..97b76c8 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -324,6 +324,10 @@ void ConfigureDiveComputerDialog::deviceDetailsReceived(DeviceDetails *newDevice
 
 void ConfigureDiveComputerDialog::reloadValues()
 {
+	// Enable the buttons to do operations on this data
+	ui->saveSettingsPushButton->setEnabled(true);
+	ui->backupButton->setEnabled(true);
+
 	switch(ui->dcStackedWidget->currentIndex()) {
 	case 0:
 		reloadValuesOSTC3();
@@ -525,6 +529,10 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked()
 
 void ConfigureDiveComputerDialog::on_DiveComputerList_currentRowChanged(int currentRow)
 {
+	// Disable the buttons to do operations on this data
+	ui->saveSettingsPushButton->setEnabled(false);
+	ui->backupButton->setEnabled(false);
+
 	switch (currentRow) {
 	case 0:
 		selected_vendor = "Heinrichs Weikamp";
diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui
index ea836f4..f736bd3 100644
--- a/qt-ui/configuredivecomputerdialog.ui
+++ b/qt-ui/configuredivecomputerdialog.ui
@@ -57,6 +57,12 @@
      </item>
      <item>
       <widget class="QPushButton" name="saveSettingsPushButton">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="toolTip">
+        <string>Read settnings from backup file or from device before writing to the device</string>
+       </property>
        <property name="text">
         <string>Save changes to device</string>
        </property>
@@ -77,6 +83,12 @@
      </item>
      <item>
       <widget class="QPushButton" name="backupButton">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="toolTip">
+        <string>Read settnings from backup file or from device before writing to a backup file</string>
+       </property>
        <property name="text">
         <string>Backup</string>
        </property>
-- 
1.9.1



More information about the subsurface mailing list