eric6/UI/UserInterface.py

branch
multi_processing
changeset 7802
eefe954f01e8
parent 7646
39e3db2b4936
parent 7785
9978016560ec
child 7818
5c9271c2f662
--- a/eric6/UI/UserInterface.py	Sun Jul 05 11:11:24 2020 +0200
+++ b/eric6/UI/UserInterface.py	Sun Oct 18 12:35:30 2020 +0200
@@ -7,7 +7,6 @@
 Module implementing the main user interface.
 """
 
-
 import os
 import sys
 import logging
@@ -436,6 +435,8 @@
         self.debuggerUI.executeMake.connect(self.project.executeMake)
         self.debuggerUI.appendStdout.connect(self.appendToStdout)
         
+        debugServer.clientDisassembly.connect(
+            self.debugViewer.disassemblyViewer.showDisassembly)
         debugServer.clientProcessStdout.connect(self.appendToStdout)
         debugServer.clientProcessStderr.connect(self.appendToStderr)
         debugServer.appendStdout.connect(self.appendToStdout)
@@ -474,6 +475,8 @@
         self.preferencesChanged.connect(
             self.backgroundService.preferencesOrProjectChanged)
         self.preferencesChanged.connect(self.__previewer.preferencesChanged)
+        self.preferencesChanged.connect(self.__astViewer.preferencesChanged)
+        self.preferencesChanged.connect(self.__disViewer.preferencesChanged)
         
         if self.browser is not None:
             self.browser.sourceFile[str].connect(
@@ -676,6 +679,15 @@
         splash.showMessage(self.tr("Setting View Profile..."))
         self.__setEditProfile()
         
+        # special treatment for the VCS toolbars
+        for tb in self.getToolbarsByCategory("vcs"):
+            tb.setVisible(False)
+            tb.setEnabled(False)
+        tb = self.getToolbar("vcs")[1]
+        tb.setEnabled(True)
+        if Preferences.getVCS("ShowVcsToolbar"):
+            tb.setVisible(True)
+        
         # now read the saved tasks
         splash.showMessage(self.tr("Reading Tasks..."))
         self.__readTasks()
@@ -769,6 +781,12 @@
         self.__astViewer = PythonAstViewer(self.viewmanager, splitter)
         splitter.addWidget(self.__astViewer)
         
+        # Create DIS viewer
+        logging.debug("Creating Python Disassembly Viewer")
+        from .PythonDisViewer import PythonDisViewer
+        self.__disViewer = PythonDisViewer(self.viewmanager, parent=splitter)
+        splitter.addWidget(self.__disViewer)
+        
         # Create layout with toolbox windows embedded in dock windows
         if self.__layoutType == "Toolboxes":
             logging.debug("Creating toolboxes...")
@@ -3287,27 +3305,31 @@
 
         # just add new toolbars to the end of the list
         self.__toolbars = {}
-        self.__toolbars["file"] = [filetb.windowTitle(), filetb]
-        self.__toolbars["edit"] = [edittb.windowTitle(), edittb]
-        self.__toolbars["search"] = [searchtb.windowTitle(), searchtb]
-        self.__toolbars["view"] = [viewtb.windowTitle(), viewtb]
-        self.__toolbars["start"] = [starttb.windowTitle(), starttb]
-        self.__toolbars["debug"] = [debugtb.windowTitle(), debugtb]
-        self.__toolbars["project"] = [projecttb.windowTitle(), projecttb]
-        self.__toolbars["tools"] = [toolstb.windowTitle(), toolstb]
-        self.__toolbars["help"] = [helptb.windowTitle(), helptb]
-        self.__toolbars["settings"] = [settingstb.windowTitle(), settingstb]
-        self.__toolbars["bookmarks"] = [bookmarktb.windowTitle(), bookmarktb]
-        self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb]
+        self.__toolbars["file"] = [filetb.windowTitle(), filetb, ""]
+        self.__toolbars["edit"] = [edittb.windowTitle(), edittb, ""]
+        self.__toolbars["search"] = [searchtb.windowTitle(), searchtb, ""]
+        self.__toolbars["view"] = [viewtb.windowTitle(), viewtb, ""]
+        self.__toolbars["start"] = [starttb.windowTitle(), starttb, ""]
+        self.__toolbars["debug"] = [debugtb.windowTitle(), debugtb, ""]
+        self.__toolbars["project"] = [projecttb.windowTitle(), projecttb, ""]
+        self.__toolbars["tools"] = [toolstb.windowTitle(), toolstb, ""]
+        self.__toolbars["help"] = [helptb.windowTitle(), helptb, ""]
+        self.__toolbars["settings"] = [settingstb.windowTitle(), settingstb,
+                                       ""]
+        self.__toolbars["bookmarks"] = [bookmarktb.windowTitle(), bookmarktb,
+                                        ""]
+        self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb,
+                                       ""]
         self.__toolbars["view_profiles"] = [profilestb.windowTitle(),
-                                            profilestb]
-        self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb]
+                                            profilestb, ""]
+        self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb, ""]
         self.__toolbars["quicksearch"] = [quicksearchtb.windowTitle(),
-                                          quicksearchtb]
+                                          quicksearchtb, ""]
         self.__toolbars["multiproject"] = [multiprojecttb.windowTitle(),
-                                           multiprojecttb]
-        self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb]
-        self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb]
+                                           multiprojecttb, ""]
+        self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb,
+                                       ""]
+        self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb, "vcs"]
         
     def __initDebugToolbarsLayout(self):
         """
