mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Working XML Backup and Restore
The ConfigureDiveComputer class now has functions for complete XML backup and restore. These dump the loaded settings on a dive computer to an XML file, and there is an option to restore them. Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
parent
e54d7d9178
commit
aad60ef6da
4 changed files with 115 additions and 13 deletions
|
@ -244,7 +244,7 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked()
|
|||
QString errorText = "";
|
||||
if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) {
|
||||
QMessageBox::critical(this, tr("XML Backup Error"),
|
||||
tr("An eror occurred while saving the backup file.\n%1")
|
||||
tr("An error occurred while saving the backup file.\n%1")
|
||||
.arg(errorText)
|
||||
);
|
||||
} else {
|
||||
|
@ -255,3 +255,29 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked()
|
||||
{
|
||||
QString filename = existing_filename ?: prefs.default_filename;
|
||||
QFileInfo fi(filename);
|
||||
filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml");
|
||||
QString restorePath = QFileDialog::getOpenFileName(this, tr("Restore Dive Computer Settings"),
|
||||
filename, tr("Backup files (*.xml)")
|
||||
);
|
||||
if (!restorePath.isEmpty()) {
|
||||
QString errorText = "";
|
||||
if (!config->restoreXMLBackup(restorePath, deviceDetails, errorText)) {
|
||||
QMessageBox::critical(this, tr("XML Restore Error"),
|
||||
tr("An error occurred while restoring the backup file.\n%1")
|
||||
.arg(errorText)
|
||||
);
|
||||
} else {
|
||||
reloadValues();
|
||||
//getDeviceData();
|
||||
//config->saveDeviceDetails(deviceDetails, &device_data);
|
||||
QMessageBox::information(this, tr("Restore succeeded"),
|
||||
tr("Your settings have been restored successfully.")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue