eric6/WebBrowser/WebBrowserTabWidget.py

Mon, 01 Feb 2021 10:38:16 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 01 Feb 2021 10:38:16 +0100
branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7923
91e843545d9a
child 8176
31965986ecd1
permissions
-rw-r--r--

Merged with default branch to prepare a new release.

638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the central widget showing the web pages.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
12 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QFile, QFileDevice
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
13 from PyQt5.QtGui import QIcon, QPixmap, QPainter
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from PyQt5.QtWidgets import (
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
15 QWidget, QHBoxLayout, QMenu, QToolButton, QDialog
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
17 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from E5Gui.E5TabWidget import E5TabWidget
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from E5Gui import E5MessageBox
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
21 from E5Gui.E5Application import e5App
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
22 from E5Gui.E5OverrideCursor import E5OverrideCursor
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
24 from .WebBrowserView import WebBrowserView
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
25 from .WebBrowserPage import WebBrowserPage
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
26 from .Tools import WebBrowserTools
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
27 from . import WebInspector
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
28
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import UI.PixmapCache
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
31 import Utilities
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import Preferences
4795
6e0a26c633b2 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4792
diff changeset
33 import Globals
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
35
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
36 def isCupsAvailable():
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
37 """
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
38 Static method to test the availability of CUPS.
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
39
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
40 @return flag indicating the availability of CUPS
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
41 @rtype bool
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
42 """
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
43 if Globals.isMacPlatform():
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
44 # OS X/MacOS always have CUPS
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
45 return True
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
46 elif Globals.isLinuxPlatform():
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
47 testPrinter = QPrinter()
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
48 return testPrinter.supportsMultipleCopies()
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
49 else:
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
50 return False
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
51
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
52
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
53 class WebBrowserTabWidget(E5TabWidget):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Class implementing the central widget showing the web pages.
1645
73904ca06d2d A few fixes for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1636
diff changeset
56
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
57 @signal sourceChanged(WebBrowserView, QUrl) emitted after the URL of a
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
58 browser has changed
4965
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
59 @signal currentUrlChanged(QUrl) emitted after the URL of the current
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
60 browser has changed
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
61 @signal titleChanged(WebBrowserView, str) emitted after the title of a
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
62 browser has changed
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
63 @signal showMessage(str) emitted to show a message in the main window
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
64 status bar
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
65 @signal browserOpened(QWidget) emitted after a new browser was created
1645
73904ca06d2d A few fixes for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1636
diff changeset
66 @signal browserClosed(QWidget) emitted after a browser was closed
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
67 @signal browserZoomValueChanged(int) emitted to signal a change of the
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
68 current browser's zoom level
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
70 sourceChanged = pyqtSignal(WebBrowserView, QUrl)
4965
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
71 currentUrlChanged = pyqtSignal(QUrl)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
72 titleChanged = pyqtSignal(WebBrowserView, str)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 showMessage = pyqtSignal(str)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
74 browserOpened = pyqtSignal(QWidget)
1196
77da430b4080 Added an action to preview the file in the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1155
diff changeset
75 browserClosed = pyqtSignal(QWidget)
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
76 browserZoomValueChanged = pyqtSignal(int)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 def __init__(self, parent):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @param parent reference to the parent widget (QWidget)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4709
diff changeset
84 super(WebBrowserTabWidget, self).__init__(parent, dnd=True)
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2334
diff changeset
85
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
86 from .WebBrowserTabBar import WebBrowserTabBar
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
87 self.__tabBar = WebBrowserTabBar(self)
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
88 self.setCustomTabBar(True, self.__tabBar)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__mainWindow = parent
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
1422
47f1dffa398e Fixed the tab bar issue observed for some styles (like Mac Aqua).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
92 self.setUsesScrollButtons(True)
47f1dffa398e Fixed the tab bar issue observed for some styles (like Mac Aqua).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
93 self.setDocumentMode(True)
47f1dffa398e Fixed the tab bar issue observed for some styles (like Mac Aqua).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
94 self.setElideMode(Qt.ElideNone)
47f1dffa398e Fixed the tab bar issue observed for some styles (like Mac Aqua).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
95
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
96 from .ClosedTabsManager import ClosedTabsManager
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
97 self.__closedTabsManager = ClosedTabsManager(self)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
98 self.__closedTabsManager.closedTabAvailable.connect(
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
99 self.__closedTabAvailable)
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
100
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2334
diff changeset
101 from .UrlBar.StackedUrlBar import StackedUrlBar
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
102 self.__stackedUrlBar = StackedUrlBar(self)
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
103 self.__tabBar.tabMoved.connect(self.__stackedUrlBar.moveBar)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
104
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.__tabContextMenuIndex = -1
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
106 self.currentChanged[int].connect(self.__currentChanged)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.setTabContextMenuPolicy(Qt.CustomContextMenu)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.customTabContextMenuRequested.connect(self.__showContextMenu)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__rightCornerWidget = QWidget(self)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__rightCornerWidgetLayout = QHBoxLayout(self.__rightCornerWidget)
2824
858412c29c34 Replaced the obsoleted method setMargin() with setContentsMargins().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
112 self.__rightCornerWidgetLayout.setContentsMargins(0, 0, 0, 0)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.__rightCornerWidgetLayout.setSpacing(0)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.__navigationMenu = QMenu(self)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__navigationMenu.aboutToShow.connect(self.__showNavigationMenu)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.__navigationMenu.triggered.connect(self.__navigationMenuTriggered)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__navigationButton = QToolButton(self)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
120 self.__navigationButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
121 UI.PixmapCache.getIcon("1downarrow"))
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
122 self.__navigationButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
123 self.tr("Show a navigation menu"))
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.__navigationButton.setPopupMode(QToolButton.InstantPopup)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.__navigationButton.setMenu(self.__navigationMenu)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__navigationButton.setEnabled(False)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__rightCornerWidgetLayout.addWidget(self.__navigationButton)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
129 self.__closedTabsMenu = QMenu(self)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
130 self.__closedTabsMenu.aboutToShow.connect(
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
131 self.__aboutToShowClosedTabsMenu)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
132
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
133 self.__closedTabsButton = QToolButton(self)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
134 self.__closedTabsButton.setIcon(UI.PixmapCache.getIcon("trash"))
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
135 self.__closedTabsButton.setToolTip(
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
136 self.tr("Show a navigation menu for closed tabs"))
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
137 self.__closedTabsButton.setPopupMode(QToolButton.InstantPopup)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
138 self.__closedTabsButton.setMenu(self.__closedTabsMenu)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
139 self.__closedTabsButton.setEnabled(False)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
140 self.__rightCornerWidgetLayout.addWidget(self.__closedTabsButton)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
141
6999
f23e546a7eb9 Web Browser, Web Browser NG, Tabview: removed the option to use only one close button instead of one per tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
142 self.setTabsClosable(True)
f23e546a7eb9 Web Browser, Web Browser NG, Tabview: removed the option to use only one close button instead of one per tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
143 self.tabCloseRequested.connect(self.closeBrowserAt)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.setCornerWidget(self.__rightCornerWidget, Qt.TopRightCorner)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.__newTabButton = QToolButton(self)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
148 self.__newTabButton.setIcon(UI.PixmapCache.getIcon("plus"))
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
149 self.__newTabButton.setToolTip(
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
150 self.tr("Open a new web browser tab"))
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.setCornerWidget(self.__newTabButton, Qt.TopLeftCorner)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
152 self.__newTabButton.clicked.connect(self.__newBrowser)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 self.__initTabContextMenu()
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
155
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
156 self.__historyCompleter = None
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 def __initTabContextMenu(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
160 Private method to create the tab context menu.
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.__tabContextMenu = QMenu(self)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
163 self.tabContextNewAct = self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
164 UI.PixmapCache.getIcon("tabNew"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
165 self.tr('New Tab'), self.newBrowser)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.__tabContextMenu.addSeparator()
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
167 self.leftMenuAct = self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
168 UI.PixmapCache.getIcon("1leftarrow"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
169 self.tr('Move Left'), self.__tabContextMenuMoveLeft)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
170 self.rightMenuAct = self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
171 UI.PixmapCache.getIcon("1rightarrow"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
172 self.tr('Move Right'), self.__tabContextMenuMoveRight)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.__tabContextMenu.addSeparator()
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
174 self.tabContextCloneAct = self.__tabContextMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
175 self.tr("Duplicate Page"), self.__tabContextMenuClone)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.__tabContextMenu.addSeparator()
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
177 self.tabContextCloseAct = self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
178 UI.PixmapCache.getIcon("tabClose"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
179 self.tr('Close'), self.__tabContextMenuClose)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
180 self.tabContextCloseOthersAct = self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
181 UI.PixmapCache.getIcon("tabCloseOther"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
182 self.tr("Close Others"), self.__tabContextMenuCloseOthers)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
183 self.__tabContextMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
184 self.tr('Close All'), self.closeAllBrowsers)
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
185 self.__tabContextMenu.addSeparator()
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
186 self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
187 UI.PixmapCache.getIcon("printPreview"),
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
188 self.tr('Print Preview'), self.__tabContextMenuPrintPreview)
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
189 self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
190 UI.PixmapCache.getIcon("print"),
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
191 self.tr('Print'), self.__tabContextMenuPrint)
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
192 self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
193 UI.PixmapCache.getIcon("printPdf"),
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
194 self.tr('Print as PDF'), self.__tabContextMenuPrintPdf)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__tabContextMenu.addSeparator()
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
196 if hasattr(WebBrowserPage, "isAudioMuted"):
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
197 self.__audioAct = self.__tabContextMenu.addAction(
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
198 "", self.__tabContextMenuAudioMute)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
199 self.__tabContextMenu.addSeparator()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
200 else:
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
201 self.__audioAct = None
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
202 self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
203 UI.PixmapCache.getIcon("reload"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
204 self.tr('Reload All'), self.reloadAllBrowsers)
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
205 self.__tabContextMenu.addSeparator()
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
206 self.__tabContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
207 UI.PixmapCache.getIcon("addBookmark"),
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
208 self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
209
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
210 self.__tabBackContextMenu = QMenu(self)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
211 self.__tabBackContextMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
212 self.tr('Close All'), self.closeAllBrowsers)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
213 self.__tabBackContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
214 UI.PixmapCache.getIcon("reload"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
215 self.tr('Reload All'), self.reloadAllBrowsers)
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
216 self.__tabBackContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
217 UI.PixmapCache.getIcon("addBookmark"),
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
218 self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
219 self.__tabBackContextMenu.addSeparator()
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
220 self.__restoreClosedTabAct = self.__tabBackContextMenu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
221 UI.PixmapCache.getIcon("trash"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
222 self.tr('Restore Closed Tab'))
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
223 self.__restoreClosedTabAct.setEnabled(False)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
224 self.__restoreClosedTabAct.setData(0)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
225 self.__restoreClosedTabAct.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
226 lambda: self.restoreClosedTab(self.__restoreClosedTabAct))
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 def __showContextMenu(self, coord, index):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 Private slot to show the tab context menu.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @param coord the position of the mouse pointer (QPoint)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @param index index of the tab the menu is requested for (integer)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 coord = self.mapToGlobal(coord)
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
236 if index == -1:
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
237 self.__tabBackContextMenu.popup(coord)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
238 else:
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
239 self.__tabContextMenuIndex = index
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
240 self.leftMenuAct.setEnabled(index > 0)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
241 self.rightMenuAct.setEnabled(index < self.count() - 1)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
242
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
243 self.tabContextCloseOthersAct.setEnabled(self.count() > 1)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
244
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
245 if self.__audioAct is not None:
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
246 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
247 self.widget(self.__tabContextMenuIndex).page()
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
248 .isAudioMuted()
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
249 ):
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
250 self.__audioAct.setText(self.tr("Unmute Tab"))
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
251 self.__audioAct.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
252 UI.PixmapCache.getIcon("audioVolumeHigh"))
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
253 else:
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
254 self.__audioAct.setText(self.tr("Mute Tab"))
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
255 self.__audioAct.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
256 UI.PixmapCache.getIcon("audioVolumeMuted"))
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
257
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
258 self.__tabContextMenu.popup(coord)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 def __tabContextMenuMoveLeft(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 Private method to move a tab one position to the left.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
264 self.moveTab(self.__tabContextMenuIndex,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
265 self.__tabContextMenuIndex - 1)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 def __tabContextMenuMoveRight(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 Private method to move a tab one position to the right.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
271 self.moveTab(self.__tabContextMenuIndex,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
272 self.__tabContextMenuIndex + 1)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 def __tabContextMenuClone(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 Private method to clone the selected tab.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 idx = self.__tabContextMenuIndex
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 if idx < 0:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 idx = self.currentIndex()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 if idx < 0 or idx > self.count():
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 return
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
284 url = self.widget(idx).url()
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
285 self.newBrowser(url)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 def __tabContextMenuClose(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 Private method to close the selected tab.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.closeBrowserAt(self.__tabContextMenuIndex)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 def __tabContextMenuCloseOthers(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Private slot to close all other tabs.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 index = self.__tabContextMenuIndex
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 for i in (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 list(range(self.count() - 1, index, -1)) +
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
300 list(range(index - 1, -1, -1))
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
301 ):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.closeBrowserAt(i)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
304 def __tabContextMenuPrint(self):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
305 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
306 Private method to print the selected tab.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
307 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
308 browser = self.widget(self.__tabContextMenuIndex)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
309 self.printBrowser(browser)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
310
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
311 def __tabContextMenuPrintPdf(self):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
312 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
313 Private method to print the selected tab as PDF.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
314 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
315 browser = self.widget(self.__tabContextMenuIndex)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
316 self.printBrowserPdf(browser)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
317
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
318 def __tabContextMenuPrintPreview(self):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
319 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
320 Private method to show a print preview of the selected tab.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
321 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
322 browser = self.widget(self.__tabContextMenuIndex)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
323 self.printPreviewBrowser(browser)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
324
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
325 def __tabContextMenuAudioMute(self):
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
326 """
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
327 Private method to mute or unmute the selected tab.
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
328 """
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
329 page = self.widget(self.__tabContextMenuIndex).page()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
330 muted = page.isAudioMuted()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
331 page.setAudioMuted(not muted)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
332
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
333 @pyqtSlot(bool)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
334 def __recentlyAudibleChanged(self, recentlyAudible, page):
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
335 """
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
336 Private slot to react on the audible state of a page.
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
337
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
338 @param recentlyAudible flag indicating the new audible state
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
339 @type bool
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
340 @param page reference to the web page
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
341 @type WebBrowserPage
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
342 """
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
343 browser = page.view()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
344 if browser is None:
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
345 return
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
346
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
347 index = self.indexOf(browser)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
348 icon = page.icon()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
349
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
350 if page.isAudioMuted() or (
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
351 not page.isAudioMuted() and recentlyAudible):
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
352 pix = QPixmap(32, 32)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
353 pix.fill(Qt.transparent)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
354 painter = QPainter(pix)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
355 icon.paint(painter, 0, 0, 22, 22)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
356 if page.isAudioMuted():
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
357 audioIcon = UI.PixmapCache.getIcon("audioMuted")
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
358 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
359 audioIcon = UI.PixmapCache.getIcon("audioPlaying")
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
360 audioIcon.paint(painter, 13, 13, 18, 18)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
361 painter.end()
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
362 self.setTabIcon(index, QIcon(pix))
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
363 else:
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
364 self.setTabIcon(index, icon)
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
365
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
366 @pyqtSlot()
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
367 def __newBrowser(self):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
369 Private slot to open a new browser tab.
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
371 self.newBrowser()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372
5780
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
373 def newBrowser(self, link=None, position=-1, background=False,
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
374 restoreSession=False):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 Public method to create a new web browser tab.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
5780
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
378 @param link link to be shown
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
379 @type str or QUrl
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
380 @param position position to create the new tab at or -1 to add it
5780
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
381 to the end
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
382 @type int
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
383 @param background flag indicating to open the tab in the
5780
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
384 background
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
385 @type bool
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
386 @param restoreSession flag indicating a restore session action
5780
79d06c98c5c9 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5777
diff changeset
387 @type bool
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
388 @return reference to the new browser
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
389 @rtype WebBrowserView
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 if link is None:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 linkName = ""
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 elif isinstance(link, QUrl):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 linkName = link.toString()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 else:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 linkName = link
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2334
diff changeset
398 from .UrlBar.UrlBar import UrlBar
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
399 urlbar = UrlBar(self.__mainWindow, self)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
400 if self.__historyCompleter is None:
4749
750577d35452 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
401 import WebBrowser.WebBrowserWindow
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
402 from .History.HistoryCompleter import (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
403 HistoryCompletionModel, HistoryCompleter
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
404 )
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
405 self.__historyCompletionModel = HistoryCompletionModel(self)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
406 self.__historyCompletionModel.setSourceModel(
4749
750577d35452 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
407 WebBrowser.WebBrowserWindow.WebBrowserWindow.historyManager()
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
408 .historyFilterModel())
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
409 self.__historyCompleter = HistoryCompleter(
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
410 self.__historyCompletionModel, self)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
411 self.__historyCompleter.activated[str].connect(self.__pathSelected)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
412 urlbar.setCompleter(self.__historyCompleter)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
413 urlbar.returnPressed.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
414 lambda: self.__lineEditReturnPressed(urlbar))
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
415 if position == -1:
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
416 self.__stackedUrlBar.addWidget(urlbar)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
417 else:
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
418 self.__stackedUrlBar.insertWidget(position, urlbar)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
419
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
420 browser = WebBrowserView(self.__mainWindow, self)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
421 urlbar.setBrowser(browser)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
423 browser.sourceChanged.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
424 lambda url: self.__sourceChanged(url, browser))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
425 browser.titleChanged.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
426 lambda title: self.__titleChanged(title, browser))
641
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
427 browser.highlighted.connect(self.showMessage)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
428 browser.backwardAvailable.connect(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
429 self.__mainWindow.setBackwardAvailable)
641
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
430 browser.forwardAvailable.connect(self.__mainWindow.setForwardAvailable)
7578
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
431 browser.loadProgress.connect(
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
432 lambda progress: self.__loadProgress(progress, browser))
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
433 browser.loadFinished.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
434 lambda ok: self.__loadFinished(ok, browser))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
435 browser.faviconChanged.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
436 lambda: self.__iconChanged(browser))
641
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
437 browser.search.connect(self.newBrowser)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
438 browser.page().windowCloseRequested.connect(
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
439 lambda: self.__windowCloseRequested(browser.page()))
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
440 browser.zoomValueChanged.connect(self.browserZoomValueChanged)
5113
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
441 if hasattr(WebBrowserPage, "recentlyAudibleChanged"):
d394e20f7467 Added support for audio per tab to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
442 browser.page().recentlyAudibleChanged.connect(
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
443 lambda audible: self.__recentlyAudibleChanged(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
444 audible, browser.page()))
6656
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
445 try:
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
446 browser.page().printRequested.connect(
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
447 lambda: self.printBrowser(browser))
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
448 except AttributeError:
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
449 # pre Qt 5.12
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
450 pass
7356
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7271
diff changeset
451 browser.showMessage.connect(self.showMessage)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
453 if position == -1:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
454 index = self.addTab(browser, self.tr("..."))
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
455 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
456 index = self.insertTab(position, browser, self.tr("..."))
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
457 if not background:
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
458 self.setCurrentIndex(index)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459
641
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
460 self.__mainWindow.closeAct.setEnabled(True)
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
461 self.__mainWindow.closeAllAct.setEnabled(True)
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
462 self.__navigationButton.setEnabled(True)
b06d4df23797 Fixed an issue in the web browser related to webkit and Qt help and fixed an issue introduced by the latest refactoring.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 638
diff changeset
463
5783
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
464 if not restoreSession:
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
465 if not linkName:
5784
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
466 if Preferences.getWebBrowser("NewTabBehavior") == 0:
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
467 linkName = "about:blank"
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
468 elif Preferences.getWebBrowser("NewTabBehavior") == 1:
5783
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
469 linkName = Preferences.getWebBrowser("HomePage")
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
470 elif Preferences.getWebBrowser("NewTabBehavior") == 2:
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
471 linkName = "eric:speeddial"
5784
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
472
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
473 if linkName == "eric:blank":
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
474 linkName = "about:blank"
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 if linkName:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 browser.setSource(QUrl(linkName))
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 if not browser.documentTitle():
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 self.setTabText(index, self.__elide(linkName, Qt.ElideMiddle))
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 self.setTabToolTip(index, linkName)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 else:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
482 self.setTabText(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
483 index,
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 self.__elide(browser.documentTitle().replace("&", "&&")))
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 self.setTabToolTip(index, browser.documentTitle())
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
486
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
487 self.browserOpened.emit(browser)
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
488
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
489 return browser
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
491 def newBrowserAfter(self, browser, link=None, background=False):
3077
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
492 """
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
493 Public method to create a new web browser tab after a given one.
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
494
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
495 @param browser reference to the browser to add after (WebBrowserView)
3077
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
496 @param link link to be shown (string or QUrl)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
497 @param background flag indicating to open the tab in the
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
498 background (bool)
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
499 @return reference to the new browser
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
500 @rtype WebBrowserView
3077
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
501 """
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
502 if browser:
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
503 position = self.indexOf(browser) + 1
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
504 else:
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
505 position = -1
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
506 return self.newBrowser(link, position, background)
3077
8d2e69e02e19 Change web browser code to show windows requested by JavaScript next to the requesting tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3048
diff changeset
507
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 def __showNavigationMenu(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 Private slot to show the navigation button menu.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 self.__navigationMenu.clear()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 for index in range(self.count()):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 act = self.__navigationMenu.addAction(
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 self.tabIcon(index), self.tabText(index))
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 act.setData(index)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 def __navigationMenuTriggered(self, act):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 Private slot called to handle the navigation button menu selection.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 @param act reference to the selected action (QAction)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 index = act.data()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 if index is not None:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 self.setCurrentIndex(index)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
528 def __windowCloseRequested(self, page):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 Private slot to handle the windowCloseRequested signal of a browser.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
531
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
532 @param page reference to the web page
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
533 @type WebBrowserPage
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 browser = page.view()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 if browser is None:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 return
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 index = self.indexOf(browser)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 self.closeBrowserAt(index)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
542 def reloadAllBrowsers(self):
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
543 """
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
544 Public slot to reload all browsers.
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
545 """
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
546 for index in range(self.count()):
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
547 browser = self.widget(index)
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
548 browser and browser.reload()
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
549
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
550 @pyqtSlot()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 def closeBrowser(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 Public slot called to handle the close action.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 self.closeBrowserAt(self.currentIndex())
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
557 def closeAllBrowsers(self, shutdown=False):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 Public slot called to handle the close all action.
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
560
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
561 @param shutdown flag indicating a shutdown action
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
562 @type bool
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 for index in range(self.count() - 1, -1, -1):
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
565 self.closeBrowserAt(index, shutdown=shutdown)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
567 def closeBrowserView(self, browser):
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
568 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
569 Public method to close the given browser.
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
570
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
571 @param browser reference to the web browser view to be closed
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
572 @type WebBrowserView
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
573 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
574 index = self.indexOf(browser)
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
575 self.closeBrowserAt(index)
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
576
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
577 def closeBrowserAt(self, index, shutdown=False):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 """
2763
e4794166ad70 Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
579 Public slot to close a browser based on its index.
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
581 @param index index of browser to close
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
582 @type int
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
583 @param shutdown flag indicating a shutdown action
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
584 @type bool
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 browser = self.widget(index)
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1665
diff changeset
587 if browser is None:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1665
diff changeset
588 return
1694
648466a9451b Added the capability to restore closed tabs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1673
diff changeset
589
4314
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
590 urlbar = self.__stackedUrlBar.widget(index)
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
591 self.__stackedUrlBar.removeWidget(urlbar)
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
592 urlbar.deleteLater()
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
593 del urlbar
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
594
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
595 self.__closedTabsManager.recordBrowser(browser, index)
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
596
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4749
diff changeset
597 browser.closeWebInspector()
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
598 WebInspector.unregisterView(browser)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 self.removeTab(index)
1196
77da430b4080 Added an action to preview the file in the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1155
diff changeset
600 self.browserClosed.emit(browser)
4314
2d9133f4cc10 Modified the web browser such, that it will ask the user, if he wants to close a modified page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
601 browser.deleteLater()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 del browser
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
603
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4741
diff changeset
604 if self.count() == 0 and not shutdown:
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 self.newBrowser()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 else:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 self.currentChanged[int].emit(self.currentIndex())
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 def currentBrowser(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 Public method to get a reference to the current browser.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
613 @return reference to the current browser (WebBrowserView)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 return self.currentWidget()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 def browserAt(self, index):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 Public method to get a reference to the browser with the given index.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 @param index index of the browser to get (integer)
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
622 @return reference to the indexed browser (WebBrowserView)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 return self.widget(index)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 def browsers(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 Public method to get a list of references to all browsers.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
630 @return list of references to browsers (list of WebBrowserView)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
632 li = []
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 for index in range(self.count()):
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
634 li.append(self.widget(index))
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
635 return li
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
637 @pyqtSlot()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
638 def printBrowser(self, browser=None):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
639 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
640 Public slot called to print the displayed page.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
641
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
642 @param browser reference to the browser to be printed (WebBrowserView)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
643 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
644 if browser is None:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
645 browser = self.currentBrowser()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
646
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
647 printer = QPrinter(mode=QPrinter.HighResolution)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
648 if Preferences.getPrinter("ColorMode"):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
649 printer.setColorMode(QPrinter.Color)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
650 else:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
651 printer.setColorMode(QPrinter.GrayScale)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
652 if Preferences.getPrinter("FirstPageFirst"):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
653 printer.setPageOrder(QPrinter.FirstPageFirst)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
654 else:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
655 printer.setPageOrder(QPrinter.LastPageFirst)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
656 printer.setPageMargins(
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
657 Preferences.getPrinter("LeftMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
658 Preferences.getPrinter("TopMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
659 Preferences.getPrinter("RightMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
660 Preferences.getPrinter("BottomMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
661 QPrinter.Millimeter
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
662 )
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
663 printerName = Preferences.getPrinter("PrinterName")
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
664 if printerName:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
665 printer.setPrinterName(printerName)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
666 printer.setResolution(Preferences.getPrinter("Resolution"))
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
667 documentName = WebBrowserTools.getFileNameFromUrl(browser.url())
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
668 printer.setDocName(documentName)
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
669
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
670 printDialog = QPrintDialog(printer, self)
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
671 printDialog.setOptions(QAbstractPrintDialog.PrintToFile |
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
672 QAbstractPrintDialog.PrintShowPageSize)
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
673 if not Globals.isWindowsPlatform():
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
674 if isCupsAvailable():
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
675 printDialog.setOption(QAbstractPrintDialog.PrintCollateCopies)
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
676 printDialog.setOption(QAbstractPrintDialog.PrintPageRange)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7578
diff changeset
677 if printDialog.exec() == QDialog.Accepted:
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
678 browser.page().execPrintPage(printer, 10 * 1000)
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
679
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
680 @pyqtSlot()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
681 def printBrowserPdf(self, browser=None):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
682 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
683 Public slot called to print the displayed page to PDF.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
684
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
685 @param browser reference to the browser to be printed (HelpBrowser)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
686 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
687 if browser is None:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
688 browser = self.currentBrowser()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
689
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
690 name = WebBrowserTools.getFileNameFromUrl(browser.url())
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
691 if name:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
692 name = name.rsplit('.', 1)[0]
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
693 name += '.pdf'
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
694 if hasattr(browser.page(), "printToPdf"):
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
695 from .Tools.PrintToPdfDialog import PrintToPdfDialog
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
696 if not name:
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
697 name = "printout.pdf"
5181
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
698 dlg = PrintToPdfDialog(name, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7578
diff changeset
699 if dlg.exec() == QDialog.Accepted:
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
700 filePath, pageLayout = dlg.getData()
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
701 if filePath:
5181
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
702 if os.path.exists(filePath):
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
703 res = E5MessageBox.warning(
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
704 self,
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
705 self.tr("Print to PDF"),
5181
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
706 self.tr("""<p>The file <b>{0}</b> exists"""
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
707 """ already. Shall it be"""
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
708 """ overwritten?</p>""").format(filePath),
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
709 E5MessageBox.StandardButtons(
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
710 E5MessageBox.No |
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
711 E5MessageBox.Yes),
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
712 E5MessageBox.No)
5181
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
713 if res == E5MessageBox.No:
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
714 return
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
715 browser.page().printToPdf(
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
716 lambda pdf: self.__pdfGeneratedForSave(filePath, pdf),
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
717 pageLayout)
5181
1948b27d7b21 Fixed a few issues related to printing in the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5113
diff changeset
718 elif Globals.isLinuxPlatform():
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
719 printer = QPrinter(mode=QPrinter.HighResolution)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
720 if Preferences.getPrinter("ColorMode"):
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
721 printer.setColorMode(QPrinter.Color)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
722 else:
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
723 printer.setColorMode(QPrinter.GrayScale)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
724 printerName = Preferences.getPrinter("PrinterName")
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
725 if printerName:
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
726 printer.setPrinterName(printerName)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
727 printer.setOutputFormat(QPrinter.PdfFormat)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
728 if name:
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
729 printer.setOutputFileName(name)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
730 printer.setResolution(Preferences.getPrinter("Resolution"))
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
731
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
732 printDialog = QPrintDialog(printer, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7578
diff changeset
733 if printDialog.exec() == QDialog.Accepted:
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
734 browser.render(printer)
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
735
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
736 def __pdfGeneratedForSave(self, filePath, pdfData):
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
737 """
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
738 Private slot to save the generated PDF data to a file.
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
739
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
740 @param filePath path to save the PDF to
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
741 @type str
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
742 @param pdfData generated PDF document
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
743 @type QByteArray
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
744 """
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
745 if pdfData.size() == 0:
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
746 return
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
747
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
748 pdfFile = QFile(filePath)
5182
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
749 if pdfFile.open(QFile.WriteOnly):
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
750 pdfFile.write(pdfData)
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
751 pdfFile.close()
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
752 if pdfFile.error() != QFileDevice.NoError:
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
753 E5MessageBox.critical(
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
754 self,
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
755 self.tr("Print to PDF"),
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
756 self.tr("""<p>The PDF could not be written to file <b>{0}"""
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
757 """</b>.</p><p><b>Error:</b> {1}</p>""").format(
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
758 filePath, pdfFile.errorString()),
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
759 E5MessageBox.StandardButtons(
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
760 E5MessageBox.Ok))
e2782c9a43d4 Started to implement real printing support for the new web browser and Qt >= 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5181
diff changeset
761
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
762 @pyqtSlot()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
763 def printPreviewBrowser(self, browser=None):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
764 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
765 Public slot called to show a print preview of the displayed file.
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
766
5534
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
767 @param browser reference to the browser to be printed (WebBrowserView)
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
768 """
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
769 from PyQt5.QtPrintSupport import QPrintPreviewDialog
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
770
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
771 if browser is None:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
772 browser = self.currentBrowser()
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
773
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
774 printer = QPrinter(mode=QPrinter.HighResolution)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
775 if Preferences.getPrinter("ColorMode"):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
776 printer.setColorMode(QPrinter.Color)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
777 else:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
778 printer.setColorMode(QPrinter.GrayScale)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
779 if Preferences.getPrinter("FirstPageFirst"):
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
780 printer.setPageOrder(QPrinter.FirstPageFirst)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
781 else:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
782 printer.setPageOrder(QPrinter.LastPageFirst)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
783 printer.setPageMargins(
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
784 Preferences.getPrinter("LeftMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
785 Preferences.getPrinter("TopMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
786 Preferences.getPrinter("RightMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
787 Preferences.getPrinter("BottomMargin") * 10,
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
788 QPrinter.Millimeter
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
789 )
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
790 printerName = Preferences.getPrinter("PrinterName")
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
791 if printerName:
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
792 printer.setPrinterName(printerName)
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
793 printer.setResolution(Preferences.getPrinter("Resolution"))
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
794
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
795 preview = QPrintPreviewDialog(printer, self)
5534
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
796 preview.resize(800, 750)
7201
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
797 preview.paintRequested.connect(
6b42677d7043 Modified sources to be in line with the minimum Qt/PyQt requirement (v 5.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6999
diff changeset
798 lambda p: self.__printPreviewRequested(p, browser))
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7578
diff changeset
799 preview.exec()
4792
f55fa7eb3cf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
800
5534
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
801 def __printPreviewRequested(self, printer, browser):
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
802 """
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
803 Private slot to generate the print preview.
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
804
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
805 @param printer reference to the printer object
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
806 @type QPrinter
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
807 @param browser reference to the browser to be printed
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
808 @type WebBrowserView
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
809 """
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
810 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
811 browser.page().execPrintPage(printer, 10 * 1000)
5534
f9368ecf153a Re-enabled the print preview function for all platforms and the print for Windows platforms for the new web browser and Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
812
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
813 def __sourceChanged(self, url, browser):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 Private slot to handle a change of a browsers source.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
817 @param url URL of the new site
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
818 @type QUrl
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
819 @param browser reference to the web browser
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
820 @type WebBrowserView
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 """
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
822 self.sourceChanged.emit(browser, url)
1645
73904ca06d2d A few fixes for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1636
diff changeset
823
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
824 if browser == self.currentBrowser():
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
825 self.currentUrlChanged.emit(url)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
827 def __titleChanged(self, title, browser):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 Private slot to handle a change of a browsers title.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
831 @param title new title
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
832 @type str
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
833 @param browser reference to the web browser
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
834 @type WebBrowserView
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 """
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
836 index = self.indexOf(browser)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
837 if title == "":
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
838 title = browser.url().toString()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
840 self.setTabText(index, self.__elide(title.replace("&", "&&")))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
841 self.setTabToolTip(index, title)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
842
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
843 self.titleChanged.emit(browser, title)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
845 def __elide(self, txt, mode=Qt.ElideRight, length=40):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 Private method to elide some text.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 @param txt text to be elided (string)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
850 @param mode elide mode (Qt.TextElideMode)
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
851 @param length amount of characters to be used (integer)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 @return the elided text (string)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 if mode == Qt.ElideNone or len(txt) < length:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 return txt
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 elif mode == Qt.ElideLeft:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 return "...{0}".format(txt[-length:])
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 elif mode == Qt.ElideMiddle:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 return "{0}...{1}".format(txt[:length // 2], txt[-(length // 2):])
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 elif mode == Qt.ElideRight:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 return "{0}...".format(txt[:length])
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 else:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 # just in case
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 return txt
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 def preferencesChanged(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 Public slot to handle a change of preferences.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 for browser in self.browsers():
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 browser.preferencesChanged()
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
872
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
873 for urlbar in self.__stackedUrlBar.urlBars():
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
874 urlbar.preferencesChanged()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
876 def __loadFinished(self, ok, browser):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 Private method to handle the loadFinished signal.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
880 @param ok flag indicating the result
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
881 @type bool
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
882 @param browser reference to the web browser
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
883 @type WebBrowserView
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 """
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
885 if ok:
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
886 self.showMessage.emit(self.tr("Finished loading"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
887 else:
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
888 self.showMessage.emit(self.tr("Failed to load"))
7578
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
889
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
890 def __loadProgress(self, progress, browser):
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
891 """
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
892 Private method to handle the loadProgress signal.
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893
7578
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
894 Note: This works around wegengine not sending a loadFinished
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
895 signal for navigation on the same page.
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
896
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
897 @param progress load progress in percent
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
898 @type int
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
899 @param browser reference to the web browser
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
900 @type WebBrowserView
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
901 """
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
902 index = self.indexOf(browser)
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
903 if progress == 0:
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
904 # page loading has started
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
905 anim = self.animationLabel(index, "loadingAnimation", 40)
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
906 if not anim:
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
907 self.setTabIcon(index, UI.PixmapCache.getIcon("loading"))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
908 else:
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
909 self.setTabIcon(index, QIcon())
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
910 self.setTabText(index, self.tr("Loading..."))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
911 self.setTabToolTip(index, self.tr("Loading..."))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
912 self.showMessage.emit(self.tr("Loading..."))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
913
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
914 self.__mainWindow.setLoadingActions(True)
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
915 elif progress == 100:
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
916 import WebBrowser.WebBrowserWindow
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
917 self.resetAnimation(index)
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
918 self.setTabIcon(
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
919 index, WebBrowser.WebBrowserWindow.WebBrowserWindow.icon(
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
920 browser.url()))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
921 self.showMessage.emit(self.tr("Finished loading"))
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
922
13b2c2167c93 Web Browser: implemented a fix for QtWebEngine not sending the loadFinished signal when navigating on the same page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
923 self.__mainWindow.setLoadingActions(False)
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
925 def __iconChanged(self, browser):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 """
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
927 Private slot to handle a change of the web site icon.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
928
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
929 @param browser reference to the web browser
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
930 @type WebBrowserView
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 """
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
932 self.setTabIcon(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
933 self.indexOf(browser),
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
934 browser.icon())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
935 self.__mainWindow.bookmarksManager().faviconChanged(browser.url())
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 def getSourceFileList(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 """
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
939 Public method to get a list of all opened Qt help files.
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 @return dictionary with tab id as key and host/namespace as value
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 sourceList = {}
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 for i in range(self.count()):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 browser = self.widget(i)
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
946 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
947 browser is not None and
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
948 browser.source().isValid()
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
949 ):
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 sourceList[i] = browser.source().host()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 return sourceList
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 def shallShutDown(self):
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 """
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 Public method to check, if the application should be shut down.
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 @return flag indicating a shut down (boolean)
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 """
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
960 if self.count() > 1 and Preferences.getWebBrowser(
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
961 "WarnOnMultipleClose"):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
962 mb = E5MessageBox.E5MessageBox(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
963 E5MessageBox.Information,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
964 self.tr("Are you sure you want to close the window?"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
965 self.tr("""Are you sure you want to close the window?\n"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
966 """You have %n tab(s) open.""", "", self.count()),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
967 modal=True,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
968 parent=self)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
969 quitButton = mb.addButton(
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
970 self.tr("&Quit"), E5MessageBox.AcceptRole)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
971 quitButton.setIcon(UI.PixmapCache.getIcon("exit"))
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
972 closeTabButton = mb.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
973 self.tr("C&lose Current Tab"), E5MessageBox.AcceptRole)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
974 closeTabButton.setIcon(UI.PixmapCache.getIcon("tabClose"))
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 mb.addButton(E5MessageBox.Cancel)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7578
diff changeset
976 mb.exec()
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 if mb.clickedButton() == quitButton:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 return True
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 else:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 if mb.clickedButton() == closeTabButton:
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 self.closeBrowser()
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 return False
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 return True
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
985
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
986 def stackedUrlBar(self):
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
987 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
988 Public method to get a reference to the stacked url bar.
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
989
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
990 @return reference to the stacked url bar (StackedUrlBar)
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
991 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
992 return self.__stackedUrlBar
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
993
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
994 def currentUrlBar(self):
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
995 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
996 Public method to get a reference to the current url bar.
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
997
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
998 @return reference to the current url bar (UrlBar)
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
999 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1000 return self.__stackedUrlBar.currentWidget()
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1001
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1002 def urlBarForView(self, view):
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1003 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1004 Public method to get a reference to the UrlBar associated with the
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1005 given view.
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1006
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1007 @param view reference to the view to get the urlbar for
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1008 @type WebBrowserView
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1009 @return reference to the associated urlbar
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1010 @rtype UrlBar
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1011 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1012 for urlbar in self.__stackedUrlBar.urlBars():
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1013 if urlbar.browser() is view:
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1014 return urlbar
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1015
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1016 return None
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6122
diff changeset
1017
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
1018 def __lineEditReturnPressed(self, edit):
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1019 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1020 Private slot to handle the entering of an URL.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
1021
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
1022 @param edit reference to the line edit
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
1023 @type UrlBar
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1024 """
953
7c42d54ba205 Added support for search schemes ("s:" or "search:") and "about:home" to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
1025 url = self.__guessUrlFromPath(edit.text())
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1026 if e5App().keyboardModifiers() == Qt.AltModifier:
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
1027 self.newBrowser(url)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1028 else:
4709
8612533a223f Started porting the eric web browser to use QtWebEngine.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
1029 self.currentBrowser().setSource(url)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1030 self.currentBrowser().setFocus()
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1031
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1032 def __pathSelected(self, path):
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1033 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1034 Private slot called when a URL is selected from the completer.
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1035
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1036 @param path path to be shown (string)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1037 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1038 url = self.__guessUrlFromPath(path)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
1039 self.currentBrowser().setSource(url)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1040
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1041 def __guessUrlFromPath(self, path):
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1042 """
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
1043 Private method to guess an URL given a path string.
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 646
diff changeset
104