@@ -3658,13 +3680,12 @@
             address = BugAddress
         subject = "[eric6] "
         if attachFile is not None:
-            f = open(attachFile, "r", encoding="utf-8")
-            body = f.read()
-            f.close()
+            with open(attachFile, "r", encoding="utf-8") as f:
+                body = f.read()
             if deleteAttachFile:
                 os.remove(attachFile)
         else:
-            body = "\r\n----\r\n{0}----\r\n{1}----\r\n{2}".format(
+            body = "\r\n----\r\n{0}\r\n----\r\n{1}\r\n----\r\n{2}".format(
                 Utilities.generateVersionInfo("\r\n"),
                 Utilities.generatePluginsVersionInfo("\r\n"),
                 Utilities.generateDistroInfo("\r\n"))
@@ -3687,7 +3708,7 @@
             if os.path.exists(logFile):
                 from .ErrorLogDialog import ErrorLogDialog
                 dlg = ErrorLogDialog(logFile, False, self)
-                dlg.exec_()
+                dlg.exec()
         
     def __hasErrorLog(self):
         """
@@ -3831,34 +3852,44 @@
         except KeyError:
             return None
         
-    def registerToolbar(self, name, text, toolbar):
+    def registerToolbar(self, name, text, toolbar, category=""):
         """
         Public method to register a toolbar.
         
         This method must be called in order to make a toolbar manageable by the
         UserInterface object.
         
-        @param name name of the toolbar (string). This is used as the key into
+        @param name name of the toolbar. This is used as the key into
             the dictionary of toolbar references.
-        @param text user visible text for the toolbar entry (string)
-        @param toolbar reference to the toolbar to be registered (QToolBar)
+        @type str
+        @param text user visible text for the toolbar entry
+        @type str
+        @param toolbar reference to the toolbar to be registered
+        @type QToolBar
+        @param category toolbar category
+        @type str
         @exception KeyError raised, if a toolbar with the given name was
             already registered
         """
         if name in self.__toolbars:
             raise KeyError("Toolbar '{0}' already registered.".format(name))
         
-        self.__toolbars[name] = [text, toolbar]
-        
-    def reregisterToolbar(self, name, text):
+        self.__toolbars[name] = [text, toolbar, category]
+        
+    def reregisterToolbar(self, name, text, category=""):
         """
         Public method to change the visible text for the named toolbar.
         
-        @param name name of the toolbar to be changed (string)
-        @param text new user visible text for the toolbar entry (string)
+        @param name name of the toolbar to be changed
+        @type str
+        @param text new user visible text for the toolbar entry
+        @type str
+        @param category new toolbar category for the toolbar entry
+        @type str
         """
         if name in self.__toolbars:
             self.__toolbars[name][0] = text
+            self.__toolbars[name][2] = category
         
     def unregisterToolbar(self, name):
         """
@@ -3880,7 +3911,28 @@
             return self.__toolbars[name]
         except KeyError:
             return None
-        
+    
+    def getToolbarsByCategory(self, category):
+        """
+        Public method to get a list of toolbars belonging to a given toolbar
+        category.
+        
+        @param category toolbar category
+        @type str
+        @return list of toolbars
+        @rtype list of QToolBar
+        """
+        toolbars = []
+        for tbName in self.__toolbars:
+            try:
+                if self.__toolbars[tbName][2] == category:
+                    toolbars.append(self.__toolbars[tbName][1])
+            except IndexError:
+                # backward compatibility; category is not yet supported
+                pass
+        
+        return toolbars
+    
     def getLocale(self):
         """
         Public method to get the locale of the IDE.
@@ -4099,8 +4151,9 @@
         """
         menu.clear()
         
-        for name, (text, tb) in sorted(self.__toolbars.items(),
-                                       key=lambda t: t[1][0]):
+        for name, (text, tb, _category) in sorted(
+            self.__toolbars.items(), key=lambda t: t[1][0]
+        ):
             act = menu.addAction(text)
             act.setCheckable(True)
             act.setChecked(not tb.isHidden())
@@ -4140,12 +4193,12 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, _category in self.__toolbars.values():
                     tb.show()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
             elif name == "__HIDE__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, _category in self.__toolbars.values():
                     tb.hide()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
@@ -4153,6 +4206,7 @@
                 tb = self.__toolbars[name][1]
                 if act.isChecked():
                     tb.show()
+                    tb.setEnabled(True)
                 else:
                     tb.hide()
 
@@ -4166,15 +4220,16 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, _category in self.__toolbars.values():
                     tb.show()
             elif name == "__HIDE__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, _category in self.__toolbars.values():
                     tb.hide()
             else:
                 tb = self.__toolbars[name][1]
                 if act.isChecked():
                     tb.show()
+                    tb.setEnabled(True)
                 else:
                     tb.hide()
             if self.__menus["toolbars"].isTearOffMenuVisible():
@@ -4688,7 +4743,7 @@
         from Preferences.ToolConfigurationDialog import ToolConfigurationDialog
         dlg = ToolConfigurationDialog(
             self.toolGroups[self.currentToolGroup][1], self)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             self.toolGroups[self.currentToolGroup][1] = dlg.getToollist()
             self.__updateExternalToolsActions()
         
@@ -4701,7 +4756,7 @@
         )
         dlg = ToolGroupConfigurationDialog(
             self.toolGroups, self.currentToolGroup, self)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             self.toolGroups, self.currentToolGroup = dlg.getToolGroups()
         
     def __createUnitTestDialog(self):
