Refined the toolbar menus of the main window.

Thu, 19 Feb 2015 19:39:19 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 19 Feb 2015 19:39:19 +0100
changeset 4117
40d4272b538a
parent 4116
2b39247e9cae
child 4118
3c9fa4b8869d

Refined the toolbar menus of the main window.

APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric6.UI.UserInterface.html file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric6.api	Mon Feb 16 19:52:14 2015 +0100
+++ b/APIs/Python3/eric6.api	Thu Feb 19 19:39:19 2015 +0100
@@ -8362,6 +8362,7 @@
 eric6.UI.UserInterface.UserInterface.checkPluginUpdatesAvailable?4()
 eric6.UI.UserInterface.UserInterface.checkProjectsWorkspace?4()
 eric6.UI.UserInterface.UserInterface.closeEvent?4(event)
+eric6.UI.UserInterface.UserInterface.createPopupMenu?4()
 eric6.UI.UserInterface.UserInterface.dragEnterEvent?4(event)
 eric6.UI.UserInterface.UserInterface.dragLeaveEvent?4(event)
 eric6.UI.UserInterface.UserInterface.dragMoveEvent?4(event)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Mon Feb 16 19:52:14 2015 +0100
+++ b/Documentation/Help/source.qhp	Thu Feb 19 19:39:19 2015 +0100
@@ -12083,6 +12083,7 @@
       <keyword name="UserInterface (Constructor)" id="UserInterface (Constructor)" ref="eric6.UI.UserInterface.html#UserInterface.__init__" />
       <keyword name="UserInterface (Module)" id="UserInterface (Module)" ref="eric6.UI.UserInterface.html" />
       <keyword name="UserInterface.__TBMenuTriggered" id="UserInterface.__TBMenuTriggered" ref="eric6.UI.UserInterface.html#UserInterface.__TBMenuTriggered" />
+      <keyword name="UserInterface.__TBPopupMenuTriggered" id="UserInterface.__TBPopupMenuTriggered" ref="eric6.UI.UserInterface.html#UserInterface.__TBPopupMenuTriggered" />
       <keyword name="UserInterface.__TRPreviewer" id="UserInterface.__TRPreviewer" ref="eric6.UI.UserInterface.html#UserInterface.__TRPreviewer" />
       <keyword name="UserInterface.__UIPreviewer" id="UserInterface.__UIPreviewer" ref="eric6.UI.UserInterface.html#UserInterface.__UIPreviewer" />
       <keyword name="UserInterface.__activateBrowser" id="UserInterface.__activateBrowser" ref="eric6.UI.UserInterface.html#UserInterface.__activateBrowser" />
@@ -12150,6 +12151,7 @@
       <keyword name="UserInterface.__openMiniEditor" id="UserInterface.__openMiniEditor" ref="eric6.UI.UserInterface.html#UserInterface.__openMiniEditor" />
       <keyword name="UserInterface.__openOnStartup" id="UserInterface.__openOnStartup" ref="eric6.UI.UserInterface.html#UserInterface.__openOnStartup" />
       <keyword name="UserInterface.__pluginsConfigure" id="UserInterface.__pluginsConfigure" ref="eric6.UI.UserInterface.html#UserInterface.__pluginsConfigure" />
+      <keyword name="UserInterface.__populateToolbarsMenu" id="UserInterface.__populateToolbarsMenu" ref="eric6.UI.UserInterface.html#UserInterface.__populateToolbarsMenu" />
       <keyword name="UserInterface.__preferencesChanged" id="UserInterface.__preferencesChanged" ref="eric6.UI.UserInterface.html#UserInterface.__preferencesChanged" />
       <keyword name="UserInterface.__processToolStderr" id="UserInterface.__processToolStderr" ref="eric6.UI.UserInterface.html#UserInterface.__processToolStderr" />
       <keyword name="UserInterface.__processToolStdout" id="UserInterface.__processToolStdout" ref="eric6.UI.UserInterface.html#UserInterface.__processToolStdout" />
@@ -12243,6 +12245,7 @@
       <keyword name="UserInterface.checkPluginUpdatesAvailable" id="UserInterface.checkPluginUpdatesAvailable" ref="eric6.UI.UserInterface.html#UserInterface.checkPluginUpdatesAvailable" />
       <keyword name="UserInterface.checkProjectsWorkspace" id="UserInterface.checkProjectsWorkspace" ref="eric6.UI.UserInterface.html#UserInterface.checkProjectsWorkspace" />
       <keyword name="UserInterface.closeEvent" id="UserInterface.closeEvent" ref="eric6.UI.UserInterface.html#UserInterface.closeEvent" />
