6 """ |
6 """ |
7 Module implementing the URL bar widget. |
7 Module implementing the URL bar widget. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import Qt, QPointF, QUrl |
10 from PyQt4.QtCore import Qt, QPointF, QUrl |
11 from PyQt4.QtGui import QColor, QPalette, QApplication, QLinearGradient |
11 from PyQt4.QtGui import QColor, QPalette, QApplication, QLinearGradient, QLabel |
|
12 from PyQt4.QtNetwork import QSslCertificate |
12 from PyQt4.QtWebKit import QWebSettings |
13 from PyQt4.QtWebKit import QWebSettings |
13 |
14 |
14 from E5Gui.E5LineEdit import E5LineEdit |
15 from E5Gui.E5LineEdit import E5LineEdit |
15 from E5Gui.E5LineEditButton import E5LineEditButton |
16 from E5Gui.E5LineEditButton import E5LineEditButton |
16 |
17 |
39 QWebSettings.PrivateBrowsingEnabled) |
40 QWebSettings.PrivateBrowsingEnabled) |
40 |
41 |
41 self.__favicon = FavIconLabel(self) |
42 self.__favicon = FavIconLabel(self) |
42 self.addWidget(self.__favicon, E5LineEdit.LeftSide) |
43 self.addWidget(self.__favicon, E5LineEdit.LeftSide) |
43 |
44 |
|
45 self.__sslLabel = QLabel(self) |
|
46 self.__sslLabel.setStyleSheet( |
|
47 "QLabel { color : white; background-color : green; }") |
|
48 self.addWidget(self.__sslLabel, E5LineEdit.LeftSide) |
|
49 self.__sslLabel.setVisible(False) |
|
50 |
44 self.__privacyButton = E5LineEditButton(self) |
51 self.__privacyButton = E5LineEditButton(self) |
45 self.__privacyButton.setIcon(UI.PixmapCache.getIcon("privateBrowsing.png")) |
52 self.__privacyButton.setIcon(UI.PixmapCache.getIcon("privateBrowsing.png")) |
46 self.addWidget(self.__privacyButton, E5LineEdit.RightSide) |
53 self.addWidget(self.__privacyButton, E5LineEdit.RightSide) |
47 self.__privacyButton.setVisible(self.__privateMode) |
54 self.__privacyButton.setVisible(self.__privateMode) |
48 |
55 |
65 self.__browser = browser |
72 self.__browser = browser |
66 self.__favicon.setBrowser(browser) |
73 self.__favicon.setBrowser(browser) |
67 |
74 |
68 self.__browser.urlChanged.connect(self.__browserUrlChanged) |
75 self.__browser.urlChanged.connect(self.__browserUrlChanged) |
69 self.__browser.loadProgress.connect(self.update) |
76 self.__browser.loadProgress.connect(self.update) |
|
77 self.__browser.loadFinished.connect(self.__loadFinished) |
|
78 self.__browser.loadStarted.connect(self.__loadStarted) |
70 |
79 |
71 def browser(self): |
80 def browser(self): |
72 """ |
81 """ |
73 Public method to get the associated browser (HelpBrowser) |
82 Public method to get the associated browser (HelpBrowser) |
74 """ |
83 """ |
80 |
89 |
81 @param url new URL of the browser (QUrl) |
90 @param url new URL of the browser (QUrl) |
82 """ |
91 """ |
83 self.setText(str(url.toEncoded(), encoding = "utf-8")) |
92 self.setText(str(url.toEncoded(), encoding = "utf-8")) |
84 self.setCursorPosition(0) |
93 self.setCursorPosition(0) |
|
94 |
|
95 def __loadStarted(self): |
|
96 """ |
|
97 Private slot to perform actions before the page is loaded. |
|
98 """ |
|
99 self.__sslLabel.setVisible(False) |
|
100 |
|
101 def __loadFinished(self, ok): |
|
102 """ |
|
103 Private slot to set some data after the page was loaded. |
|
104 |
|
105 @param ok flag indicating a successful load (boolean) |
|
106 """ |
|
107 if ok and self.__browser.url().scheme() == "https": |
|
108 sslInfo = self.__browser.page().getSslInfo() |
|
109 if sslInfo is not None: |
|
110 org = sslInfo.subjectInfo(QSslCertificate.Organization) |
|
111 if org == "": |
|
112 cn = sslInfo.subjectInfo(QSslCertificate.CommonName) |
|
113 if cn != "": |
|
114 org = cn.split(".", 1)[1] |
|
115 if org == "": |
|
116 org = self.trUtf8("Unknown") |
|
117 self.__sslLabel.setText(" {0} ".format(org)) |
|
118 self.__sslLabel.setVisible(True) |
|
119 return |
|
120 |
|
121 self.__sslLabel.setVisible(False) |
85 |
122 |
86 def setPrivateMode(self, on): |
123 def setPrivateMode(self, on): |
87 """ |
124 """ |
88 Public method to set the private mode. |
125 Public method to set the private mode. |
89 |
126 |