111 |
111 |
112 _performingShutdown = False |
112 _performingShutdown = False |
113 |
113 |
114 def __init__(self, home, path, parent, name, fromEric=False, |
114 def __init__(self, home, path, parent, name, fromEric=False, |
115 initShortcutsOnly=False, searchWord=None, |
115 initShortcutsOnly=False, searchWord=None, |
116 private=False, qthelp=False, settingsDir=""): |
116 private=False, qthelp=False, settingsDir="", |
|
117 restoreSession=False): |
117 """ |
118 """ |
118 Constructor |
119 Constructor |
119 |
120 |
120 @param home the URL to be shown (string) |
121 @param home the URL to be shown |
121 @param path the path of the working dir (usually '.') (string) |
122 @type str |
122 @param parent parent widget of this window (QWidget) |
123 @param path the path of the working dir (usually '.') |
123 @param name name of this window (string) |
124 @type str |
|
125 @param parent parent widget of this window |
|
126 @type QWidget |
|
127 @param name name of this window |
|
128 @type str |
124 @param fromEric flag indicating whether it was called from within |
129 @param fromEric flag indicating whether it was called from within |
125 eric6 (boolean) |
130 eric6 |
|
131 @type bool |
126 @keyparam initShortcutsOnly flag indicating to just initialize the |
132 @keyparam initShortcutsOnly flag indicating to just initialize the |
127 keyboard shortcuts (boolean) |
133 keyboard shortcuts |
128 @keyparam searchWord word to search for (string) |
134 @type bool |
129 @keyparam private flag indicating a private browsing window (bool) |
135 @keyparam searchWord word to search for |
130 @keyparam qthelp flag indicating to enable the QtHelp support (bool) |
136 @type str |
131 @keyparam settingsDir directory to be used for the settings files (str) |
137 @keyparam private flag indicating a private browsing window |
|
138 @type bool |
|
139 @keyparam qthelp flag indicating to enable the QtHelp support |
|
140 @type bool |
|
141 @keyparam settingsDir directory to be used for the settings files |
|
142 @type str |
|
143 @keyparam restoreSession flag indicating a restore session action |
|
144 @type bool |
132 """ |
145 """ |
133 self.__hideNavigationTimer = None |
146 self.__hideNavigationTimer = None |
134 |
147 |
135 super(WebBrowserWindow, self).__init__(parent) |
148 super(WebBrowserWindow, self).__init__(parent) |
136 self.setObjectName(name) |
149 self.setObjectName(name) |
338 |
351 |
339 syncMgr = self.syncManager() |
352 syncMgr = self.syncManager() |
340 syncMgr.syncMessage.connect(self.statusBar().showMessage) |
353 syncMgr.syncMessage.connect(self.statusBar().showMessage) |
341 syncMgr.syncError.connect(self.statusBar().showMessage) |
354 syncMgr.syncError.connect(self.statusBar().showMessage) |
342 |
355 |
343 self.__tabWidget.newBrowser(home) |
356 if not restoreSession: |
344 self.__tabWidget.currentBrowser().setFocus() |
357 self.__tabWidget.newBrowser(home) |
|
358 self.__tabWidget.currentBrowser().setFocus() |
345 |
359 |
346 self.__imagesIcon = ImagesIcon(self) |
360 self.__imagesIcon = ImagesIcon(self) |
347 self.statusBar().addPermanentWidget(self.__imagesIcon) |
361 self.statusBar().addPermanentWidget(self.__imagesIcon) |
348 self.__javaScriptIcon = JavaScriptIcon(self) |
362 self.__javaScriptIcon = JavaScriptIcon(self) |
349 self.statusBar().addPermanentWidget(self.__javaScriptIcon) |
363 self.statusBar().addPermanentWidget(self.__javaScriptIcon) |
426 self.__hideNavigationTimer = QTimer(self) |
440 self.__hideNavigationTimer = QTimer(self) |
427 self.__hideNavigationTimer.setInterval(1000) |
441 self.__hideNavigationTimer.setInterval(1000) |
428 self.__hideNavigationTimer.setSingleShot(True) |
442 self.__hideNavigationTimer.setSingleShot(True) |
429 self.__hideNavigationTimer.timeout.connect(self.__hideNavigation) |
443 self.__hideNavigationTimer.timeout.connect(self.__hideNavigation) |
430 |
444 |
|
445 self.__forcedClose = False |
431 self.sessionManager() |
446 self.sessionManager() |
432 |
447 |
433 QTimer.singleShot(0, syncMgr.loadSettings) |
448 QTimer.singleShot(0, syncMgr.loadSettings) |
434 |
449 |
435 def __del__(self): |
450 def __del__(self): |
1833 )) |
1848 )) |
1834 if not self.__initShortcutsOnly: |
1849 if not self.__initShortcutsOnly: |
1835 self.showTabManagerAct.triggered.connect(self.__showTabManager) |
1850 self.showTabManagerAct.triggered.connect(self.__showTabManager) |
1836 self.__actions.append(self.showTabManagerAct) |
1851 self.__actions.append(self.showTabManagerAct) |
1837 |
1852 |
|
1853 self.showSessionsManagerAct = E5Action( |
|
1854 self.tr('Session Manager'), |
|
1855 self.tr('Session Manager...'), |
|
1856 0, 0, self, 'webbrowser_show_session_manager') |
|
1857 self.showSessionsManagerAct.setStatusTip(self.tr( |
|
1858 'Shows the session manager window')) |
|
1859 self.showSessionsManagerAct.setWhatsThis(self.tr( |
|
1860 """<b>Session Manager</b>""" |
|
1861 """<p>Shows the session manager window.</p>""" |
|
1862 )) |
|
1863 if not self.__initShortcutsOnly: |
|
1864 self.showSessionsManagerAct.triggered.connect( |
|
1865 self.__showSessionManagerDialog) |
|
1866 self.__actions.append(self.showSessionsManagerAct) |
|
1867 |
1838 self.virustotalScanCurrentAct = E5Action( |
1868 self.virustotalScanCurrentAct = E5Action( |
1839 self.tr("Scan current site"), |
1869 self.tr("Scan current site"), |
1840 UI.PixmapCache.getIcon("virustotal.png"), |
1870 UI.PixmapCache.getIcon("virustotal.png"), |
1841 self.tr("Scan current site"), |
1871 self.tr("Scan current site"), |
1842 0, 0, |
1872 0, 0, |
1900 menu.addAction(self.newAct) |
1930 menu.addAction(self.newAct) |
1901 menu.addAction(self.newPrivateAct) |
1931 menu.addAction(self.newPrivateAct) |
1902 menu.addAction(self.openAct) |
1932 menu.addAction(self.openAct) |
1903 menu.addAction(self.openTabAct) |
1933 menu.addAction(self.openTabAct) |
1904 menu.addSeparator() |
1934 menu.addSeparator() |
|
1935 if not self.isPrivate(): |
|
1936 sessionsMenu = menu.addMenu(self.tr("Sessions")) |
|
1937 sessionsMenu.aboutToShow.connect( |
|
1938 self.sessionManager().aboutToShowSessionsMenu) |
|
1939 menu.addAction(self.showSessionsManagerAct) |
|
1940 menu.addSeparator() |
1905 if self.saveAsAct is not None: |
1941 if self.saveAsAct is not None: |
1906 menu.addAction(self.saveAsAct) |
1942 menu.addAction(self.saveAsAct) |
1907 menu.addAction(self.savePageScreenAct) |
1943 menu.addAction(self.savePageScreenAct) |
1908 menu.addAction(self.saveVisiblePageScreenAct) |
1944 menu.addAction(self.saveVisiblePageScreenAct) |
1909 menu.addSeparator() |
1945 menu.addSeparator() |
2078 self.__superMenu.addAction(self.newAct) |
2114 self.__superMenu.addAction(self.newAct) |
2079 self.__superMenu.addAction(self.newPrivateAct) |
2115 self.__superMenu.addAction(self.newPrivateAct) |
2080 self.__superMenu.addAction(self.openAct) |
2116 self.__superMenu.addAction(self.openAct) |
2081 self.__superMenu.addAction(self.openTabAct) |
2117 self.__superMenu.addAction(self.openTabAct) |
2082 self.__superMenu.addSeparator() |
2118 self.__superMenu.addSeparator() |
|
2119 |
|
2120 if not self.isPrivate(): |
|
2121 sessionsMenu = self.__superMenu.addMenu(self.tr("Sessions")) |
|
2122 sessionsMenu.aboutToShow.connect( |
|
2123 self.sessionManager().aboutToShowSessionsMenu) |
|
2124 self.__superMenu.addAction(self.showSessionsManagerAct) |
|
2125 self.__superMenu.addSeparator() |
2083 |
2126 |
2084 menu = self.__superMenu.addMenu(self.tr("Save")) |
2127 menu = self.__superMenu.addMenu(self.tr("Save")) |
2085 if self.saveAsAct: |
2128 if self.saveAsAct: |
2086 menu.addAction(self.saveAsAct) |
2129 menu.addAction(self.saveAsAct) |
2087 menu.addAction(self.savePageScreenAct) |
2130 menu.addAction(self.savePageScreenAct) |
2376 addNextTo, link, background=background) |
2419 addNextTo, link, background=background) |
2377 else: |
2420 else: |
2378 return self.__tabWidget.newBrowser(link, background=background) |
2421 return self.__tabWidget.newBrowser(link, background=background) |
2379 |
2422 |
2380 @pyqtSlot() |
2423 @pyqtSlot() |
2381 def newWindow(self, link=None): |
2424 def newWindow(self, link=None, restoreSession=False): |
2382 """ |
2425 """ |
2383 Public slot called to open a new web browser window. |
2426 Public slot called to open a new web browser window. |
2384 |
2427 |
2385 @param link URL to be displayed in the new window |
2428 @param link URL to be displayed in the new window |
2386 @type str or QUrl |
2429 @type str or QUrl |
|
2430 @param restoreSession flag indicating a restore session action |
|
2431 @type bool |
2387 @return reference to the new window |
2432 @return reference to the new window |
2388 @rtype WebBrowserWindow |
2433 @rtype WebBrowserWindow |
2389 """ |
2434 """ |
2390 if link is None: |
2435 if link is None: |
2391 linkName = "" |
2436 linkName = "" |
2392 elif isinstance(link, QUrl): |
2437 elif isinstance(link, QUrl): |
2393 linkName = link.toString() |
2438 linkName = link.toString() |
2394 else: |
2439 else: |
2395 linkName = link |
2440 linkName = link |
2396 h = WebBrowserWindow(linkName, ".", self.parent(), "webbrowser", |
2441 h = WebBrowserWindow(linkName, ".", self.parent(), "webbrowser", |
2397 self.__fromEric, private=self.isPrivate()) |
2442 self.__fromEric, private=self.isPrivate(), |
|
2443 restoreSession=restoreSession) |
2398 h.show() |
2444 h.show() |
2399 |
2445 |
2400 self.webBrowserWindowOpened.emit(h) |
2446 self.webBrowserWindowOpened.emit(h) |
2401 |
2447 |
2402 return h |
2448 return h |
2686 It opens the search dialog in order to perform the various |
2732 It opens the search dialog in order to perform the various |
2687 search actions and to collect the various search info. |
2733 search actions and to collect the various search info. |
2688 """ |
2734 """ |
2689 self.__searchWidget.showFind() |
2735 self.__searchWidget.showFind() |
2690 |
2736 |
|
2737 def forceClose(self): |
|
2738 """ |
|
2739 Public method to force closing the window. |
|
2740 """ |
|
2741 self.__forcedClose = True |
|
2742 self.close() |
|
2743 |
2691 def closeEvent(self, e): |
2744 def closeEvent(self, e): |
2692 """ |
2745 """ |
2693 Protected event handler for the close event. |
2746 Protected event handler for the close event. |
2694 |
2747 |
2695 @param e the close event (QCloseEvent) |
2748 @param e the close event (QCloseEvent) |
2708 """ |
2761 """ |
2709 Private method to shut down a web browser window. |
2762 Private method to shut down a web browser window. |
2710 |
2763 |
2711 @return flag indicating successful shutdown (boolean) |
2764 @return flag indicating successful shutdown (boolean) |
2712 """ |
2765 """ |
2713 if not WebBrowserWindow._performingShutdown: |
2766 if not WebBrowserWindow._performingShutdown and not self.__forcedClose: |
2714 if not self.__tabWidget.shallShutDown(): |
2767 if not self.__tabWidget.shallShutDown(): |
2715 return False |
2768 return False |
2716 |
2769 |
2717 self.__bookmarksToolBar.setModel(None) |
2770 self.__bookmarksToolBar.setModel(None) |
2718 |
2771 |
4721 if cls._sessionManager is None and not cls._isPrivate: |
4774 if cls._sessionManager is None and not cls._isPrivate: |
4722 from .Session.SessionManager import SessionManager |
4775 from .Session.SessionManager import SessionManager |
4723 cls._sessionManager = SessionManager() |
4776 cls._sessionManager = SessionManager() |
4724 |
4777 |
4725 return cls._sessionManager |
4778 return cls._sessionManager |
|
4779 |
|
4780 def __showSessionManagerDialog(self): |
|
4781 """ |
|
4782 Private slot to show the session manager dialog. |
|
4783 """ |
|
4784 self.sessionManager().showSessionManagerDialog() |