mirror of https://gitlab.com/pamhyr/pamhyr2
Mainwindow: Add backup file dialog.
parent
017f26c03d
commit
a3da09cf5b
|
|
@ -864,12 +864,32 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if os.path.exists(backup):
|
||||
file_modified_date = time.ctime(os.path.getmtime(file))
|
||||
backup_modified_date = time.ctime(os.path.getmtime(backup))
|
||||
|
||||
if backup_modified_date > file_modified_date:
|
||||
logger.info(f"Select backup ({backup})")
|
||||
file = backup
|
||||
yes = self.dialog_open_backup_study()
|
||||
|
||||
if yes:
|
||||
logger.info(f"Select backup ({backup})")
|
||||
file = backup
|
||||
|
||||
return file
|
||||
|
||||
def dialog_open_backup_study(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
dlg.setWindowTitle(self._trad["mb_open_backup_title"])
|
||||
dlg.setText(self._trad["mb_open_backup_msg"])
|
||||
opt = QMessageBox.No | QMessageBox.Yes
|
||||
|
||||
dlg.setStandardButtons(opt)
|
||||
dlg.setIcon(QMessageBox.Question)
|
||||
dlg.button(QMessageBox.Yes).setText(self._trad["Yes"])
|
||||
dlg.button(QMessageBox.No).setText(self._trad["No"])
|
||||
|
||||
res = dlg.exec()
|
||||
|
||||
return res == QMessageBox.Yes
|
||||
|
||||
def dialog_close(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -200,6 +200,15 @@ class MainTranslate(UnitTranslate):
|
|||
"Do you want to open again the last open study?"
|
||||
)
|
||||
|
||||
self._dict["mb_open_backup_title"] = _translate(
|
||||
"MainWindow", "Open backup file"
|
||||
)
|
||||
self._dict["mb_open_backup_msg"] = _translate(
|
||||
"MainWindow",
|
||||
"A more recent backup file as found for this study, "
|
||||
+ "do you want to open the backup file?"
|
||||
)
|
||||
|
||||
self._dict["mb_close_title"] = _translate(
|
||||
"MainWindow", "Close without saving study"
|
||||
)
|
||||
|
|
@ -207,6 +216,7 @@ class MainTranslate(UnitTranslate):
|
|||
"MainWindow",
|
||||
"Do you want to save current study before closing it?"
|
||||
)
|
||||
|
||||
self._dict["x"] = _translate("MainWindow", "X (m)")
|
||||
self._dict["y"] = _translate("MainWindow", "Y (m)")
|
||||
self._dict["Yes"] = _translate("MainWindow", "Yes")
|
||||
|
|
|
|||
Loading…
Reference in New Issue