50 self.__browser = None |
50 self.__browser = None |
51 self.__privateMode = WebBrowserWindow.isPrivate() |
51 self.__privateMode = WebBrowserWindow.isPrivate() |
52 |
52 |
53 self.__bmActiveIcon = UI.PixmapCache.getIcon("bookmark16") |
53 self.__bmActiveIcon = UI.PixmapCache.getIcon("bookmark16") |
54 self.__bmInactiveIcon = QIcon( |
54 self.__bmInactiveIcon = QIcon( |
55 self.__bmActiveIcon.pixmap(16, 16, QIcon.Disabled)) |
55 self.__bmActiveIcon.pixmap(16, 16, QIcon.Mode.Disabled)) |
56 |
56 |
57 self.__safeBrowsingLabel = SafeBrowsingLabel(self) |
57 self.__safeBrowsingLabel = SafeBrowsingLabel(self) |
58 self.addWidget(self.__safeBrowsingLabel, E5LineEdit.LeftSide) |
58 self.addWidget(self.__safeBrowsingLabel, E5LineEdit.LeftSide) |
59 self.__safeBrowsingLabel.setVisible(False) |
59 self.__safeBrowsingLabel.setVisible(False) |
60 |
60 |
203 from .BookmarkActionSelectionDialog import ( |
203 from .BookmarkActionSelectionDialog import ( |
204 BookmarkActionSelectionDialog |
204 BookmarkActionSelectionDialog |
205 ) |
205 ) |
206 url = self.__browser.url() |
206 url = self.__browser.url() |
207 dlg = BookmarkActionSelectionDialog(url) |
207 dlg = BookmarkActionSelectionDialog(url) |
208 if dlg.exec() == QDialog.Accepted: |
208 if dlg.exec() == QDialog.DialogCode.Accepted: |
209 action = dlg.getAction() |
209 action = dlg.getAction() |
210 if action == BookmarkActionSelectionDialog.AddBookmark: |
210 if action == BookmarkActionSelectionDialog.AddBookmark: |
211 self.__browser.addBookmark() |
211 self.__browser.addBookmark() |
212 elif action == BookmarkActionSelectionDialog.EditBookmark: |
212 elif action == BookmarkActionSelectionDialog.EditBookmark: |
213 bookmark = ( |
213 bookmark = ( |
233 """ |
233 """ |
234 Protected method handling a paint event. |
234 Protected method handling a paint event. |
235 |
235 |
236 @param evt reference to the paint event (QPaintEvent) |
236 @param evt reference to the paint event (QPaintEvent) |
237 """ |
237 """ |
238 foregroundColor = QApplication.palette().color(QPalette.Text) |
238 foregroundColor = QApplication.palette().color(QPalette.ColorRole.Text) |
239 |
239 |
240 if self.__privateMode: |
240 if self.__privateMode: |
241 backgroundColor = Preferences.getWebBrowser("PrivateModeUrlColor") |
241 backgroundColor = Preferences.getWebBrowser("PrivateModeUrlColor") |
242 else: |
242 else: |
243 backgroundColor = QApplication.palette().color(QPalette.Base) |
243 backgroundColor = QApplication.palette().color( |
|
244 QPalette.ColorRole.Base) |
244 |
245 |
245 if self.__browser is not None: |
246 if self.__browser is not None: |
246 p = self.palette() |
247 p = self.palette() |
247 progress = self.__browser.progress() |
248 progress = self.__browser.progress() |
248 |
249 |
259 else: |
260 else: |
260 backgroundColor = Preferences.getWebBrowser( |
261 backgroundColor = Preferences.getWebBrowser( |
261 "SecureUrlColor") |
262 "SecureUrlColor") |
262 |
263 |
263 if progress == 0 or progress == 100: |
264 if progress == 0 or progress == 100: |
264 p.setBrush(QPalette.Base, backgroundColor) |
265 p.setBrush(QPalette.ColorRole.Base, backgroundColor) |
265 p.setBrush(QPalette.Text, foregroundColor) |
266 p.setBrush(QPalette.ColorRole.Text, foregroundColor) |
266 else: |
267 else: |
267 highlight = QApplication.palette().color(QPalette.Highlight) |
268 highlight = QApplication.palette().color( |
|
269 QPalette.ColorRole.Highlight) |
268 r = (highlight.red() + 2 * backgroundColor.red()) // 3 |
270 r = (highlight.red() + 2 * backgroundColor.red()) // 3 |
269 g = (highlight.green() + 2 * backgroundColor.green()) // 3 |
271 g = (highlight.green() + 2 * backgroundColor.green()) // 3 |
270 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3 |
272 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3 |
271 |
273 |
272 loadingColor = QColor(r, g, b) |
274 loadingColor = QColor(r, g, b) |
281 gradient = QLinearGradient( |
283 gradient = QLinearGradient( |
282 QPointF(0, 0), QPointF(self.width(), 0)) |
284 QPointF(0, 0), QPointF(self.width(), 0)) |
283 gradient.setColorAt(0, loadingColor) |
285 gradient.setColorAt(0, loadingColor) |
284 gradient.setColorAt(progress / 100.0 - 0.000001, loadingColor) |
286 gradient.setColorAt(progress / 100.0 - 0.000001, loadingColor) |
285 gradient.setColorAt(progress / 100.0, backgroundColor) |
287 gradient.setColorAt(progress / 100.0, backgroundColor) |
286 p.setBrush(QPalette.Base, gradient) |
288 p.setBrush(QPalette.ColorRole.Base, gradient) |
287 |
289 |
288 self.setPalette(p) |
290 self.setPalette(p) |
289 |
291 |
290 E5LineEdit.paintEvent(self, evt) |
292 E5LineEdit.paintEvent(self, evt) |
291 |
293 |
303 """ |
305 """ |
304 Protected method called by a mouse press event. |
306 Protected method called by a mouse press event. |
305 |
307 |
306 @param evt reference to the mouse event (QMouseEvent) |
308 @param evt reference to the mouse event (QMouseEvent) |
307 """ |
309 """ |
308 if evt.button() == Qt.XButton1: |
310 if evt.button() == Qt.MouseButton.XButton1: |
309 self.__mw.currentBrowser().triggerPageAction( |
311 self.__mw.currentBrowser().triggerPageAction( |
310 QWebEnginePage.Back) |
312 QWebEnginePage.WebAction.Back) |
311 elif evt.button() == Qt.XButton2: |
313 elif evt.button() == Qt.MouseButton.XButton2: |
312 self.__mw.currentBrowser().triggerPageAction( |
314 self.__mw.currentBrowser().triggerPageAction( |
313 QWebEnginePage.Forward) |
315 QWebEnginePage.WebAction.Forward) |
314 else: |
316 else: |
315 super(UrlBar, self).mousePressEvent(evt) |
317 super(UrlBar, self).mousePressEvent(evt) |
316 |
318 |
317 def mouseDoubleClickEvent(self, evt): |
319 def mouseDoubleClickEvent(self, evt): |
318 """ |
320 """ |
319 Protected method to handle mouse double click events. |
321 Protected method to handle mouse double click events. |
320 |
322 |
321 @param evt reference to the mouse event (QMouseEvent) |
323 @param evt reference to the mouse event (QMouseEvent) |
322 """ |
324 """ |
323 if evt.button() == Qt.LeftButton: |
325 if evt.button() == Qt.MouseButton.LeftButton: |
324 self.selectAll() |
326 self.selectAll() |
325 else: |
327 else: |
326 E5LineEdit.mouseDoubleClickEvent(self, evt) |
328 E5LineEdit.mouseDoubleClickEvent(self, evt) |
327 |
329 |
328 def keyPressEvent(self, evt): |
330 def keyPressEvent(self, evt): |
329 """ |
331 """ |
330 Protected method to handle key presses. |
332 Protected method to handle key presses. |
331 |
333 |
332 @param evt reference to the key press event (QKeyEvent) |
334 @param evt reference to the key press event (QKeyEvent) |
333 """ |
335 """ |
334 if evt.key() == Qt.Key_Escape: |
336 if evt.key() == Qt.Key.Key_Escape: |
335 if self.__browser is not None: |
337 if self.__browser is not None: |
336 self.setText( |
338 self.setText( |
337 str(self.__browser.url().toEncoded(), encoding="utf-8")) |
339 str(self.__browser.url().toEncoded(), encoding="utf-8")) |
338 self.selectAll() |
340 self.selectAll() |
339 completer = self.completer() |
341 completer = self.completer() |
341 completer.popup().hide() |
343 completer.popup().hide() |
342 return |
344 return |
343 |
345 |
344 currentText = self.text().strip() |
346 currentText = self.text().strip() |
345 if ( |
347 if ( |
346 evt.key() in [Qt.Key_Enter, Qt.Key_Return] and |
348 evt.key() in [Qt.Key.Key_Enter, Qt.Key.Key_Return] and |
347 not currentText.lower().startswith(("http://", "https://")) |
349 not currentText.lower().startswith(("http://", "https://")) |
348 ): |
350 ): |
349 append = "" |
351 append = "" |
350 if evt.modifiers() == Qt.KeyboardModifiers(Qt.ControlModifier): |
352 if evt.modifiers() == Qt.KeyboardModifiers( |
|
353 Qt.KeyboardModifier.ControlModifier |
|
354 ): |
351 append = ".com" |
355 append = ".com" |
|
356 elif ( |
|
357 evt.modifiers() == Qt.KeyboardModifiers( |
|
358 Qt.KeyboardModifier.ControlModifier | |
|
359 Qt.KeyboardModifier.ShiftModifier |
|
360 ) |
|
361 ): |
|
362 append = ".org" |
352 elif evt.modifiers() == Qt.KeyboardModifiers( |
363 elif evt.modifiers() == Qt.KeyboardModifiers( |
353 Qt.ControlModifier | Qt.ShiftModifier): |
364 Qt.KeyboardModifier.ShiftModifier |
354 append = ".org" |
365 ): |
355 elif evt.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier): |
|
356 append = ".net" |
366 append = ".net" |
357 |
367 |
358 if append != "": |
368 if append != "": |
359 url = QUrl("http://www." + currentText) |
369 url = QUrl("http://www." + currentText) |
360 host = url.host() |
370 host = url.host() |
388 url = QUrl() |
398 url = QUrl() |
389 if mimeData.hasUrls(): |
399 if mimeData.hasUrls(): |
390 url = mimeData.urls()[0] |
400 url = mimeData.urls()[0] |
391 elif mimeData.hasText(): |
401 elif mimeData.hasText(): |
392 url = QUrl.fromEncoded(mimeData.text().encode("utf-8"), |
402 url = QUrl.fromEncoded(mimeData.text().encode("utf-8"), |
393 QUrl.TolerantMode) |
403 QUrl.ParsingMode.TolerantMode) |
394 |
404 |
395 if url.isEmpty() or not url.isValid(): |
405 if url.isEmpty() or not url.isValid(): |
396 E5LineEdit.dropEvent(self, evt) |
406 E5LineEdit.dropEvent(self, evt) |
397 return |
407 return |
398 |
408 |
441 sslConfiguration = self.__browser.page().getSslConfiguration() |
451 sslConfiguration = self.__browser.page().getSslConfiguration() |
442 if sslConfiguration is not None and QSslCertificate is not None: |
452 if sslConfiguration is not None and QSslCertificate is not None: |
443 sslCertificate = self.__browser.page().getSslCertificate() |
453 sslCertificate = self.__browser.page().getSslCertificate() |
444 if sslCertificate is not None: |
454 if sslCertificate is not None: |
445 org = Utilities.decodeString(", ".join( |
455 org = Utilities.decodeString(", ".join( |
446 sslCertificate.subjectInfo(QSslCertificate.Organization))) |
456 sslCertificate.subjectInfo( |
|
457 QSslCertificate.SubjectInfo.Organization))) |
447 if org == "": |
458 if org == "": |
448 cn = Utilities.decodeString(", ".join( |
459 cn = Utilities.decodeString(", ".join( |
449 sslCertificate.subjectInfo( |
460 sslCertificate.subjectInfo( |
450 QSslCertificate.CommonName))) |
461 QSslCertificate.SubjectInfo.CommonName))) |
451 if cn != "": |
462 if cn != "": |
452 org = cn.split(".", 1)[1] |
463 org = cn.split(".", 1)[1] |
453 if org == "": |
464 if org == "": |
454 org = self.tr("Unknown") |
465 org = self.tr("Unknown") |
455 self.__sslLabel.setText(" {0} ".format(org)) |
466 self.__sslLabel.setText(" {0} ".format(org)) |