Helpviewer/HelpWindow.py

changeset 2192
61b3849df76d
parent 2149
bd0bbb3043df
child 2302
f29e9405c851
equal deleted inserted replaced
2191:7c7251ce9497 2192:61b3849df76d
64 from .data import javascript_rc # __IGNORE_WARNING__ 64 from .data import javascript_rc # __IGNORE_WARNING__
65 65
66 from E5Gui.E5Action import E5Action 66 from E5Gui.E5Action import E5Action
67 from E5Gui import E5MessageBox, E5FileDialog 67 from E5Gui import E5MessageBox, E5FileDialog
68 from E5Gui.E5MainWindow import E5MainWindow 68 from E5Gui.E5MainWindow import E5MainWindow
69 from E5Gui.E5Application import e5App
69 70
70 from E5Network.E5NetworkMonitor import E5NetworkMonitor 71 from E5Network.E5NetworkMonitor import E5NetworkMonitor
71 72
72 import Preferences 73 import Preferences
73 from Preferences import Shortcuts 74 from Preferences import Shortcuts
76 import Utilities 77 import Utilities
77 78
78 import UI.PixmapCache 79 import UI.PixmapCache
79 import UI.Config 80 import UI.Config
80 from UI.Info import Version 81 from UI.Info import Version
82 from UI.NotificationWidget import NotificationWidget
81 83
82 84
83 class HelpWindow(E5MainWindow): 85 class HelpWindow(E5MainWindow):
84 """ 86 """
85 Class implementing the web browser main window. 87 Class implementing the web browser main window.
93 privacyChanged = pyqtSignal(bool) 95 privacyChanged = pyqtSignal(bool)
94 96
95 helpwindows = [] 97 helpwindows = []
96 98
97 maxMenuFilePathLen = 75 99 maxMenuFilePathLen = 75
100
101 _fromEric = False
98 102
99 _networkAccessManager = None 103 _networkAccessManager = None
100 _cookieJar = None 104 _cookieJar = None
101 _helpEngine = None 105 _helpEngine = None
102 _bookmarksManager = None 106 _bookmarksManager = None
108 _userAgentsManager = None 112 _userAgentsManager = None
109 _syncManager = None 113 _syncManager = None
110 _speedDial = None 114 _speedDial = None
111 _personalInformationManager = None 115 _personalInformationManager = None
112 _greaseMonkeyManager = None 116 _greaseMonkeyManager = None
117 _notification = None
113 118
114 def __init__(self, home, path, parent, name, fromEric=False, 119 def __init__(self, home, path, parent, name, fromEric=False,
115 initShortcutsOnly=False, searchWord=None): 120 initShortcutsOnly=False, searchWord=None):
116 """ 121 """
117 Constructor 122 Constructor
128 super().__init__(parent) 133 super().__init__(parent)
129 self.setObjectName(name) 134 self.setObjectName(name)
130 self.setWindowTitle(self.trUtf8("eric5 Web Browser")) 135 self.setWindowTitle(self.trUtf8("eric5 Web Browser"))
131 136
132 self.fromEric = fromEric 137 self.fromEric = fromEric
138 self.__class__._fromEric = fromEric
133 self.initShortcutsOnly = initShortcutsOnly 139 self.initShortcutsOnly = initShortcutsOnly
134 self.setWindowIcon(UI.PixmapCache.getIcon("ericWeb.png")) 140 self.setWindowIcon(UI.PixmapCache.getIcon("ericWeb.png"))
135 141
136 self.mHistory = [] 142 self.mHistory = []
137 self.__lastConfigurationPageName = "" 143 self.__lastConfigurationPageName = ""
3293 3299
3294 encodedStyle = bytes(QByteArray(userStyle).toBase64()).decode() 3300 encodedStyle = bytes(QByteArray(userStyle).toBase64()).decode()
3295 dataString = "data:text/css;charset=utf-8;base64,{0}".format(encodedStyle) 3301 dataString = "data:text/css;charset=utf-8;base64,{0}".format(encodedStyle)
3296 3302
3297 return QUrl(dataString) 3303 return QUrl(dataString)
3304
3305 ##########################################
3306 ## Support for desktop notifications below
3307 ##########################################
3308
3309 @classmethod
3310 def showNotification(cls, icon, heading, text):
3311 """
3312 Clsss method to show a desktop notification.
3313
3314 @param icon icon to be shown in the notification (QPixmap)
3315 @param heading heading of the notification (string)
3316 @param text text of the notification (string)
3317 """
3318 if cls._fromEric:
3319 e5App().getObject("UserInterface").showNotification(icon, heading, text)
3320 else:
3321 if Preferences.getUI("NotificationsEnabled"):
3322 if cls._notification is None:
3323 cls._notification = NotificationWidget()
3324 cls._notification.setPixmap(icon)
3325 cls._notification.setHeading(heading)
3326 cls._notification.setText(text)
3327 cls._notification.setTimeout(Preferences.getUI("NotificationTimeout"))
3328 cls._notification.move(Preferences.getUI("NotificationPosition"))
3329 cls._notification.show()
3330
3331 @classmethod
3332 def notificationsEnabled(cls):
3333 """
3334 Clsss method to check, if notifications are enabled.
3335
3336 @return flag indicating, if notifications are enabled (boolean)
3337 """
3338 if cls._fromEric:
3339 return e5App().getObject("UserInterface").notificationsEnabled
3340 else:
3341 return Preferences.getUI("NotificationsEnabled")

eric ide

mercurial