57 |
57 |
58 from .Tools import Scripts, WebBrowserTools, WebIconProvider |
58 from .Tools import Scripts, WebBrowserTools, WebIconProvider |
59 |
59 |
60 from .ZoomManager import ZoomManager |
60 from .ZoomManager import ZoomManager |
61 |
61 |
|
62 from .WebBrowserSingleApplication import WebBrowserSingleApplicationServer |
|
63 |
62 from eric6config import getConfig |
64 from eric6config import getConfig |
63 |
65 |
64 |
66 |
65 class WebBrowserWindow(E5MainWindow): |
67 class WebBrowserWindow(E5MainWindow): |
66 """ |
68 """ |
115 _lastActiveWindow = None |
117 _lastActiveWindow = None |
116 |
118 |
117 def __init__(self, home, path, parent, name, fromEric=False, |
119 def __init__(self, home, path, parent, name, fromEric=False, |
118 initShortcutsOnly=False, searchWord=None, |
120 initShortcutsOnly=False, searchWord=None, |
119 private=False, qthelp=False, settingsDir="", |
121 private=False, qthelp=False, settingsDir="", |
120 restoreSession=False): |
122 restoreSession=False, single=False): |
121 """ |
123 """ |
122 Constructor |
124 Constructor |
123 |
125 |
124 @param home the URL to be shown |
126 @param home the URL to be shown |
125 @type str |
127 @type str |
142 @keyparam qthelp flag indicating to enable the QtHelp support |
144 @keyparam qthelp flag indicating to enable the QtHelp support |
143 @type bool |
145 @type bool |
144 @keyparam settingsDir directory to be used for the settings files |
146 @keyparam settingsDir directory to be used for the settings files |
145 @type str |
147 @type str |
146 @keyparam restoreSession flag indicating a restore session action |
148 @keyparam restoreSession flag indicating a restore session action |
|
149 @type bool |
|
150 @param single flag indicating to start in single application mode |
147 @type bool |
151 @type bool |
148 """ |
152 """ |
149 self.__hideNavigationTimer = None |
153 self.__hideNavigationTimer = None |
150 |
154 |
151 super(WebBrowserWindow, self).__init__(parent) |
155 super(WebBrowserWindow, self).__init__(parent) |
355 syncMgr = self.syncManager() |
359 syncMgr = self.syncManager() |
356 syncMgr.syncMessage.connect(self.statusBar().showMessage) |
360 syncMgr.syncMessage.connect(self.statusBar().showMessage) |
357 syncMgr.syncError.connect(self.statusBar().showMessage) |
361 syncMgr.syncError.connect(self.statusBar().showMessage) |
358 |
362 |
359 restoreSessionData = {} |
363 restoreSessionData = {} |
360 if WebBrowserWindow._performingStartup and not home: |
364 if WebBrowserWindow._performingStartup and not home and \ |
|
365 not WebBrowserWindow.isPrivate(): |
361 startupBehavior = Preferences.getWebBrowser("StartupBehavior") |
366 startupBehavior = Preferences.getWebBrowser("StartupBehavior") |
362 if not private and startupBehavior in [3, 4]: |
367 if not private and startupBehavior in [3, 4]: |
363 if startupBehavior == 3: |
368 if startupBehavior == 3: |
364 # restore last session |
369 # restore last session |
365 restoreSessionFile = \ |
370 restoreSessionFile = \ |
381 home = Preferences.getWebBrowser("HomePage") |
386 home = Preferences.getWebBrowser("HomePage") |
382 elif Preferences.getWebBrowser("StartupBehavior") == 2: |
387 elif Preferences.getWebBrowser("StartupBehavior") == 2: |
383 home = "eric:speeddial" |
388 home = "eric:speeddial" |
384 |
389 |
385 if not restoreSession: |
390 if not restoreSession: |
386 self.__tabWidget.newBrowser(home) |
391 self.__tabWidget.newBrowser(QUrl.fromUserInput(home)) |
387 self.__tabWidget.currentBrowser().setFocus() |
392 self.__tabWidget.currentBrowser().setFocus() |
388 WebBrowserWindow._performingStartup = False |
393 WebBrowserWindow._performingStartup = False |
389 |
394 |
390 self.__imagesIcon = ImagesIcon(self) |
395 self.__imagesIcon = ImagesIcon(self) |
391 self.statusBar().addPermanentWidget(self.__imagesIcon) |
396 self.statusBar().addPermanentWidget(self.__imagesIcon) |
463 |
468 |
464 e5App().focusChanged.connect(self.__appFocusChanged) |
469 e5App().focusChanged.connect(self.__appFocusChanged) |
465 |
470 |
466 self.__toolbarStates = self.saveState() |
471 self.__toolbarStates = self.saveState() |
467 |
472 |
|
473 if single: |
|
474 self.SAServer = WebBrowserSingleApplicationServer() |
|
475 self.SAServer.loadUrl.connect(self.__saLoadUrl) |
|
476 self.SAServer.search.connect(self.__saSearchWord) |
|
477 else: |
|
478 self.SAServer = None |
|
479 |
468 self.__hideNavigationTimer = QTimer(self) |
480 self.__hideNavigationTimer = QTimer(self) |
469 self.__hideNavigationTimer.setInterval(1000) |
481 self.__hideNavigationTimer.setInterval(1000) |
470 self.__hideNavigationTimer.setSingleShot(True) |
482 self.__hideNavigationTimer.setSingleShot(True) |
471 self.__hideNavigationTimer.timeout.connect(self.__hideNavigation) |
483 self.__hideNavigationTimer.timeout.connect(self.__hideNavigation) |
472 |
484 |
473 self.__forcedClose = False |
485 self.__forcedClose = False |
474 |
486 |
475 if restoreSessionData: |
487 if restoreSessionData and not WebBrowserWindow.isPrivate(): |
476 self.sessionManager().restoreSessionFromData( |
488 self.sessionManager().restoreSessionFromData( |
477 self, restoreSessionData) |
489 self, restoreSessionData) |
478 |
490 |
479 self.sessionManager().activateTimer() |
491 if not WebBrowserWindow.isPrivate(): |
|
492 self.sessionManager().activateTimer() |
480 |
493 |
481 QTimer.singleShot(0, syncMgr.loadSettings) |
494 QTimer.singleShot(0, syncMgr.loadSettings) |
482 |
495 |
483 if WebBrowserWindow._useQtHelp: |
496 if WebBrowserWindow._useQtHelp: |
484 QTimer.singleShot(50, self.__lookForNewDocumentation) |
497 QTimer.singleShot(50, self.__lookForNewDocumentation) |
2837 |
2850 |
2838 self.__isClosing = True |
2851 self.__isClosing = True |
2839 |
2852 |
2840 if not self.__fromEric: |
2853 if not self.__fromEric: |
2841 if not WebBrowserWindow._performingShutdown and \ |
2854 if not WebBrowserWindow._performingShutdown and \ |
2842 len(WebBrowserWindow.BrowserWindows) == 1: |
2855 len(WebBrowserWindow.BrowserWindows) == 1 and \ |
|
2856 not WebBrowserWindow.isPrivate(): |
2843 # shut down the session manager in case the last window is |
2857 # shut down the session manager in case the last window is |
2844 # about to be closed |
2858 # about to be closed |
2845 self.sessionManager().shutdown() |
2859 self.sessionManager().shutdown() |
2846 |
2860 |
2847 self.__bookmarksToolBar.setModel(None) |
2861 self.__bookmarksToolBar.setModel(None) |
2951 not self.downloadManager().allowQuit(): |
2965 not self.downloadManager().allowQuit(): |
2952 return False |
2966 return False |
2953 |
2967 |
2954 WebBrowserWindow._performingShutdown = True |
2968 WebBrowserWindow._performingShutdown = True |
2955 |
2969 |
2956 self.sessionManager().shutdown() |
2970 if not WebBrowserWindow.isPrivate(): |
|
2971 self.sessionManager().shutdown() |
2957 |
2972 |
2958 if WebBrowserWindow._downloadManager is not None: |
2973 if WebBrowserWindow._downloadManager is not None: |
2959 self.downloadManager().shutdown() |
2974 self.downloadManager().shutdown() |
2960 |
2975 |
2961 self.cookieJar().close() |
2976 self.cookieJar().close() |
3303 self.virustotalIpReportAct.setEnabled(True) |
3318 self.virustotalIpReportAct.setEnabled(True) |
3304 self.virustotalDomainReportAct.setEnabled(True) |
3319 self.virustotalDomainReportAct.setEnabled(True) |
3305 |
3320 |
3306 self.__javaScriptIcon.preferencesChanged() |
3321 self.__javaScriptIcon.preferencesChanged() |
3307 |
3322 |
3308 self.sessionManager().preferencesChanged() |
3323 if not WebBrowserWindow.isPrivate(): |
|
3324 self.sessionManager().preferencesChanged() |
3309 |
3325 |
3310 def masterPasswordChanged(self, oldPassword, newPassword, local=False): |
3326 def masterPasswordChanged(self, oldPassword, newPassword, local=False): |
3311 """ |
3327 """ |
3312 Public slot to handle the change of the master password. |
3328 Public slot to handle the change of the master password. |
3313 |
3329 |
4990 def __showSafeBrowsingDialog(self): |
5006 def __showSafeBrowsingDialog(self): |
4991 """ |
5007 """ |
4992 Private slot to show the safe browsing management dialog. |
5008 Private slot to show the safe browsing management dialog. |
4993 """ |
5009 """ |
4994 self.safeBrowsingManager().showSafeBrowsingDialog() |
5010 self.safeBrowsingManager().showSafeBrowsingDialog() |
|
5011 |
|
5012 ############################################################### |
|
5013 ## Methods below implement single application related functions |
|
5014 ############################################################### |
|
5015 |
|
5016 @pyqtSlot(str) |
|
5017 def __saLoadUrl(self, urlStr): |
|
5018 """ |
|
5019 Private slot to load an URL received via the single application |
|
5020 protocol. |
|
5021 |
|
5022 @param urlStr URL to be loaded |
|
5023 @type str |
|
5024 """ |
|
5025 url = QUrl.fromUserInput(urlStr) |
|
5026 self.__linkActivated(url) |
|
5027 |
|
5028 @pyqtSlot(str) |
|
5029 def __saSearchWord(self, word): |
|
5030 """ |
|
5031 Private slot to search for the given word. |
|
5032 |
|
5033 @param word word to be searched for |
|
5034 @type str |
|
5035 """ |
|
5036 if WebBrowserWindow._useQtHelp: |
|
5037 self.__searchWord = word |
|
5038 self.__searchForWord() |