80 Public method get the page title. |
80 Public method get the page title. |
81 |
81 |
82 @return page title |
82 @return page title |
83 @rtype str |
83 @rtype str |
84 """ |
84 """ |
85 return self.documentTitle() |
85 titleStr = self.documentTitle() |
|
86 if not titleStr: |
|
87 url = self.url() |
|
88 |
|
89 titleStr = url.host() |
|
90 if not titleStr: |
|
91 titleStr = url.toString( |
|
92 QUrl.UrlFormattingOption.RemoveFragment) |
|
93 |
|
94 if not titleStr or titleStr == "about:blank": |
|
95 titleStr = self.tr("Empty Page") |
|
96 |
|
97 return titleStr |
86 |
98 |
87 def loadResource(self, type_, name): |
99 def loadResource(self, type_, name): |
88 """ |
100 """ |
89 Public method to load data of the specified type from the resource with |
101 Public method to load data of the specified type from the resource with |
90 the given name. |
102 the given name. |
135 else: |
147 else: |
136 # forward |
148 # forward |
137 for ind in range(index): |
149 for ind in range(index): |
138 self.forward() |
150 self.forward() |
139 |
151 |
|
152 def isBackwardAvailable(self): |
|
153 """ |
|
154 Public method to check, if stepping backward through the history is |
|
155 available. |
|
156 """ |
|
157 return QTextBrowser.isBackwardAvailable(self) |
|
158 |
|
159 def isForwardAvailable(self): |
|
160 """ |
|
161 Public method to check, if stepping forward through the history is |
|
162 available. |
|
163 """ |
|
164 return QTextBrowser.isForwardAvailable(self) |
|
165 |
140 def scaleUp(self): |
166 def scaleUp(self): |
141 """ |
167 """ |
142 Public method to zoom in. |
168 Public method to zoom in. |
143 """ |
169 """ |
144 if self.__zoomCount < 10: |
170 if self.__zoomCount < 10: |
208 Public method to handle wheel event to zoom. |
234 Public method to handle wheel event to zoom. |
209 |
235 |
210 @param evt reference to the event object |
236 @param evt reference to the event object |
211 @type QWheelEvent |
237 @type QWheelEvent |
212 """ |
238 """ |
|
239 delta = evt.angleDelta().y() |
213 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: |
240 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: |
214 if evt.angleDelta().y() > 0: |
241 if delta > 0: |
215 self.scaleUp() |
242 self.scaleUp() |
216 else: |
243 else: |
217 self.scaleDown() |
244 self.scaleDown() |
218 evt.accept() |
245 evt.accept() |
|
246 |
|
247 elif evt.modifiers() & Qt.KeyboardModifier.ShiftModifier: |
|
248 if delta < 0: |
|
249 self.backward() |
|
250 elif delta > 0: |
|
251 self.forward() |
|
252 evt.accept() |
|
253 |
219 else: |
254 else: |
220 QTextBrowser.wheelEvent(self, evt) |
255 QTextBrowser.wheelEvent(self, evt) |
221 |
256 |
222 def keyPressEvent(self, evt): |
257 def keyPressEvent(self, evt): |
223 """ |
258 """ |
285 pinch.setTotalScaleFactor(1.6) |
320 pinch.setTotalScaleFactor(1.6) |
286 self.setScale(zoom) |
321 self.setScale(zoom) |
287 evt.accept() |
322 evt.accept() |
288 |
323 |
289 # TODO: implement context menu |
324 # TODO: implement context menu |
|
325 # - Backward |
|
326 # - Forward |
|
327 # - Reload |
290 # - Open Link |
328 # - Open Link |
291 # - Open Link in New Page |
329 # - Open Link in New Page |
292 # - Open Link in Background Page |
330 # - Open Link in Background Page |
293 # - Copy |
331 # - Copy |
294 # - Copy Link LOcation |
332 # - Copy Link Location |
295 # - Select All |
333 # - Select All |
296 # TODO: add Ctrl+LMB action (open link in new page) |
334 # TODO: add Ctrl+LMB action (open link in new page) |