+      <keyword name="UserInterface.createPopupMenu" id="UserInterface.createPopupMenu" ref="eric6.UI.UserInterface.html#UserInterface.createPopupMenu" />
       <keyword name="UserInterface.dragEnterEvent" id="UserInterface.dragEnterEvent" ref="eric6.UI.UserInterface.html#UserInterface.dragEnterEvent" />
       <keyword name="UserInterface.dragLeaveEvent" id="UserInterface.dragLeaveEvent" ref="eric6.UI.UserInterface.html#UserInterface.dragLeaveEvent" />
       <keyword name="UserInterface.dragMoveEvent" id="UserInterface.dragMoveEvent" ref="eric6.UI.UserInterface.html#UserInterface.dragMoveEvent" />
--- a/Documentation/Source/eric6.UI.UserInterface.html	Mon Feb 16 19:52:14 2015 +0100
+++ b/Documentation/Source/eric6.UI.UserInterface.html	Thu Feb 19 19:39:19 2015 +0100
@@ -183,7 +183,10 @@
 <td>Constructor</td>
 </tr><tr>
 <td><a href="#UserInterface.__TBMenuTriggered">__TBMenuTriggered</a></td>
-<td>Private method to handle the toggle of a toolbar.</td>
+<td>Private method to handle the toggle of a toolbar via the Window-> Toolbars submenu.</td>
+</tr><tr>
+<td><a href="#UserInterface.__TBPopupMenuTriggered">__TBPopupMenuTriggered</a></td>
+<td>Private method to handle the toggle of a toolbar via the QMainWindow Toolbars popup menu.</td>
 </tr><tr>
 <td><a href="#UserInterface.__TRPreviewer">__TRPreviewer</a></td>
 <td>Private slot to start the Translation Previewer executable.</td>
@@ -386,6 +389,9 @@
 <td><a href="#UserInterface.__pluginsConfigure">__pluginsConfigure</a></td>
 <td>Private slot to show the plugin manager configuration page.</td>
 </tr><tr>
+<td><a href="#UserInterface.__populateToolbarsMenu">__populateToolbarsMenu</a></td>
+<td>Private method to populate a toolbars menu.</td>
+</tr><tr>
 <td><a href="#UserInterface.__preferencesChanged">__preferencesChanged</a></td>
 <td>Private slot to handle a change of the preferences.</td>
 </tr><tr>
@@ -665,6 +671,9 @@
 <td><a href="#UserInterface.closeEvent">closeEvent</a></td>
 <td>Protected event handler for the close event.</td>
 </tr><tr>
+<td><a href="#UserInterface.createPopupMenu">createPopupMenu</a></td>
+<td>Public method to create the toolbars menu for Qt.</td>
+</tr><tr>
 <td><a href="#UserInterface.dragEnterEvent">dragEnterEvent</a></td>
 <td>Protected method to handle the drag enter event.</td>
 </tr><tr>
@@ -805,7 +814,19 @@
 <h4>UserInterface.__TBMenuTriggered</h4>
 <b>__TBMenuTriggered</b>(<i>act</i>)
 <p>
-        Private method to handle the toggle of a toolbar.
+        Private method to handle the toggle of a toolbar via the Window->
+        Toolbars submenu.
+</p><dl>
+<dt><i>act</i></dt>
+<dd>
+reference to the action that was triggered (QAction)
+</dd>
+</dl><a NAME="UserInterface.__TBPopupMenuTriggered" ID="UserInterface.__TBPopupMenuTriggered"></a>
+<h4>UserInterface.__TBPopupMenuTriggered</h4>
+<b>__TBPopupMenuTriggered</b>(<i>act</i>)
+<p>
+        Private method to handle the toggle of a toolbar via the QMainWindow
+        Toolbars popup menu.
 </p><dl>
 <dt><i>act</i></dt>
 <dd>
@@ -1290,7 +1311,17 @@
 <b>__pluginsConfigure</b>(<i></i>)
 <p>
         Private slot to show the plugin manager configuration page.
-</p><a NAME="UserInterface.__preferencesChanged" ID="UserInterface.__preferencesChanged"></a>
+</p><a NAME="UserInterface.__populateToolbarsMenu" ID="UserInterface.__populateToolbarsMenu"></a>
+<h4>UserInterface.__populateToolbarsMenu</h4>
+<b>__populateToolbarsMenu</b>(<i>menu</i>)
+<p>
+        Private method to populate a toolbars menu.
+</p><dl>
+<dt><i>menu</i></dt>
+<dd>
+reference to the menu to be populated (QMenu)
+</dd>
+</dl><a NAME="UserInterface.__preferencesChanged" ID="UserInterface.__preferencesChanged"></a>
 <h4>UserInterface.__preferencesChanged</h4>
 <b>__preferencesChanged</b>(<i></i>)
 <p>
@@ -1952,6 +1983,16 @@
 <dd>
 close event (QCloseEvent)
 </dd>
