Helpviewer/UserAgent/UserAgentMenu.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3020
542e97d4ecb3
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
7 Module implementing a menu to select the user agent string. 7 Module implementing a menu to select the user agent string.
8 """ 8 """
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11 11
12 from PyQt4.QtCore import QByteArray, QXmlStreamReader 12 from PyQt4.QtCore import QXmlStreamReader, QFile, QIODevice
13 from PyQt4.QtGui import QMenu, QAction, QActionGroup, QInputDialog, QLineEdit 13 from PyQt4.QtGui import QMenu, QAction, QActionGroup, QInputDialog, QLineEdit
14 14
15 from E5Gui import E5MessageBox 15 from E5Gui import E5MessageBox
16 16
17 17
121 """ 121 """
122 Private slot to add the default user agent entries. 122 Private slot to add the default user agent entries.
123 123
124 @return flag indicating that a user agent entry is checked (boolean) 124 @return flag indicating that a user agent entry is checked (boolean)
125 """ 125 """
126 from .UserAgentDefaults import UserAgentDefaults 126 from . import UserAgentDefaults_rc # __IGNORE_WARNING__
127 defaultUserAgents = QFile(":/UserAgentDefaults.xml")
128 defaultUserAgents.open(QIODevice.ReadOnly)
129
127 menuStack = [] 130 menuStack = []
128 isChecked = False 131 isChecked = False
129 defaultUserAgents = QByteArray(UserAgentDefaults)
130 132
131 if self.__url: 133 if self.__url:
132 currentUserAgentString = self.__manager.userAgentForUrl(self.__url) 134 currentUserAgentString = self.__manager.userAgentForUrl(self.__url)
133 else: 135 else:
134 from Helpviewer.HelpBrowserWV import HelpWebPage 136 from Helpviewer.HelpBrowserWV import HelpWebPage
175 177
176 if xml.isEndElement() and xml.name() == "useragentmenu": 178 if xml.isEndElement() and xml.name() == "useragentmenu":
177 menuStack.pop() 179 menuStack.pop()
178 180
179 if xml.hasError(): 181 if xml.hasError():
180 E5MessageBox.critical(self, 182 E5MessageBox.critical(
183 self,
181 self.trUtf8("Parsing default user agents"), 184 self.trUtf8("Parsing default user agents"),
182 self.trUtf8( 185 self.trUtf8(
183 """<p>Error parsing default user agents.</p><p>{0}</p>""") 186 """<p>Error parsing default user agents.</p><p>{0}</p>""")
184 .format(xml.errorString())) 187 .format(xml.errorString()))
185 188

eric ide

mercurial