Sat, 22 May 2021 18:51:46 +0200
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
4962
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
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) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
4962
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the status bar icon base class. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | # |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | # This is modelled after the code found in Qupzilla |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | # Copyright (C) 2014 David Rosca <nowrep@gmail.com> |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | # |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
15 | from E5Gui.EricClickableLabel import EricClickableLabel |
4962
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
18 | class StatusBarIcon(EricClickableLabel): |
4962
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Class implementing common methods for all status bar icons. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | def __init__(self, window): |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Constructor |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | @param window reference to the web browser window |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @type WebBrowserWindow |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
29 | super().__init__(window) |
4962
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self._window = window |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | def _testCurrentPageWebAttribute(self, attr): |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Protected method to test a web attribute on the current page. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @param attr attribute to test |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @type QWebEngineSettings.WebAttribute |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @return flag indicating the attribute is set |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @rtype bool |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | settings = self._currentPageSettings() |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | return settings is not None and settings.testAttribute(attr) |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | def _setCurrentPageWebAttribute(self, attr, val): |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Protected method to set a web attribute on the current page. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @param attr attribute to sett |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @type QWebEngineSettings.WebAttribute |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @param val value to be set |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @type bool |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | settings = self._currentPageSettings() |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | if settings is not None: |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | settings.setAttribute(attr, val) |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | def _currentPageSettings(self): |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | Protected method to get a reference to the web settings of the |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | current page. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @return reference to the web settings object |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | @rtype QWebEngineSettings |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | view = self._window.currentBrowser() |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | if view is None: |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | return None |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | return view.page().settings() |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | def _currentPage(self): |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | Protected method to get a reference to the current page. |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | @return reference to the current page |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | @rtype WebBrowserPage |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | view = self._window.currentBrowser() |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | if view is None: |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | return None |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | |
b602ac3fe532
Started implementing the status bar icons for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | return view.page() |
4964
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
84 | |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
85 | def preferencesChanged(self): |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
86 | """ |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
87 | Public method to handle changes of the settings. |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
88 | """ |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
89 | # do nothing |
a894e8c92369
Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4962
diff
changeset
|
90 | pass |