+</dl><a NAME="UserInterface.createPopupMenu" ID="UserInterface.createPopupMenu"></a>
+<h4>UserInterface.createPopupMenu</h4>
+<b>createPopupMenu</b>(<i></i>)
+<p>
+        Public method to create the toolbars menu for Qt.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+toolbars menu (QMenu)
+</dd>
 </dl><a NAME="UserInterface.dragEnterEvent" ID="UserInterface.dragEnterEvent"></a>
 <h4>UserInterface.dragEnterEvent</h4>
 <b>dragEnterEvent</b>(<i>event</i>)
--- a/UI/UserInterface.py	Mon Feb 16 19:52:14 2015 +0100
+++ b/UI/UserInterface.py	Thu Feb 19 19:39:19 2015 +0100
@@ -3438,52 +3438,97 @@
         """
         self.showMenu.emit("Subwindows", self.__menus["subwindow"])
         
-    def __showToolbarsMenu(self):
-        """
-        Private slot to display the Toolbars menu.
-        """
-        self.__menus["toolbars"].clear()
+    def __populateToolbarsMenu(self, menu):
+        """
+        Private method to populate a toolbars menu.
+        
+        @param menu reference to the menu to be populated (QMenu)
+        """
+        menu.clear()
         
         tbList = []
         for name, (text, tb) in list(self.__toolbars.items()):
             tbList.append((text, tb, name))
         
-        tbList.sort()
-        for text, tb, name in tbList:
-            act = self.__menus["toolbars"].addAction(text)
+        for text, tb, name in sorted(tbList):
+            act = menu.addAction(text)
             act.setCheckable(True)
-            act.setData(name)
             act.setChecked(not tb.isHidden())
-        self.__menus["toolbars"].addSeparator()
-        self.__toolbarsShowAllAct = \
-            self.__menus["toolbars"].addAction(self.tr("&Show all"))
-        self.__toolbarsHideAllAct = \
-            self.__menus["toolbars"].addAction(self.tr("&Hide all"))
+            act.setData(name)
+        menu.addSeparator()
+        act = menu.addAction(self.tr("&Show all"))
+        act.setData("__SHOW__")
+        act = menu.addAction(self.tr("&Hide all"))
+        act.setData("__HIDE__")
+        
+    def createPopupMenu(self):
+        """
+        Public method to create the toolbars menu for Qt.
+        
+        @return toolbars menu (QMenu)
+        """
+        menu = QMenu(self)
+        menu.triggered.connect(self.__TBPopupMenuTriggered)
+        
+        self.__populateToolbarsMenu(menu)
+        
+        return menu
+        
+    def __showToolbarsMenu(self):
+        """
+        Private slot to display the Toolbars menu.
+        """
+        self.__populateToolbarsMenu(self.__menus["toolbars"])
 
     def __TBMenuTriggered(self, act):
         """
-        Private method to handle the toggle of a toolbar.
+        Private method to handle the toggle of a toolbar via the Window->
+        Toolbars submenu.
         
         @param act reference to the action that was triggered (QAction)
         """
-        if act == self.__toolbarsShowAllAct:
-            for text, tb in list(self.__toolbars.values()):
-                tb.show()
-            if self.__menus["toolbars"].isTearOffMenuVisible():
-                self.__showToolbarsMenu()
-        elif act == self.__toolbarsHideAllAct:
-            for text, tb in list(self.__toolbars.values()):
-                tb.hide()
-            if self.__menus["toolbars"].isTearOffMenuVisible():
-                self.__showToolbarsMenu()
-        else:
-            name = act.data()
-            if name:
+        name = act.data()
+        if name:
+            if name == "__SHOW__":
+                for text, tb in list(self.__toolbars.values()):
+                    tb.show()
+                if self.__menus["toolbars"].isTearOffMenuVisible():
+                    self.__menus["toolbars"].hideTearOffMenu()
+            elif name == "__HIDE__":
+                for text, tb in list(self.__toolbars.values()):
+                    tb.hide()
+                if self.__menus["toolbars"].isTearOffMenuVisible():
+                    self.__menus["toolbars"].hideTearOffMenu()
+            else:
                 tb = self.__toolbars[name][1]
                 if act.isChecked():
                     tb.show()
                 else:
                     tb.hide()
+
+    def __TBPopupMenuTriggered(self, act):
+        """
+        Private method to handle the toggle of a toolbar via the QMainWindow
+        Toolbars popup menu.
+        
+        @param act reference to the action that was triggered (QAction)
+        """
+        name = act.data()
+        if name:
+            if name == "__SHOW__":
+                for text, tb in list(self.__toolbars.values()):
+                    tb.show()
+            elif name == "__HIDE__":
+                for text, tb in list(self.__toolbars.values()):
+                    tb.hide()
+            else:
+                tb = self.__toolbars[name][1]
+                if act.isChecked():
+                    tb.show()
+                else:
+                    tb.hide()
+            if self.__menus["toolbars"].isTearOffMenuVisible():
+                self.__menus["toolbars"].hideTearOffMenu()
         
     def __saveCurrentViewProfile(self, save):
         """

eric ide

mercurial