8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import json |
11 import json |
12 import functools |
12 import functools |
|
13 import contextlib |
13 |
14 |
14 from PyQt5.QtCore import ( |
15 from PyQt5.QtCore import ( |
15 pyqtSlot, pyqtSignal, Qt, QObject, QTimer, QDir, QFile, QFileInfo, |
16 pyqtSlot, pyqtSignal, Qt, QObject, QTimer, QDir, QFile, QFileInfo, |
16 QFileSystemWatcher, QByteArray, QDateTime |
17 QFileSystemWatcher, QByteArray, QDateTime |
17 ) |
18 ) |
464 window.restoreGeometry(geometry) |
465 window.restoreGeometry(geometry) |
465 QApplication.processEvents() |
466 QApplication.processEvents() |
466 |
467 |
467 if "CurrentWindowIndex" in sessionData: |
468 if "CurrentWindowIndex" in sessionData: |
468 currentWindowIndex = sessionData["CurrentWindowIndex"] |
469 currentWindowIndex = sessionData["CurrentWindowIndex"] |
469 try: |
470 with contextlib.suppress(IndexError): |
470 currentWindow = ( |
471 currentWindow = ( |
471 WebBrowserWindow.mainWindows()[currentWindowIndex] |
472 WebBrowserWindow.mainWindows()[currentWindowIndex] |
472 ) |
473 ) |
473 QTimer.singleShot(0, lambda: currentWindow.raise_()) |
474 QTimer.singleShot(0, lambda: currentWindow.raise_()) |
474 except IndexError: |
|
475 # ignore it |
|
476 pass |
|
477 |
475 |
478 def renameSession(self, sessionFilePath, flags=0): |
476 def renameSession(self, sessionFilePath, flags=0): |
479 """ |
477 """ |
480 Public method to rename or clone a session. |
478 Public method to rename or clone a session. |
481 |
479 |