@@ -5879,7 +5934,7 @@
                     self.__lastConfigurationPageName)
             else:
                 self.__configurationDialog.showConfigurationPageByName("empty")
-            self.__configurationDialog.exec_()
+            self.__configurationDialog.exec()
             QApplication.processEvents()
             if self.__configurationDialog.result() == QDialog.Accepted:
                 self.__configurationDialog.setPreferences()
@@ -6020,7 +6075,7 @@
         from Preferences.ViewProfileDialog import ViewProfileDialog
         dlg = ViewProfileDialog(self.__layoutType, self.profiles['edit'][1],
                                 self.profiles['debug'][1])
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             edit, debug = dlg.getVisibilities()
             self.profiles['edit'][1] = edit
             self.profiles['debug'][1] = debug
@@ -6036,7 +6091,7 @@
         """
         from E5Gui.E5ToolBarDialog import E5ToolBarDialog
         dlg = E5ToolBarDialog(self.toolbarManager)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             Preferences.setUI(
                 "ToolbarManagerState", self.toolbarManager.saveState())
         
@@ -6095,7 +6150,7 @@
         from E5Network.E5SslCertificatesDialog import E5SslCertificatesDialog
         
         dlg = E5SslCertificatesDialog(self)
-        dlg.exec_()
+        dlg.exec()
         
     def __clearPrivateData(self):
         """
@@ -6103,7 +6158,7 @@
         """
         from .ClearPrivateDataDialog import ClearPrivateDataDialog
         dlg = ClearPrivateDataDialog(self)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             # recent files, recent projects, recent multi  projects,
             # debug histories, shell histories
             (files, projects, multiProjects, debug, shell, vcs, plugins) = (
@@ -6560,7 +6615,7 @@
             self.pluginManager,
             [] if pluginFileNames is None else pluginFileNames[:],
             self)
-        dlg.exec_()
+        dlg.exec()
         if dlg.restartNeeded():
             self.__restart(ask=True)
         
@@ -6570,7 +6625,7 @@
         """
         from PluginManager.PluginUninstallDialog import PluginUninstallDialog
         dlg = PluginUninstallDialog(self.pluginManager, self)
-        dlg.exec_()
+        dlg.exec()
         
     def showPluginsAvailable(self):
         """
@@ -6578,7 +6633,7 @@
         """
         from PluginManager.PluginRepositoryDialog import PluginRepositoryDialog
         dlg = PluginRepositoryDialog(self.pluginManager, self)
-        res = dlg.exec_()
+        res = dlg.exec()
         if res == (QDialog.Accepted + 1):
             self.__installPlugins(dlg.getDownloadedPlugins())
         

eric ide

mercurial