Added some more user agent strings to the web browser.

Thu, 02 Jun 2011 17:29:13 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 02 Jun 2011 17:29:13 +0200
changeset 1102
aae999261983
parent 1101
43da69edffc4
child 1104
029fde1585ed

Added some more user agent strings to the web browser.

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentMenu.html file | annotate | diff | comparison | revisions
Helpviewer/UserAgent/UserAgentDefaults.py file | annotate | diff | comparison | revisions
Helpviewer/UserAgent/UserAgentMenu.py file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentMenu.html	Thu Jun 02 12:28:58 2011 +0200
+++ b/Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentMenu.html	Thu Jun 02 17:29:13 2011 +0200
@@ -91,7 +91,12 @@
 <b>__addDefaultActions</b>(<i></i>)
 <p>
         Private slot to add the default user agent entries.
-</p><a NAME="UserAgentMenu.__changeUserAgent" ID="UserAgentMenu.__changeUserAgent"></a>
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating that a user agent entry is checked (boolean)
+</dd>
+</dl><a NAME="UserAgentMenu.__changeUserAgent" ID="UserAgentMenu.__changeUserAgent"></a>
 <h4>UserAgentMenu.__changeUserAgent</h4>
 <b>__changeUserAgent</b>(<i></i>)
 <p>
--- a/Helpviewer/UserAgent/UserAgentDefaults.py	Thu Jun 02 12:28:58 2011 +0200
+++ b/Helpviewer/UserAgent/UserAgentDefaults.py	Thu Jun 02 17:29:13 2011 +0200
@@ -9,27 +9,48 @@
 
 UserAgentDefaults = """
 <useragentswitcher>
-    <separator/>
-    <useragent description="Safari 4.0.4 (Mac)" useragent="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10"/>
-    <useragent description="Mobile Safari 3.1.2 (iPhone)" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16"/>
-    <useragent description="Mobile Safari 3.1.2 (iPod touch)" useragent="Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16"/>
+    <useragentmenu title="Firefox">
+        <useragent description="Firefox 4.0.1 (Windows)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"/>
+        <useragent description="Firefox 3.5.3 (Windows)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"/>
+    </useragentmenu>
 
-    <separator/>
-    <useragent description="Firefox 3.5.3 (Windows)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"/>
+    <useragentmenu title="Chrome">
+        <useragent description="Chrome 12.0 (Windows)" useragent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.0 Safari/534.30"/>
+        <useragent description="Chrome 11.0 (Windows)" useragent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"/>
+    </useragentmenu>
+
+    <useragentmenu title="Internet Explorer">
+        <useragent description="Internet Explorer 9.0" useragent="Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)"/>
+        <useragent description="Internet Explorer 8.0" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"/>
+        <useragent description="Internet Explorer 7.0" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"/>
+        <useragent description="Internet Explorer 6.0" useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"/>
+    </useragentmenu>
 
-    <separator/>
-    <useragent description="Internet Explorer 8.0" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"/>
-    <useragent description="Internet Explorer 7.0" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"/>
-    <useragent description="Internet Explorer 6.0" useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"/>
+    <useragentmenu title="Opera">
+        <useragent description="Opera 11.1 (Linux)" useragent="Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.8.131 Version/11.10"/>
+        <useragent description="Opera 11.1 (Mac)" useragent="Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; en) Presto/2.8.131 Version/11.10"/>
+        <useragent description="Opera 11.1 (Windows)" useragent="Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.10"/>
+        <useragent description="Opera 10.0 (Linux)" useragent="Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.2.15 Version/10.00"/>
+        <useragent description="Opera 10.0 (Mac)" useragent="Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00"/>
+        <useragent description="Opera 10.0 (Windows)" useragent="Opera/9.80 (Windows NT 6.0; U; en) Presto/2.2.15 Version/10.00"/>
+    </useragentmenu>
 
-    <separator/>
-    <useragent description="Opera 10.0 (Mac)" useragent="Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00"/>
-    <useragent description="Opera 10.0 (Windows)" useragent="Opera/9.80 (Windows NT 6.0; U; en) Presto/2.2.15 Version/10.00"/>
+    <useragentmenu title="Safari">
+        <useragent description="Safari 5.0.4 (Mac)" useragent="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"/>
+        <useragent description="Safari 4.0.4 (Mac)" useragent="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10"/>
+        <separator/>
+        <useragent description="Mobile Safari 4.3.2 (iPad)" useragent="Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"/>
+        <useragent description="Mobile Safari 4.3.2 (iPhone)" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"/>
+        <useragent description="Mobile Safari 4.3.2 (iPod touch)" useragent="Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"/>
+        <useragent description="Mobile Safari 3.1.2 (iPhone)" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16"/>
+        <useragent description="Mobile Safari 3.1.2 (iPod touch)" useragent="Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16"/>
+    </useragentmenu>
 
-    <separator/>
-    <useragent description="Googlebot 2.1" useragent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"/>
-    <useragent description="Msnbot 1.1" useragent="msnbot/1.1 (+http://search.msn.com/msnbot.htm)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
-    <useragent description="Yahoo Slurp" useragent="Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
+    <useragentmenu title="v_a_r_i_o_u_s">
+        <useragent description="Googlebot 2.1" useragent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"/>
+        <useragent description="Msnbot 1.1" useragent="msnbot/1.1 (+http://search.msn.com/msnbot.htm)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
+        <useragent description="Yahoo Slurp" useragent="Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
+    </useragentmenu>
 
 </useragentswitcher>
 """
