20 from PyQt6.QtWidgets import ( |
20 from PyQt6.QtWidgets import ( |
21 QApplication, QInputDialog, QLineEdit, QDialog, QDialogButtonBox, QLabel, |
21 QApplication, QInputDialog, QLineEdit, QDialog, QDialogButtonBox, QLabel, |
22 QComboBox, QVBoxLayout |
22 QComboBox, QVBoxLayout |
23 ) |
23 ) |
24 |
24 |
25 from E5Gui import E5MessageBox |
25 from E5Gui import EricMessageBox |
26 from E5Gui.E5OverrideCursor import E5OverrideCursor |
26 from E5Gui.EricOverrideCursor import EricOverrideCursor |
27 |
27 |
28 import Utilities |
28 import Utilities |
29 import Preferences |
29 import Preferences |
30 |
30 |
31 |
31 |
441 """ |
441 """ |
442 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
442 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
443 if window is None: |
443 if window is None: |
444 window = WebBrowserWindow.mainWindow() |
444 window = WebBrowserWindow.mainWindow() |
445 |
445 |
446 with E5OverrideCursor(): |
446 with EricOverrideCursor(): |
447 # restore session for first window |
447 # restore session for first window |
448 data = sessionData["Windows"].pop(0) |
448 data = sessionData["Windows"].pop(0) |
449 window.tabWidget().loadFromSessionData(data) |
449 window.tabWidget().loadFromSessionData(data) |
450 if "WindowGeometry" in data: |
450 if "WindowGeometry" in data: |
451 geometry = QByteArray.fromBase64( |
451 geometry = QByteArray.fromBase64( |
505 if not newName.endswith(".json"): |
505 if not newName.endswith(".json"): |
506 newName += ".json" |
506 newName += ".json" |
507 |
507 |
508 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
508 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
509 if os.path.exists(newSessionPath): |
509 if os.path.exists(newSessionPath): |
510 E5MessageBox.information( |
510 EricMessageBox.information( |
511 WebBrowserWindow.getWindow(), |
511 WebBrowserWindow.getWindow(), |
512 title, |
512 title, |
513 self.tr("""The session file "{0}" exists already. Please""" |
513 self.tr("""The session file "{0}" exists already. Please""" |
514 """ enter another name.""").format(newName)) |
514 """ enter another name.""").format(newName)) |
515 self.renameSession(sessionFilePath, flags) |
515 self.renameSession(sessionFilePath, flags) |
516 return |
516 return |
517 |
517 |
518 if flags & SessionManager.CloneSession: |
518 if flags & SessionManager.CloneSession: |
519 if not QFile.copy(sessionFilePath, newSessionPath): |
519 if not QFile.copy(sessionFilePath, newSessionPath): |
520 E5MessageBox.critical( |
520 EricMessageBox.critical( |
521 WebBrowserWindow.getWindow(), |
521 WebBrowserWindow.getWindow(), |
522 title, |
522 title, |
523 self.tr("""An error occurred while cloning the session""" |
523 self.tr("""An error occurred while cloning the session""" |
524 """ file.""")) |
524 """ file.""")) |
525 return |
525 return |
526 else: |
526 else: |
527 if not QFile.rename(sessionFilePath, newSessionPath): |
527 if not QFile.rename(sessionFilePath, newSessionPath): |
528 E5MessageBox.critical( |
528 EricMessageBox.critical( |
529 WebBrowserWindow.getWindow(), |
529 WebBrowserWindow.getWindow(), |
530 title, |
530 title, |
531 self.tr("""An error occurred while renaming the session""" |
531 self.tr("""An error occurred while renaming the session""" |
532 """ file.""")) |
532 """ file.""")) |
533 return |
533 return |
554 if not newName.endswith(".json"): |
554 if not newName.endswith(".json"): |
555 newName += ".json" |
555 newName += ".json" |
556 |
556 |
557 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
557 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
558 if os.path.exists(newSessionPath): |
558 if os.path.exists(newSessionPath): |
559 E5MessageBox.information( |
559 EricMessageBox.information( |
560 WebBrowserWindow.getWindow(), |
560 WebBrowserWindow.getWindow(), |
561 self.tr("Save Session"), |
561 self.tr("Save Session"), |
562 self.tr("""The session file "{0}" exists already. Please""" |
562 self.tr("""The session file "{0}" exists already. Please""" |
563 """ enter another name.""").format(newName)) |
563 """ enter another name.""").format(newName)) |
564 self.saveSession() |
564 self.saveSession() |
574 @type str |
574 @type str |
575 @return flag indicating success |
575 @return flag indicating success |
576 @rtype bool |
576 @rtype bool |
577 """ |
577 """ |
578 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
578 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
579 res = E5MessageBox.yesNo( |
579 res = EricMessageBox.yesNo( |
580 WebBrowserWindow.getWindow(), |
580 WebBrowserWindow.getWindow(), |
581 self.tr("Restore Backup"), |
581 self.tr("Restore Backup"), |
582 self.tr("""Are you sure you want to replace the current""" |
582 self.tr("""Are you sure you want to replace the current""" |
583 """ session?""")) |
583 """ session?""")) |
584 if res: |
584 if res: |
614 |
614 |
615 @param sessionFilePath file name of the session file to be deleted |
615 @param sessionFilePath file name of the session file to be deleted |
616 @type str |
616 @type str |
617 """ |
617 """ |
618 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
618 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
619 res = E5MessageBox.yesNo( |
619 res = EricMessageBox.yesNo( |
620 WebBrowserWindow.getWindow(), |
620 WebBrowserWindow.getWindow(), |
621 self.tr("Delete Session"), |
621 self.tr("Delete Session"), |
622 self.tr("""Are you sure you want to delete session "{0}"?""") |
622 self.tr("""Are you sure you want to delete session "{0}"?""") |
623 .format(QFileInfo(sessionFilePath).baseName())) |
623 .format(QFileInfo(sessionFilePath).baseName())) |
624 if res: |
624 if res: |
643 if not newName.endswith(".json"): |
643 if not newName.endswith(".json"): |
644 newName += ".json" |
644 newName += ".json" |
645 |
645 |
646 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
646 newSessionPath = os.path.join(self.getSessionsDirectory(), newName) |
647 if os.path.exists(newSessionPath): |
647 if os.path.exists(newSessionPath): |
648 E5MessageBox.information( |
648 EricMessageBox.information( |
649 WebBrowserWindow.getWindow(), |
649 WebBrowserWindow.getWindow(), |
650 self.tr("New Session"), |
650 self.tr("New Session"), |
651 self.tr("""The session file "{0}" exists already. Please""" |
651 self.tr("""The session file "{0}" exists already. Please""" |
652 """ enter another name.""").format(newName)) |
652 """ enter another name.""").format(newName)) |
653 self.newSession() |
653 self.newSession() |