12 from PyQt6.QtCore import ( |
12 from PyQt6.QtCore import ( |
13 pyqtSignal, pyqtSlot, QFileInfo, QDateTime, QDate, QTime, QUrl, QTimer, |
13 pyqtSignal, pyqtSlot, QFileInfo, QDateTime, QDate, QTime, QUrl, QTimer, |
14 QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile, QObject |
14 QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile, QObject |
15 ) |
15 ) |
16 |
16 |
17 from E5Gui import E5MessageBox |
17 from E5Gui import EricMessageBox |
18 |
18 |
19 from Utilities.AutoSaver import AutoSaver |
19 from Utilities.AutoSaver import AutoSaver |
20 import Utilities |
20 import Utilities |
21 import Preferences |
21 import Preferences |
22 |
22 |
447 """ |
447 """ |
448 historyFile = QFile(self.getFileName()) |
448 historyFile = QFile(self.getFileName()) |
449 if not historyFile.exists(): |
449 if not historyFile.exists(): |
450 return |
450 return |
451 if not historyFile.open(QIODevice.OpenModeFlag.ReadOnly): |
451 if not historyFile.open(QIODevice.OpenModeFlag.ReadOnly): |
452 E5MessageBox.warning( |
452 EricMessageBox.warning( |
453 None, |
453 None, |
454 self.tr("Loading History"), |
454 self.tr("Loading History"), |
455 self.tr( |
455 self.tr( |
456 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
456 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
457 """Reason: {1}</p>""") |
457 """Reason: {1}</p>""") |
538 else: |
538 else: |
539 f = historyFile |
539 f = historyFile |
540 opened = f.open(QIODevice.OpenModeFlag.Append) |
540 opened = f.open(QIODevice.OpenModeFlag.Append) |
541 |
541 |
542 if not opened: |
542 if not opened: |
543 E5MessageBox.warning( |
543 EricMessageBox.warning( |
544 None, |
544 None, |
545 self.tr("Saving History"), |
545 self.tr("Saving History"), |
546 self.tr( |
546 self.tr( |
547 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
547 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
548 """Reason: {1}</p>""") |
548 """Reason: {1}</p>""") |
562 f.write(data) |
562 f.write(data) |
563 |
563 |
564 f.close() |
564 f.close() |
565 if saveAll: |
565 if saveAll: |
566 if historyFile.exists() and not historyFile.remove(): |
566 if historyFile.exists() and not historyFile.remove(): |
567 E5MessageBox.warning( |
567 EricMessageBox.warning( |
568 None, |
568 None, |
569 self.tr("Saving History"), |
569 self.tr("Saving History"), |
570 self.tr( |
570 self.tr( |
571 """<p>Error removing old history file <b>{0}</b>.""" |
571 """<p>Error removing old history file <b>{0}</b>.""" |
572 """<br/>Reason: {1}</p>""") |
572 """<br/>Reason: {1}</p>""") |
573 .format(historyFile.fileName(), |
573 .format(historyFile.fileName(), |
574 historyFile.errorString())) |
574 historyFile.errorString())) |
575 if not f.copy(historyFile.fileName()): |
575 if not f.copy(historyFile.fileName()): |
576 E5MessageBox.warning( |
576 EricMessageBox.warning( |
577 None, |
577 None, |
578 self.tr("Saving History"), |
578 self.tr("Saving History"), |
579 self.tr( |
579 self.tr( |
580 """<p>Error moving new history file over old one """ |
580 """<p>Error moving new history file over old one """ |
581 """(<b>{0}</b>).<br/>Reason: {1}</p>""") |
581 """(<b>{0}</b>).<br/>Reason: {1}</p>""") |