--- a/Helpviewer/UserAgent/UserAgentMenu.py	Thu Jun 02 12:28:58 2011 +0200
+++ b/Helpviewer/UserAgent/UserAgentMenu.py	Thu Jun 02 17:29:13 2011 +0200
@@ -38,6 +38,8 @@
         """
         self.aboutToShow.disconnect(self.__populateMenu)
         
+        self.__actionGroup = QActionGroup(self)
+        
         # add default action
         self.__defaultUserAgent = QAction(self)
         self.__defaultUserAgent.setText(self.trUtf8("Default"))
@@ -45,9 +47,11 @@
         self.__defaultUserAgent.triggered[()].connect(self.__switchToDefaultUserAgent)
         self.__defaultUserAgent.setChecked(HelpWebPage().userAgent() == "")
         self.addAction(self.__defaultUserAgent)
+        self.__actionGroup.addAction(self.__defaultUserAgent)
+        isChecked = self.__defaultUserAgent.isChecked()
         
         # add default extra user agents
-        self.__addDefaultActions()
+        isChecked = self.__addDefaultActions() or isChecked
         
         # add other action
         self.addSeparator()
@@ -56,14 +60,8 @@
         self.__otherUserAgent.setCheckable(True)
         self.__otherUserAgent.triggered[()].connect(self.__switchToOtherUserAgent)
         self.addAction(self.__otherUserAgent)
-        
-        usingCustomUserAgent = True
-        actionGroup = QActionGroup(self)
-        for act in self.actions():
-            actionGroup.addAction(act)
-            if act.isChecked():
-                usingCustomUserAgent = False
-        self.__otherUserAgent.setChecked(usingCustomUserAgent)
+        self.__actionGroup.addAction(self.__otherUserAgent)
+        self.__otherUserAgent.setChecked(not isChecked)
     
     def __switchToDefaultUserAgent(self):
         """
@@ -94,7 +92,11 @@
     def __addDefaultActions(self):
         """
         Private slot to add the default user agent entries.
+        
+        @return flag indicating that a user agent entry is checked (boolean)
         """
+        menuStack = []
+        isChecked = False
         defaultUserAgents = QByteArray(UserAgentDefaults)
         
         currentUserAgentString = HelpWebPage().userAgent()
@@ -102,7 +104,10 @@
         while not xml.atEnd():
             xml.readNext()
             if xml.isStartElement() and xml.name() == "separator":
-                self.addSeparator()
+                if menuStack:
+                    menuStack[-1].addSeparator()
+                else:
+                    self.addSeparator()
                 continue
             
             if xml.isStartElement() and xml.name() == "useragent":
@@ -117,10 +122,31 @@
                 act.setCheckable(True)
                 act.setChecked(userAgent == currentUserAgentString)
                 act.triggered[()].connect(self.__changeUserAgent)
-                self.addAction(act)
+                if menuStack:
+                    menuStack[-1].addAction(act)
+                else:
+                    self.addAction(act)
+                self.__actionGroup.addAction(act)
+                isChecked = isChecked or act.isChecked()
+            
+            if xml.isStartElement() and xml.name() == "useragentmenu":
+                attributes = xml.attributes()
+                title = attributes.value("title")
+                if title == "v_a_r_i_o_u_s":
+                    title = self.trUtf8("Various")
+                
+                menu = QMenu(self)
+                menu.setTitle(title)
+                self.addMenu(menu)
+                menuStack.append(menu)
+            
+            if xml.isEndElement() and xml.name() == "useragentmenu":
+                menuStack.pop()
         
         if xml.hasError():
             E5MessageBox.critical(self,
                 self.trUtf8("Parsing default user agents"),
                 self.trUtf8("""<p>Error parsing default user agents.</p><p>{0}</p>""")\
                     .format(xml.errorString()))
+        
+        return isChecked
--- a/changelog	Thu Jun 02 12:28:58 2011 +0200
+++ b/changelog	Thu Jun 02 17:29:13 2011 +0200
@@ -11,7 +11,8 @@
 - added support for the Mercurial rebase extension
 - enhanced the Mercurial log browser dialog
 - added function to test the login data to the Email config page
-- added a puse button to the web browser download
+- added a pause button to the web browser download
+- added some more user agent strings to the web browser
 
 Version 5.2-snapshot-20110501:
 - bug fixes

eric ide

mercurial