--- a/WebBrowser/WebBrowserWindow.py Fri Jun 30 19:58:09 2017 +0200 +++ b/WebBrowser/WebBrowserWindow.py Sat Jul 01 19:14:01 2017 +0200 @@ -113,22 +113,35 @@ def __init__(self, home, path, parent, name, fromEric=False, initShortcutsOnly=False, searchWord=None, - private=False, qthelp=False, settingsDir=""): + private=False, qthelp=False, settingsDir="", + restoreSession=False): """ Constructor - @param home the URL to be shown (string) - @param path the path of the working dir (usually '.') (string) - @param parent parent widget of this window (QWidget) - @param name name of this window (string) + @param home the URL to be shown + @type str + @param path the path of the working dir (usually '.') + @type str + @param parent parent widget of this window + @type QWidget + @param name name of this window + @type str @param fromEric flag indicating whether it was called from within - eric6 (boolean) + eric6 + @type bool @keyparam initShortcutsOnly flag indicating to just initialize the - keyboard shortcuts (boolean) - @keyparam searchWord word to search for (string) - @keyparam private flag indicating a private browsing window (bool) - @keyparam qthelp flag indicating to enable the QtHelp support (bool) - @keyparam settingsDir directory to be used for the settings files (str) + keyboard shortcuts + @type bool + @keyparam searchWord word to search for + @type str + @keyparam private flag indicating a private browsing window + @type bool + @keyparam qthelp flag indicating to enable the QtHelp support + @type bool + @keyparam settingsDir directory to be used for the settings files + @type str + @keyparam restoreSession flag indicating a restore session action + @type bool """ self.__hideNavigationTimer = None @@ -340,8 +353,9 @@ syncMgr.syncMessage.connect(self.statusBar().showMessage) syncMgr.syncError.connect(self.statusBar().showMessage) - self.__tabWidget.newBrowser(home) - self.__tabWidget.currentBrowser().setFocus() + if not restoreSession: + self.__tabWidget.newBrowser(home) + self.__tabWidget.currentBrowser().setFocus() self.__imagesIcon = ImagesIcon(self) self.statusBar().addPermanentWidget(self.__imagesIcon) @@ -428,6 +442,7 @@ self.__hideNavigationTimer.setSingleShot(True) self.__hideNavigationTimer.timeout.connect(self.__hideNavigation) + self.__forcedClose = False self.sessionManager() QTimer.singleShot(0, syncMgr.loadSettings) @@ -1835,6 +1850,21 @@ self.showTabManagerAct.triggered.connect(self.__showTabManager) self.__actions.append(self.showTabManagerAct) + self.showSessionsManagerAct = E5Action( + self.tr('Session Manager'), + self.tr('Session Manager...'), + 0, 0, self, 'webbrowser_show_session_manager') + self.showSessionsManagerAct.setStatusTip(self.tr( + 'Shows the session manager window')) + self.showSessionsManagerAct.setWhatsThis(self.tr( + """<b>Session Manager</b>""" + """<p>Shows the session manager window.</p>""" + )) + if not self.__initShortcutsOnly: + self.showSessionsManagerAct.triggered.connect( + self.__showSessionManagerDialog) + self.__actions.append(self.showSessionsManagerAct) + self.virustotalScanCurrentAct = E5Action( self.tr("Scan current site"), UI.PixmapCache.getIcon("virustotal.png"), @@ -1902,6 +1932,12 @@ menu.addAction(self.openAct) menu.addAction(self.openTabAct) menu.addSeparator() + if not self.isPrivate(): + sessionsMenu = menu.addMenu(self.tr("Sessions")) + sessionsMenu.aboutToShow.connect( + self.sessionManager().aboutToShowSessionsMenu) + menu.addAction(self.showSessionsManagerAct) + menu.addSeparator() if self.saveAsAct is not None: menu.addAction(self.saveAsAct) menu.addAction(self.savePageScreenAct) @@ -2081,6 +2117,13 @@ self.__superMenu.addAction(self.openTabAct) self.__superMenu.addSeparator() + if not self.isPrivate(): + sessionsMenu = self.__superMenu.addMenu(self.tr("Sessions")) + sessionsMenu.aboutToShow.connect( + self.sessionManager().aboutToShowSessionsMenu) + self.__superMenu.addAction(self.showSessionsManagerAct) + self.__superMenu.addSeparator() + menu = self.__superMenu.addMenu(self.tr("Save")) if self.saveAsAct: menu.addAction(self.saveAsAct) @@ -2378,12 +2421,14 @@ return self.__tabWidget.newBrowser(link, background=background) @pyqtSlot() - def newWindow(self, link=None): + def newWindow(self, link=None, restoreSession=False): """ Public slot called to open a new web browser window. @param link URL to be displayed in the new window @type str or QUrl + @param restoreSession flag indicating a restore session action + @type bool @return reference to the new window @rtype WebBrowserWindow """ @@ -2394,7 +2439,8 @@ else: linkName = link h = WebBrowserWindow(linkName, ".", self.parent(), "webbrowser", - self.__fromEric, private=self.isPrivate()) + self.__fromEric, private=self.isPrivate(), + restoreSession=restoreSession) h.show() self.webBrowserWindowOpened.emit(h) @@ -2688,6 +2734,13 @@ """ self.__searchWidget.showFind() + def forceClose(self): + """ + Public method to force closing the window. + """ + self.__forcedClose = True + self.close() + def closeEvent(self, e): """ Protected event handler for the close event. @@ -2710,7 +2763,7 @@ @return flag indicating successful shutdown (boolean) """ - if not WebBrowserWindow._performingShutdown: + if not WebBrowserWindow._performingShutdown and not self.__forcedClose: if not self.__tabWidget.shallShutDown(): return False @@ -4723,3 +4776,9 @@ cls._sessionManager = SessionManager() return cls._sessionManager + + def __showSessionManagerDialog(self): + """ + Private slot to show the session manager dialog. + """ + self.sessionManager().showSessionManagerDialog()