eric6/WebBrowser/SiteInfo/SiteInfoWidget.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to show some site information.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QPoint
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
11 from PyQt5.QtWidgets import (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 QMenu, QGridLayout, QHBoxLayout, QLabel, QFrame, QSizePolicy, QPushButton,
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 QSpacerItem
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 )
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import UI.PixmapCache
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from WebBrowser.WebBrowserWindow import WebBrowserWindow
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class SiteInfoWidget(QMenu):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing a widget to show SSL certificate infos.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 def __init__(self, browser, parent=None):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param browser reference to the browser view
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type WebBrowserView
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param parent reference to the parent object
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type QWidget
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 super(SiteInfoWidget, self).__init__(parent)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__browser = browser
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 url = browser.url()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setMinimumWidth(400)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 layout = QGridLayout(self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 rows = 0
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 titleLabel = QLabel(self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 titleLabel.setText(self.tr("<b>Site {0}</b>").format(url.host()))
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 layout.addWidget(titleLabel, rows, 0, 1, -1, Qt.AlignCenter)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 line = QFrame(self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 line.setLineWidth(1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 line.setFrameStyle(QFrame.HLine | QFrame.Sunken)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 layout.addWidget(line, rows, 0, 1, -1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 secureIcon = QLabel()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 layout.addWidget(secureIcon, rows, 0, Qt.AlignCenter)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 secureLabel = QLabel()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 secureLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 layout.addWidget(secureLabel, rows, 1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 if url.scheme() in ["https"]:
7565
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
61 if WebBrowserWindow.networkManager().isInsecureHost(url.host()):
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
62 secureLabel.setText(
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
63 self.tr("Your connection to this site "
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
64 "<b>may not be secure</b>."))
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
65 secureIcon.setPixmap(
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
66 UI.PixmapCache.getPixmap("securityMedium"))
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
67 else:
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
68 secureLabel.setText(
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
69 self.tr("Your connection to this site is <b>secure</b>."))
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
70 secureIcon.setPixmap(
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
71 UI.PixmapCache.getPixmap("securityHigh"))
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 else:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 secureLabel.setText(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.tr("Your connection to this site is <b>not secure</b>."))
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 secureIcon.setPixmap(
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: 7360
diff changeset
76 UI.PixmapCache.getPixmap("securityLow"))
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 visits = WebBrowserWindow.historyManager().siteVisitsCount(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 url.scheme(), url.host())
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 historyIcon = QLabel()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 layout.addWidget(historyIcon, rows, 0, Qt.AlignCenter)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 historyLabel = QLabel()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 historyLabel.setSizePolicy(QSizePolicy.Expanding,
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 QSizePolicy.Preferred)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 layout.addWidget(historyLabel, rows, 1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 if visits > 3:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 historyLabel.setText(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.tr("This is your <b>{0}.</b> visit of this site.")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 .format(visits))
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 historyIcon.setPixmap(
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: 7360
diff changeset
92 UI.PixmapCache.getPixmap("flagGreen"))
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 elif visits == 0:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 historyLabel.setText(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.tr("You have <b>never</b> visited this site before.")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 .format(visits))
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 historyIcon.setPixmap(
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: 7360
diff changeset
98 UI.PixmapCache.getPixmap("flagBlack"))
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 else:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 historyIcon.setPixmap(
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: 7360
diff changeset
101 UI.PixmapCache.getPixmap("flagYellow"))
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 if visits == 1:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 visitStr = self.tr("first")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 elif visits == 2:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 visitStr = self.tr("second")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 else:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 visitStr = self.tr("third")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 historyLabel.setText(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.tr("This is your <b>{0}</b> visit of this site.")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 .format(visitStr))
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 line = QFrame(self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 line.setLineWidth(1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 line.setFrameStyle(QFrame.HLine | QFrame.Sunken)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 layout.addWidget(line, rows, 0, 1, -1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 page = self.__browser.page()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 scheme = page.registerProtocolHandlerRequestScheme()
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
121 registeredUrl = (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 WebBrowserWindow.protocolHandlerManager().protocolHandler(scheme)
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
123 )
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
124 if (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
125 bool(scheme) and
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
126 registeredUrl != page.registerProtocolHandlerRequestUrl()
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
127 ):
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 horizontalLayout = QHBoxLayout()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 protocolHandlerLabel = QLabel(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.tr("Register as <b>{0}</b> links handler.")
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 .format(scheme), self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 protocolHandlerLabel.setSizePolicy(QSizePolicy.Expanding,
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 QSizePolicy.Preferred)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 horizontalLayout.addWidget(protocolHandlerLabel)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 protocolHandlerButton = QPushButton(self.tr("Register"), self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 horizontalLayout.addWidget(protocolHandlerButton)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 protocolHandlerButton.clicked.connect(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.__registerProtocolHandler)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 layout.addLayout(horizontalLayout, rows, 0, 1, -1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 protocolHandlerLine = QFrame(self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 protocolHandlerLine.setLineWidth(1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 protocolHandlerLine.setFrameStyle(QFrame.HLine | QFrame.Sunken)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 layout.addWidget(protocolHandlerLine, rows, 0, 1, -1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 rows += 1
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 horizontalLayout = QHBoxLayout()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 spacerItem = QSpacerItem(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 horizontalLayout.addItem(spacerItem)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 moreButton = QPushButton(self.tr("More..."), self)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 horizontalLayout.addWidget(moreButton)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 moreButton.clicked.connect(self.__showSiteInfo)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 layout.addLayout(horizontalLayout, rows, 0, 1, -1)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 def showAt(self, pos):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 Public method to show the widget.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @param pos position to show at
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @type QPoint
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.adjustSize()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 xpos = pos.x() - self.width() // 2
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 if xpos < 0:
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 xpos = 10
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 p = QPoint(xpos, pos.y() + 10)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.move(p)
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 self.show()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 def accept(self):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 Public method to accept the widget.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.close()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 @pyqtSlot()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def __showSiteInfo(self):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Private slot to show the site info dialog.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 from .SiteInfoDialog import SiteInfoDialog
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 siteinfoDialog = SiteInfoDialog(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__browser, self.__browser.mainWindow())
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 siteinfoDialog.show()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @pyqtSlot()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 def __registerProtocolHandler(self):
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Private slot to register a protocol handler.
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.close()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 page = self.__browser.page()
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 WebBrowserWindow.protocolHandlerManager().addProtocolHandler(
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 page.registerProtocolHandlerRequestScheme(),
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 page.registerProtocolHandlerRequestUrl())

eric ide

mercurial