--- a/UI/UserInterface.py Sat Jul 07 12:01:23 2018 +0200 +++ b/UI/UserInterface.py Wed Aug 01 19:43:34 2018 +0200 @@ -209,8 +209,7 @@ self.__disableCrashSession = disableCrashSession self.__disabledPlugins = disabledPlugins[:] - self.layoutType, self.embeddedShell, self.embeddedFileBrowser = \ - Preferences.getUILayout() + self.__layoutType = Preferences.getUI("LayoutType") self.passiveMode = Preferences.getDebugger("PassiveDbgEnabled") @@ -268,6 +267,14 @@ splash.showMessage(self.tr("Generating Main User Interface...")) + self.codeDocumentationViewer = None + self.cooperation = None + self.irc = None + self.symbolsViewer = None + self.browser = None + self.templateViewer = None + self.numbersViewer = None + # Create the main window now so that we can connect QActions to it. logging.debug("Creating Layout...") self.__createLayout(debugServer) @@ -301,25 +308,6 @@ # now setup the connections splash.showMessage(self.tr("Setting up connections...")) - self.browser.sourceFile[str].connect( - self.viewmanager.openSourceFile) - self.browser.sourceFile[str, int].connect( - self.viewmanager.openSourceFile) - self.browser.sourceFile[str, list].connect( - self.viewmanager.openSourceFile) - self.browser.sourceFile[str, int, str].connect( - self.viewmanager.openSourceFile) - self.browser.designerFile.connect(self.__designer) - self.browser.linguistFile.connect(self.__linguist4) - self.browser.projectFile.connect(self.project.openProject) - self.browser.multiProjectFile.connect( - self.multiProject.openMultiProject) - self.browser.pixmapEditFile.connect(self.__editPixmap) - self.browser.pixmapFile.connect(self.__showPixmap) - self.browser.svgFile.connect(self.__showSvg) - self.browser.binaryFile.connect(self.__openHexEditor) - self.browser.unittestOpen.connect(self.__unittestScript) - self.browser.trpreview.connect(self.__TRPreviewer) self.debugViewer.exceptionLogger.sourceFile.connect( self.viewmanager.openSourceFile) @@ -426,8 +414,6 @@ self.debuggerUI.resetUI.connect(self.debugViewer.handleResetUI) self.debuggerUI.resetUI.connect(self.__debuggingDone) self.debuggerUI.debuggingStarted.connect( - self.browser.handleProgramChange) - self.debuggerUI.debuggingStarted.connect( self.debugViewer.exceptionLogger.debuggingStarted) self.debuggerUI.debuggingStarted.connect( self.debugViewer.handleDebuggingStarted) @@ -450,8 +436,6 @@ self.debugViewer.breakpointViewer.highlightBreakpoint) debugServer.clientProcessStdout.connect(self.appendToStdout) debugServer.clientProcessStderr.connect(self.appendToStderr) - debugServer.clientInterpreterChanged.connect( - self.browser.handleInterpreterChanged) debugServer.appendStdout.connect(self.appendToStdout) self.stdout.appendStdout.connect(self.appendToStdout) @@ -480,17 +464,47 @@ self.projectBrowser.ppBrowser.handlePreferencesChanged) self.preferencesChanged.connect( self.projectBrowser.poBrowser.handlePreferencesChanged) - self.preferencesChanged.connect(self.browser.handlePreferencesChanged) self.preferencesChanged.connect( self.taskViewer.handlePreferencesChanged) self.preferencesChanged.connect(self.pluginManager.preferencesChanged) self.preferencesChanged.connect(debugServer.preferencesChanged) self.preferencesChanged.connect(self.debugViewer.preferencesChanged) - self.preferencesChanged.connect(self.cooperation.preferencesChanged) self.preferencesChanged.connect( self.backgroundService.preferencesOrProjectChanged) - self.preferencesChanged.connect( - self.codeDocumentationViewer.preferencesChanged) + + if self.browser is not None: + self.browser.sourceFile[str].connect( + self.viewmanager.openSourceFile) + self.browser.sourceFile[str, int].connect( + self.viewmanager.openSourceFile) + self.browser.sourceFile[str, list].connect( + self.viewmanager.openSourceFile) + self.browser.sourceFile[str, int, str].connect( + self.viewmanager.openSourceFile) + self.browser.designerFile.connect(self.__designer) + self.browser.linguistFile.connect(self.__linguist4) + self.browser.projectFile.connect(self.project.openProject) + self.browser.multiProjectFile.connect( + self.multiProject.openMultiProject) + self.browser.pixmapEditFile.connect(self.__editPixmap) + self.browser.pixmapFile.connect(self.__showPixmap) + self.browser.svgFile.connect(self.__showSvg) + self.browser.binaryFile.connect(self.__openHexEditor) + self.browser.unittestOpen.connect(self.__unittestScript) + self.browser.trpreview.connect(self.__TRPreviewer) + + self.debuggerUI.debuggingStarted.connect( + self.browser.handleProgramChange) + + debugServer.clientInterpreterChanged.connect( + self.browser.handleInterpreterChanged) + + self.preferencesChanged.connect( + self.browser.handlePreferencesChanged) + + if self.codeDocumentationViewer is not None: + self.preferencesChanged.connect( + self.codeDocumentationViewer.preferencesChanged) self.viewmanager.editorSaved.connect(self.project.repopulateItem) self.viewmanager.lastEditorClosed.connect(self.__lastEditorClosed) @@ -501,8 +515,6 @@ self.projectBrowser.handleEditorChanged) self.viewmanager.editorLineChanged.connect( self.projectBrowser.handleEditorLineChanged) - self.viewmanager.checkActions.connect( - self.cooperation.checkEditorActions) self.viewmanager.editorOpened.connect(self.__writeCrashSession) self.viewmanager.editorClosed.connect(self.__writeCrashSession) self.viewmanager.editorRenamed.connect(self.__writeCrashSession) @@ -511,19 +523,36 @@ self.shell.zoomValueChanged.connect( lambda v: self.viewmanager.zoomValueChanged(v, self.shell)) - self.cooperation.shareEditor.connect(self.viewmanager.shareEditor) - self.cooperation.startEdit.connect(self.viewmanager.startSharedEdit) - self.cooperation.sendEdit.connect(self.viewmanager.sendSharedEdit) - self.cooperation.cancelEdit.connect(self.viewmanager.cancelSharedEdit) - self.cooperation.connected.connect(self.viewmanager.shareConnected) - self.cooperation.editorCommand.connect(self.viewmanager.receive) - self.viewmanager.setCooperationClient(self.cooperation.getClient()) - - self.symbolsViewer.insertSymbol.connect(self.viewmanager.insertSymbol) - - self.numbersViewer.insertNumber.connect(self.viewmanager.insertNumber) - - self.irc.autoConnected.connect(self.__ircAutoConnected) + if self.cooperation is not None: + self.viewmanager.checkActions.connect( + self.cooperation.checkEditorActions) + self.preferencesChanged.connect( + self.cooperation.preferencesChanged) + self.cooperation.shareEditor.connect( + self.viewmanager.shareEditor) + self.cooperation.startEdit.connect( + self.viewmanager.startSharedEdit) + self.cooperation.sendEdit.connect( + self.viewmanager.sendSharedEdit) + self.cooperation.cancelEdit.connect( + self.viewmanager.cancelSharedEdit) + self.cooperation.connected.connect( + self.viewmanager.shareConnected) + self.cooperation.editorCommand.connect( + self.viewmanager.receive) + self.viewmanager.setCooperationClient( + self.cooperation.getClient()) + + if self.symbolsViewer is not None: + self.symbolsViewer.insertSymbol.connect( + self.viewmanager.insertSymbol) + + if self.numbersViewer is not None: + self.numbersViewer.insertNumber.connect( + self.viewmanager.insertNumber) + + if self.irc is not None: + self.irc.autoConnected.connect(self.__ircAutoConnected) # create the toolbar manager object self.toolbarManager = E5ToolBarManager(self, self) @@ -563,17 +592,23 @@ e5App().registerObject("ProjectBrowser", self.projectBrowser) e5App().registerObject("MultiProject", self.multiProject) e5App().registerObject("TaskViewer", self.taskViewer) - e5App().registerObject("TemplateViewer", self.templateViewer) + if self.templateViewer is not None: + e5App().registerObject("TemplateViewer", self.templateViewer) e5App().registerObject("Shell", self.shell) if self.dummyHelpViewer is not None: e5App().registerObject("DummyHelpViewer", self.dummyHelpViewer) e5App().registerObject("PluginManager", self.pluginManager) e5App().registerObject("ToolbarManager", self.toolbarManager) - e5App().registerObject("Cooperation", self.cooperation) - e5App().registerObject("IRC", self.irc) - e5App().registerObject("Symbols", self.symbolsViewer) - e5App().registerObject("Numbers", self.numbersViewer) - e5App().registerObject("DocuViewer", self.codeDocumentationViewer) + if self.cooperation is not None: + e5App().registerObject("Cooperation", self.cooperation) + if self.irc is not None: + e5App().registerObject("IRC", self.irc) + if self.symbolsViewer is not None: + e5App().registerObject("Symbols", self.symbolsViewer) + if self.numbersViewer is not None: + e5App().registerObject("Numbers", self.numbersViewer) + if self.codeDocumentationViewer is not None: + e5App().registerObject("DocuViewer", self.codeDocumentationViewer) # list of web addresses serving the versions file self.__httpAlternatives = Preferences.getUI("VersionsUrls6") @@ -642,8 +677,9 @@ self.toolbarManager.restoreState( Preferences.getUI("ToolbarManagerState")) - # finalize the initialization of the code documentation viewer - self.codeDocumentationViewer.finalizeSetup() + if self.codeDocumentationViewer is not None: + # finalize the initialization of the code documentation viewer + self.codeDocumentationViewer.finalizeSetup() # now activate the initial view profile splash.showMessage(self.tr("Setting View Profile...")) @@ -653,9 +689,10 @@ splash.showMessage(self.tr("Reading Tasks...")) self.__readTasks() - # now read the saved templates - splash.showMessage(self.tr("Reading Templates...")) - self.templateViewer.readTemplates() + if self.templateViewer is not None: + # now read the saved templates + splash.showMessage(self.tr("Reading Templates...")) + self.templateViewer.readTemplates() # now start the debug client splash.showMessage(self.tr("Starting Debugger...")) @@ -724,18 +761,18 @@ splitter.addWidget(self.__previewer) # Create layout with toolbox windows embedded in dock windows - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": logging.debug("Creating toolboxes...") self.__createToolboxesLayout(debugServer) # Create layout with sidebar windows embedded in dock windows - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": logging.debug("Creating sidebars...") self.__createSidebarsLayout(debugServer) else: raise ValueError("Wrong layout type given ({0})".format( - self.layoutType)) + self.__layoutType)) logging.debug("Created Layout") def __createToolboxesLayout(self, debugServer): @@ -770,9 +807,7 @@ # Create the project browser logging.debug("Creating Project Browser...") from Project.ProjectBrowser import ProjectBrowser - self.projectBrowser = ProjectBrowser( - self.project, None, - embeddedBrowser=(self.embeddedFileBrowser == 2)) + self.projectBrowser = ProjectBrowser(self.project) self.lToolbox.addItem(self.projectBrowser, UI.PixmapCache.getIcon("projectViewer.png"), self.tr("Project-Viewer")) @@ -785,50 +820,51 @@ self.lToolbox.addItem(self.multiProjectBrowser, UI.PixmapCache.getIcon("multiProjectViewer.png"), self.tr("Multiproject-Viewer")) - - # Create the template viewer part of the user interface - logging.debug("Creating Template Viewer...") - from Templates.TemplateViewer import TemplateViewer - self.templateViewer = TemplateViewer(None, - self.viewmanager) - self.lToolbox.addItem(self.templateViewer, - UI.PixmapCache.getIcon("templateViewer.png"), - self.tr("Template-Viewer")) - - # Create the code documentation viewer - logging.debug("Creating Code Documentation Viewer...") - from .CodeDocumentationViewer import CodeDocumentationViewer - self.codeDocumentationViewer = CodeDocumentationViewer(self) - self.rToolbox.addItem(self.codeDocumentationViewer, - UI.PixmapCache.getIcon("codeDocuViewer.png"), - self.tr("Code Documentation Viewer")) + + if Preferences.getUI("ShowTemplateViewer"): + # Create the template viewer part of the user interface + logging.debug("Creating Template Viewer...") + from Templates.TemplateViewer import TemplateViewer + self.templateViewer = TemplateViewer(None, + self.viewmanager) + self.lToolbox.addItem(self.templateViewer, + UI.PixmapCache.getIcon("templateViewer.png"), + self.tr("Template-Viewer")) + + if Preferences.getUI("ShowCodeDocumentationViewer"): + # Create the code documentation viewer + logging.debug("Creating Code Documentation Viewer...") + from .CodeDocumentationViewer import CodeDocumentationViewer + self.codeDocumentationViewer = CodeDocumentationViewer(self) + self.rToolbox.addItem(self.codeDocumentationViewer, + UI.PixmapCache.getIcon("codeDocuViewer.png"), + self.tr("Code Documentation Viewer")) # Create the debug viewer maybe without the embedded shell logging.debug("Creating Debug Viewer...") from Debugger.DebugViewer import DebugViewer - self.debugViewer = DebugViewer( - debugServer, True, self.viewmanager, None, - embeddedShell=self.embeddedShell, - embeddedBrowser=(self.embeddedFileBrowser == 1)) + self.debugViewer = DebugViewer(debugServer, True, self.viewmanager) self.rToolbox.addItem(self.debugViewer, UI.PixmapCache.getIcon("debugViewer.png"), self.tr("Debug-Viewer")) - - # Create the chat part of the user interface - logging.debug("Creating Chat Widget...") - from Cooperation.ChatWidget import ChatWidget - self.cooperation = ChatWidget(self) - self.rToolbox.addItem(self.cooperation, - UI.PixmapCache.getIcon("cooperation.png"), - self.tr("Cooperation")) - - # Create the IRC part of the user interface - logging.debug("Creating IRC Widget...") - from Network.IRC.IrcWidget import IrcWidget - self.irc = IrcWidget(self) - self.rToolbox.addItem(self.irc, - UI.PixmapCache.getIcon("irc.png"), - self.tr("IRC")) + + if Preferences.getUI("ShowCooperation"): + # Create the chat part of the user interface + logging.debug("Creating Chat Widget...") + from Cooperation.ChatWidget import ChatWidget + self.cooperation = ChatWidget(self) + self.rToolbox.addItem(self.cooperation, + UI.PixmapCache.getIcon("cooperation.png"), + self.tr("Cooperation")) + + if Preferences.getUI("ShowIrc"): + # Create the IRC part of the user interface + logging.debug("Creating IRC Widget...") + from Network.IRC.IrcWidget import IrcWidget + self.irc = IrcWidget(self) + self.rToolbox.addItem(self.irc, + UI.PixmapCache.getIcon("irc.png"), + self.tr("IRC")) # Create the task viewer part of the user interface logging.debug("Creating Task Viewer...") @@ -846,20 +882,17 @@ UI.PixmapCache.getIcon("logViewer.png"), self.tr("Log-Viewer")) - if self.embeddedShell: - self.shell = self.debugViewer.shell - else: - # Create the shell - logging.debug("Creating Shell...") - from QScintilla.Shell import ShellAssembly - self.shellAssembly = \ - ShellAssembly(debugServer, self.viewmanager, True) - self.shell = self.shellAssembly.shell() - self.hToolbox.insertItem(0, self.shellAssembly, - UI.PixmapCache.getIcon("shell.png"), - self.tr("Shell")) - - if self.embeddedFileBrowser == 0: # separate window + # Create the shell + logging.debug("Creating Shell...") + from QScintilla.Shell import ShellAssembly + self.shellAssembly = \ + ShellAssembly(debugServer, self.viewmanager, True) + self.shell = self.shellAssembly.shell() + self.hToolbox.insertItem(0, self.shellAssembly, + UI.PixmapCache.getIcon("shell.png"), + self.tr("Shell")) + + if Preferences.getUI("ShowFileBrowser"): # Create the file browser logging.debug("Creating File Browser...") from .Browser import Browser @@ -867,26 +900,24 @@ self.lToolbox.addItem(self.browser, UI.PixmapCache.getIcon("browser.png"), self.tr("File-Browser")) - elif self.embeddedFileBrowser == 1: # embedded in debug browser - self.browser = self.debugViewer.browser - else: # embedded in project browser - self.browser = self.projectBrowser.fileBrowser - - # Create the symbols viewer - logging.debug("Creating Symbols Viewer...") - from .SymbolsWidget import SymbolsWidget - self.symbolsViewer = SymbolsWidget() - self.lToolbox.addItem(self.symbolsViewer, - UI.PixmapCache.getIcon("symbols.png"), - self.tr("Symbols")) - - # Create the numbers viewer - logging.debug("Creating Numbers Viewer...") - from .NumbersWidget import NumbersWidget - self.numbersViewer = NumbersWidget() - self.hToolbox.addItem(self.numbersViewer, - UI.PixmapCache.getIcon("numbers.png"), - self.tr("Numbers")) + + if Preferences.getUI("ShowSymbolsViewer"): + # Create the symbols viewer + logging.debug("Creating Symbols Viewer...") + from .SymbolsWidget import SymbolsWidget + self.symbolsViewer = SymbolsWidget() + self.lToolbox.addItem(self.symbolsViewer, + UI.PixmapCache.getIcon("symbols.png"), + self.tr("Symbols")) + + if Preferences.getUI("ShowNumbersViewer"): + # Create the numbers viewer + logging.debug("Creating Numbers Viewer...") + from .NumbersWidget import NumbersWidget + self.numbersViewer = NumbersWidget() + self.hToolbox.addItem(self.numbersViewer, + UI.PixmapCache.getIcon("numbers.png"), + self.tr("Numbers")) self.hToolbox.setCurrentIndex(0) @@ -913,9 +944,7 @@ # Create the project browser logging.debug("Creating Project Browser...") from Project.ProjectBrowser import ProjectBrowser - self.projectBrowser = ProjectBrowser( - self.project, None, - embeddedBrowser=(self.embeddedFileBrowser == 2)) + self.projectBrowser = ProjectBrowser(self.project) self.leftSidebar.addTab( self.projectBrowser, UI.PixmapCache.getIcon("projectViewer.png"), @@ -931,50 +960,52 @@ UI.PixmapCache.getIcon("multiProjectViewer.png"), self.tr("Multiproject-Viewer")) - # Create the template viewer part of the user interface - logging.debug("Creating Template Viewer...") - from Templates.TemplateViewer import TemplateViewer - self.templateViewer = TemplateViewer(None, - self.viewmanager) - self.leftSidebar.addTab( - self.templateViewer, - UI.PixmapCache.getIcon("templateViewer.png"), - self.tr("Template-Viewer")) + if Preferences.getUI("ShowTemplateViewer"): + # Create the template viewer part of the user interface + logging.debug("Creating Template Viewer...") + from Templates.TemplateViewer import TemplateViewer + self.templateViewer = TemplateViewer(None, + self.viewmanager) + self.leftSidebar.addTab( + self.templateViewer, + UI.PixmapCache.getIcon("templateViewer.png"), + self.tr("Template-Viewer")) - # Create the code documentation viewer - logging.debug("Creating Code Documentation Viewer...") - from .CodeDocumentationViewer import CodeDocumentationViewer - self.codeDocumentationViewer = CodeDocumentationViewer(self) - self.rightSidebar.addTab( - self.codeDocumentationViewer, - UI.PixmapCache.getIcon("codeDocuViewer.png"), - self.tr("Code Documentation Viewer")) + if Preferences.getUI("ShowCodeDocumentationViewer"): + # Create the code documentation viewer + logging.debug("Creating Code Documentation Viewer...") + from .CodeDocumentationViewer import CodeDocumentationViewer + self.codeDocumentationViewer = CodeDocumentationViewer(self) + self.rightSidebar.addTab( + self.codeDocumentationViewer, + UI.PixmapCache.getIcon("codeDocuViewer.png"), + self.tr("Code Documentation Viewer")) # Create the debug viewer maybe without the embedded shell logging.debug("Creating Debug Viewer...") from Debugger.DebugViewer import DebugViewer - self.debugViewer = DebugViewer( - debugServer, True, self.viewmanager, None, - embeddedShell=self.embeddedShell, - embeddedBrowser=(self.embeddedFileBrowser == 1)) + self.debugViewer = DebugViewer(debugServer, True, self.viewmanager) self.rightSidebar.addTab( self.debugViewer, UI.PixmapCache.getIcon("debugViewer.png"), self.tr("Debug-Viewer")) - # Create the chat part of the user interface - logging.debug("Creating Chat Widget...") - from Cooperation.ChatWidget import ChatWidget - self.cooperation = ChatWidget(self) - self.rightSidebar.addTab( - self.cooperation, UI.PixmapCache.getIcon("cooperation.png"), - self.tr("Cooperation")) - - # Create the IRC part of the user interface - logging.debug("Creating IRC Widget...") - from Network.IRC.IrcWidget import IrcWidget - self.irc = IrcWidget(self) - self.rightSidebar.addTab( - self.irc, UI.PixmapCache.getIcon("irc.png"), self.tr("IRC")) + if Preferences.getUI("ShowCooperation"): + # Create the chat part of the user interface + logging.debug("Creating Chat Widget...") + from Cooperation.ChatWidget import ChatWidget + self.cooperation = ChatWidget(self) + self.rightSidebar.addTab( + self.cooperation, UI.PixmapCache.getIcon("cooperation.png"), + self.tr("Cooperation")) + + if Preferences.getUI("ShowIrc"): + # Create the IRC part of the user interface + logging.debug("Creating IRC Widget...") + from Network.IRC.IrcWidget import IrcWidget + self.irc = IrcWidget(self) + self.rightSidebar.addTab( + self.irc, UI.PixmapCache.getIcon("irc.png"), + self.tr("IRC")) # Create the task viewer part of the user interface logging.debug("Creating Task Viewer...") @@ -992,20 +1023,17 @@ UI.PixmapCache.getIcon("logViewer.png"), self.tr("Log-Viewer")) - if self.embeddedShell: - self.shell = self.debugViewer.shell - else: - # Create the shell - logging.debug("Creating Shell...") - from QScintilla.Shell import ShellAssembly - self.shellAssembly = \ - ShellAssembly(debugServer, self.viewmanager, True) - self.shell = self.shellAssembly.shell() - self.bottomSidebar.insertTab(0, self.shellAssembly, - UI.PixmapCache.getIcon("shell.png"), - self.tr("Shell")) + # Create the shell + logging.debug("Creating Shell...") + from QScintilla.Shell import ShellAssembly + self.shellAssembly = \ + ShellAssembly(debugServer, self.viewmanager, True) + self.shell = self.shellAssembly.shell() + self.bottomSidebar.insertTab(0, self.shellAssembly, + UI.PixmapCache.getIcon("shell.png"), + self.tr("Shell")) - if self.embeddedFileBrowser == 0: # separate window + if Preferences.getUI("ShowFileBrowser"): # Create the file browser logging.debug("Creating File Browser...") from .Browser import Browser @@ -1013,26 +1041,24 @@ self.leftSidebar.addTab(self.browser, UI.PixmapCache.getIcon("browser.png"), self.tr("File-Browser")) - elif self.embeddedFileBrowser == 1: # embedded in debug browser - self.browser = self.debugViewer.browser - else: # embedded in project browser - self.browser = self.projectBrowser.fileBrowser - - # Create the symbols viewer - logging.debug("Creating Symbols Viewer...") - from .SymbolsWidget import SymbolsWidget - self.symbolsViewer = SymbolsWidget() - self.leftSidebar.addTab(self.symbolsViewer, - UI.PixmapCache.getIcon("symbols.png"), - self.tr("Symbols")) - - # Create the numbers viewer - logging.debug("Creating Numbers Viewer...") - from .NumbersWidget import NumbersWidget - self.numbersViewer = NumbersWidget() - self.bottomSidebar.addTab(self.numbersViewer, - UI.PixmapCache.getIcon("numbers.png"), - self.tr("Numbers")) + + if Preferences.getUI("ShowSymbolsViewer"): + # Create the symbols viewer + logging.debug("Creating Symbols Viewer...") + from .SymbolsWidget import SymbolsWidget + self.symbolsViewer = SymbolsWidget() + self.leftSidebar.addTab(self.symbolsViewer, + UI.PixmapCache.getIcon("symbols.png"), + self.tr("Symbols")) + + if Preferences.getUI("ShowNumbersViewer"): + # Create the numbers viewer + logging.debug("Creating Numbers Viewer...") + from .NumbersWidget import NumbersWidget + self.numbersViewer = NumbersWidget() + self.bottomSidebar.addTab(self.numbersViewer, + UI.PixmapCache.getIcon("numbers.png"), + self.tr("Numbers")) self.bottomSidebar.setCurrentIndex(0) @@ -1087,14 +1113,14 @@ """ assert side in [UserInterface.LeftSide, UserInterface.BottomSide] - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": if side == UserInterface.LeftSide: self.lToolbox.addItem(widget, icon, label) elif side == UserInterface.BottomSide: self.hToolbox.addItem(widget, icon, label) elif side == UserInterface.RightSide: self.rToolbox.addItem(widget, icon, label) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": if side == UserInterface.LeftSide: self.leftSidebar.addTab(widget, icon, label) elif side == UserInterface.BottomSide: @@ -1108,12 +1134,12 @@ @param widget reference to the widget to remove (QWidget) """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": for container in [self.lToolbox, self.hToolbox, self.rToolbox]: index = container.indexOf(widget) if index != -1: container.removeItem(index) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": for container in [self.leftSidebar, self.bottomSidebar, self.rightSidebar]: index = container.indexOf(widget) @@ -1125,11 +1151,11 @@ Public method to show the Log-Viewer. """ if Preferences.getUI("LogViewerAutoRaise"): - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.hToolboxDock.show() self.hToolbox.setCurrentWidget(self.logViewer) self.hToolboxDock.raise_() - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.bottomSidebar.show() self.bottomSidebar.setCurrentWidget(self.logViewer) self.bottomSidebar.raise_() @@ -1366,6 +1392,22 @@ self.exitAct.setMenuRole(QAction.QuitRole) self.actions.append(self.exitAct) + self.restartAct = E5Action( + self.tr('Restart'), + UI.PixmapCache.getIcon("restart.png"), + self.tr('Restart'), + QKeySequence(self.tr("Ctrl+Shift+Q", "File|Quit")), + 0, self, 'restart_eric') + self.restartAct.setStatusTip(self.tr('Restart the IDE')) + self.restartAct.setWhatsThis(self.tr( + """<b>Restart the IDE</b>""" + """<p>This restarts the IDE. Any unsaved changes may be saved""" + """ first. Any Python program being debugged will be stopped""" + """ and the preferences will be written to disc.</p>""" + )) + self.restartAct.triggered.connect(self.__restart) + self.actions.append(self.restartAct) + self.saveSessionAct = E5Action( self.tr('Save session'), self.tr('Save session...'), @@ -1513,23 +1555,24 @@ self.shellActivateAct.triggered.connect(self.__activateShell) self.actions.append(self.shellActivateAct) self.addAction(self.shellActivateAct) - - self.browserActivateAct = E5Action( - self.tr('File-Browser'), - self.tr('&File-Browser'), - QKeySequence(self.tr("Alt+Shift+F")), - 0, self, - 'file_browser_activate') - self.browserActivateAct.setStatusTip(self.tr( - "Switch the input focus to the File-Browser window.")) - self.browserActivateAct.setWhatsThis(self.tr( - """<b>Activate File-Browser</b>""" - """<p>This switches the input focus to the File-Browser""" - """ window.</p>""" - )) - self.browserActivateAct.triggered.connect(self.__activateBrowser) - self.actions.append(self.browserActivateAct) - self.addAction(self.browserActivateAct) + + if self.browser is not None: + self.browserActivateAct = E5Action( + self.tr('File-Browser'), + self.tr('&File-Browser'), + QKeySequence(self.tr("Alt+Shift+F")), + 0, self, + 'file_browser_activate') + self.browserActivateAct.setStatusTip(self.tr( + "Switch the input focus to the File-Browser window.")) + self.browserActivateAct.setWhatsThis(self.tr( + """<b>Activate File-Browser</b>""" + """<p>This switches the input focus to the File-Browser""" + """ window.</p>""" + )) + self.browserActivateAct.triggered.connect(self.__activateBrowser) + self.actions.append(self.browserActivateAct) + self.addAction(self.browserActivateAct) self.logViewerActivateAct = E5Action( self.tr('Log-Viewer'), @@ -1566,24 +1609,25 @@ self.__activateTaskViewer) self.actions.append(self.taskViewerActivateAct) self.addAction(self.taskViewerActivateAct) - - self.templateViewerActivateAct = E5Action( - self.tr('Template-Viewer'), - self.tr('Templ&ate-Viewer'), - QKeySequence(self.tr("Alt+Shift+A")), - 0, self, - 'template_viewer_activate') - self.templateViewerActivateAct.setStatusTip(self.tr( - "Switch the input focus to the Template-Viewer window.")) - self.templateViewerActivateAct.setWhatsThis(self.tr( - """<b>Activate Template-Viewer</b>""" - """<p>This switches the input focus to the Template-Viewer""" - """ window.</p>""" - )) - self.templateViewerActivateAct.triggered.connect( - self.__activateTemplateViewer) - self.actions.append(self.templateViewerActivateAct) - self.addAction(self.templateViewerActivateAct) + + if self.templateViewer is not None: + self.templateViewerActivateAct = E5Action( + self.tr('Template-Viewer'), + self.tr('Templ&ate-Viewer'), + QKeySequence(self.tr("Alt+Shift+A")), + 0, self, + 'template_viewer_activate') + self.templateViewerActivateAct.setStatusTip(self.tr( + "Switch the input focus to the Template-Viewer window.")) + self.templateViewerActivateAct.setWhatsThis(self.tr( + """<b>Activate Template-Viewer</b>""" + """<p>This switches the input focus to the Template-Viewer""" + """ window.</p>""" + )) + self.templateViewerActivateAct.triggered.connect( + self.__activateTemplateViewer) + self.actions.append(self.templateViewerActivateAct) + self.addAction(self.templateViewerActivateAct) self.ltAct = E5Action( self.tr('Left Toolbox'), @@ -1665,76 +1709,80 @@ self.bsbAct.triggered.connect(self.__toggleBottomSidebar) self.actions.append(self.bsbAct) - self.cooperationViewerActivateAct = E5Action( - self.tr('Cooperation-Viewer'), - self.tr('Co&operation-Viewer'), - QKeySequence(self.tr("Alt+Shift+O")), - 0, self, - 'cooperation_viewer_activate') - self.cooperationViewerActivateAct.setStatusTip(self.tr( - "Switch the input focus to the Cooperation-Viewer window.")) - self.cooperationViewerActivateAct.setWhatsThis(self.tr( - """<b>Activate Cooperation-Viewer</b>""" - """<p>This switches the input focus to the Cooperation-Viewer""" - """ window.</p>""" - )) - self.cooperationViewerActivateAct.triggered.connect( - self.activateCooperationViewer) - self.actions.append(self.cooperationViewerActivateAct) - self.addAction(self.cooperationViewerActivateAct) - - self.ircActivateAct = E5Action( - self.tr('IRC'), - self.tr('&IRC'), - QKeySequence(self.tr("Meta+Shift+I")), - 0, self, - 'irc_widget_activate') - self.ircActivateAct.setStatusTip(self.tr( - "Switch the input focus to the IRC window.")) - self.ircActivateAct.setWhatsThis(self.tr( - """<b>Activate IRC</b>""" - """<p>This switches the input focus to the IRC window.</p>""" - )) - self.ircActivateAct.triggered.connect( - self.__activateIRC) - self.actions.append(self.ircActivateAct) - self.addAction(self.ircActivateAct) - - self.symbolsViewerActivateAct = E5Action( - self.tr('Symbols-Viewer'), - self.tr('S&ymbols-Viewer'), - QKeySequence(self.tr("Alt+Shift+Y")), - 0, self, - 'symbols_viewer_activate') - self.symbolsViewerActivateAct.setStatusTip(self.tr( - "Switch the input focus to the Symbols-Viewer window.")) - self.symbolsViewerActivateAct.setWhatsThis(self.tr( - """<b>Activate Symbols-Viewer</b>""" - """<p>This switches the input focus to the Symbols-Viewer""" - """ window.</p>""" - )) - self.symbolsViewerActivateAct.triggered.connect( - self.__activateSymbolsViewer) - self.actions.append(self.symbolsViewerActivateAct) - self.addAction(self.symbolsViewerActivateAct) - - self.numbersViewerActivateAct = E5Action( - self.tr('Numbers-Viewer'), - self.tr('Num&bers-Viewer'), - QKeySequence(self.tr("Alt+Shift+B")), - 0, self, - 'numbers_viewer_activate') - self.numbersViewerActivateAct.setStatusTip(self.tr( - "Switch the input focus to the Numbers-Viewer window.")) - self.numbersViewerActivateAct.setWhatsThis(self.tr( - """<b>Activate Numbers-Viewer</b>""" - """<p>This switches the input focus to the Numbers-Viewer""" - """ window.</p>""" - )) - self.numbersViewerActivateAct.triggered.connect( - self.__activateNumbersViewer) - self.actions.append(self.numbersViewerActivateAct) - self.addAction(self.numbersViewerActivateAct) + if self.cooperation is not None: + self.cooperationViewerActivateAct = E5Action( + self.tr('Cooperation-Viewer'), + self.tr('Co&operation-Viewer'), + QKeySequence(self.tr("Alt+Shift+O")), + 0, self, + 'cooperation_viewer_activate') + self.cooperationViewerActivateAct.setStatusTip(self.tr( + "Switch the input focus to the Cooperation-Viewer window.")) + self.cooperationViewerActivateAct.setWhatsThis(self.tr( + """<b>Activate Cooperation-Viewer</b>""" + """<p>This switches the input focus to the""" + """ Cooperation-Viewer window.</p>""" + )) + self.cooperationViewerActivateAct.triggered.connect( + self.activateCooperationViewer) + self.actions.append(self.cooperationViewerActivateAct) + self.addAction(self.cooperationViewerActivateAct) + + if self.irc is not None: + self.ircActivateAct = E5Action( + self.tr('IRC'), + self.tr('&IRC'), + QKeySequence(self.tr("Meta+Shift+I")), + 0, self, + 'irc_widget_activate') + self.ircActivateAct.setStatusTip(self.tr( + "Switch the input focus to the IRC window.")) + self.ircActivateAct.setWhatsThis(self.tr( + """<b>Activate IRC</b>""" + """<p>This switches the input focus to the IRC window.</p>""" + )) + self.ircActivateAct.triggered.connect( + self.__activateIRC) + self.actions.append(self.ircActivateAct) + self.addAction(self.ircActivateAct) + + if self.symbolsViewer is not None: + self.symbolsViewerActivateAct = E5Action( + self.tr('Symbols-Viewer'), + self.tr('S&ymbols-Viewer'), + QKeySequence(self.tr("Alt+Shift+Y")), + 0, self, + 'symbols_viewer_activate') + self.symbolsViewerActivateAct.setStatusTip(self.tr( + "Switch the input focus to the Symbols-Viewer window.")) + self.symbolsViewerActivateAct.setWhatsThis(self.tr( + """<b>Activate Symbols-Viewer</b>""" + """<p>This switches the input focus to the Symbols-Viewer""" + """ window.</p>""" + )) + self.symbolsViewerActivateAct.triggered.connect( + self.__activateSymbolsViewer) + self.actions.append(self.symbolsViewerActivateAct) + self.addAction(self.symbolsViewerActivateAct) + + if self.numbersViewer is not None: + self.numbersViewerActivateAct = E5Action( + self.tr('Numbers-Viewer'), + self.tr('Num&bers-Viewer'), + QKeySequence(self.tr("Alt+Shift+B")), + 0, self, + 'numbers_viewer_activate') + self.numbersViewerActivateAct.setStatusTip(self.tr( + "Switch the input focus to the Numbers-Viewer window.")) + self.numbersViewerActivateAct.setWhatsThis(self.tr( + """<b>Activate Numbers-Viewer</b>""" + """<p>This switches the input focus to the Numbers-Viewer""" + """ window.</p>""" + )) + self.numbersViewerActivateAct.triggered.connect( + self.__activateNumbersViewer) + self.actions.append(self.numbersViewerActivateAct) + self.addAction(self.numbersViewerActivateAct) self.whatsThisAct = E5Action( self.tr('What\'s This?'), @@ -2664,6 +2712,7 @@ self.__menus["file"].addAction(self.saveSessionAct) self.__menus["file"].addAction(self.loadSessionAct) self.__menus["file"].addSeparator() + self.__menus["file"].addAction(self.restartAct) self.__menus["file"].addAction(self.exitAct) act = self.__menus["file"].actions()[0] sep = self.__menus["file"].insertSeparator(act) @@ -2756,20 +2805,51 @@ self.__menus["window"]) self.__menus["subwindow"].setTearOffEnabled(True) # left side + try: + self.__menus["subwindow"].addSection(self.tr("Left Side")) + except AttributeError: + # Qt4 + pass self.__menus["subwindow"].addAction(self.pbActivateAct) self.__menus["subwindow"].addAction(self.mpbActivateAct) - self.__menus["subwindow"].addAction(self.templateViewerActivateAct) - self.__menus["subwindow"].addAction(self.browserActivateAct) - self.__menus["subwindow"].addAction(self.symbolsViewerActivateAct) + if self.templateViewer is not None: + self.__menus["subwindow"].addAction(self.templateViewerActivateAct) + if self.browser is not None: + self.__menus["subwindow"].addAction(self.browserActivateAct) + if self.symbolsViewer is not None: + self.__menus["subwindow"].addAction(self.symbolsViewerActivateAct) # bottom side + try: + self.__menus["subwindow"].addSection(self.tr("Bottom Side")) + except AttributeError: + # Qt4 + self.__menus["subwindow"].addSeparator() self.__menus["subwindow"].addAction(self.shellActivateAct) self.__menus["subwindow"].addAction(self.taskViewerActivateAct) self.__menus["subwindow"].addAction(self.logViewerActivateAct) - self.__menus["subwindow"].addAction(self.numbersViewerActivateAct) + if self.numbersViewer is not None: + self.__menus["subwindow"].addAction(self.numbersViewerActivateAct) + try: + self.__menus["subwindow"].addSection(self.tr("Right Side")) + except AttributeError: + # Qt4 + self.__menus["subwindow"].addSeparator() # right side + if self.codeDocumentationViewer is not None: + self.__menus["subwindow"].addAction( + self.tr("Code Documentation Viewer"), + self.activateCodeDocumentationViewer) self.__menus["subwindow"].addAction(self.debugViewerActivateAct) - self.__menus["subwindow"].addAction(self.cooperationViewerActivateAct) - self.__menus["subwindow"].addAction(self.ircActivateAct) + if self.cooperation is not None: + self.__menus["subwindow"].addAction( + self.cooperationViewerActivateAct) + if self.irc is not None: + self.__menus["subwindow"].addAction(self.ircActivateAct) + try: + self.__menus["subwindow"].addSection(self.tr("Plug-ins")) + except AttributeError: + # Qt4 + self.__menus["subwindow"].addSeparator() self.__menus["toolbars"] = \ QMenu(self.tr("&Toolbars"), self.__menus["window"]) @@ -2880,6 +2960,7 @@ pluginstb.setToolTip(self.tr("Plugins")) filetb.addSeparator() + filetb.addAction(self.restartAct) filetb.addAction(self.exitAct) act = filetb.actions()[0] sep = filetb.insertSeparator(act) @@ -3582,17 +3663,24 @@ """ if self.__shutdown(): e5App().closeAllWindows() - - def __restart(self): + + @pyqtSlot() + def __restart(self, ask=False): """ Private method to restart the application. - """ - res = E5MessageBox.yesNo( - self, - self.tr("Restart application"), - self.tr( - """The application needs to be restarted. Do it now?"""), - yesDefault=True) + + @param ask flag indicating to ask the user for permission + @type bool + """ + if ask: + res = E5MessageBox.yesNo( + self, + self.tr("Restart application"), + self.tr( + """The application needs to be restarted. Do it now?"""), + yesDefault=True) + else: + res = True if res and self.__shutdown(): e5App().closeAllWindows() @@ -3737,14 +3825,14 @@ self.__menus["window"].addActions(self.viewProfileActGrp.actions()) self.__menus["window"].addSeparator() - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.__menus["window"].addAction(self.ltAct) self.ltAct.setChecked(not self.lToolboxDock.isHidden()) self.__menus["window"].addAction(self.rtAct) self.rtAct.setChecked(not self.lToolboxDock.isHidden()) self.__menus["window"].addAction(self.htAct) self.htAct.setChecked(not self.hToolboxDock.isHidden()) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.__menus["window"].addAction(self.lsbAct) self.lsbAct.setChecked(not self.leftSidebar.isHidden()) self.__menus["window"].addAction(self.rsbAct) @@ -3869,10 +3957,10 @@ """ if self.currentProfile and save: # step 1: save the window geometries of the active profile - if self.layoutType in ["Toolboxes", "Sidebars"]: + if self.__layoutType in ["Toolboxes", "Sidebars"]: state = self.saveState() self.profiles[self.currentProfile][0] = state - if self.layoutType == "Sidebars": + if self.__layoutType == "Sidebars": state = self.leftSplitter.saveState() self.profiles[self.currentProfile][2][0] = state state = self.verticalSplitter.saveState() @@ -3886,14 +3974,14 @@ state = self.rightSidebar.saveState() self.profiles[self.currentProfile][2][5] = state # step 2: save the visibility of the windows of the active profile - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.profiles[self.currentProfile][1][0] = \ self.lToolboxDock.isVisible() self.profiles[self.currentProfile][1][1] = \ self.hToolboxDock.isVisible() self.profiles[self.currentProfile][1][2] = \ self.rToolboxDock.isVisible() - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.profiles[self.currentProfile][1][0] = \ self.leftSidebar.isVisible() self.profiles[self.currentProfile][1][1] = \ @@ -3915,11 +4003,11 @@ self.__saveCurrentViewProfile(save) # step 2: set the window geometries of the new profile - if self.layoutType in ["Toolboxes", "Sidebars"]: + if self.__layoutType in ["Toolboxes", "Sidebars"]: state = self.profiles[name][0] if not state.isEmpty(): self.restoreState(state) - if self.layoutType == "Sidebars": + if self.__layoutType == "Sidebars": state = self.profiles[name][2][0] if not state.isEmpty(): self.leftSplitter.restoreState(state) @@ -3941,11 +4029,11 @@ self.__configureDockareaCornerUsage() # step 3: activate the windows of the new profile - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.lToolboxDock.setVisible(self.profiles[name][1][0]) self.hToolboxDock.setVisible(self.profiles[name][1][1]) self.rToolboxDock.setVisible(self.profiles[name][1][2]) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.leftSidebar.setVisible(self.profiles[name][1][0]) self.bottomSidebar.setVisible(self.profiles[name][1][1]) self.rightSidebar.setVisible(self.profiles[name][1][2]) @@ -3968,30 +4056,28 @@ Private slot to handle the start of a debugging session. """ self.setDebugProfile() - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.__currentRightWidget = self.rToolbox.currentWidget() self.rToolbox.setCurrentWidget(self.debugViewer) - if not self.embeddedShell: - self.__currentBottomWidget = self.hToolbox.currentWidget() - self.hToolbox.setCurrentWidget(self.shellAssembly) - elif self.layoutType == "Sidebars": + self.__currentBottomWidget = self.hToolbox.currentWidget() + self.hToolbox.setCurrentWidget(self.shellAssembly) + elif self.__layoutType == "Sidebars": self.__currentRightWidget = self.rightSidebar.currentWidget() self.rightSidebar.setCurrentWidget(self.debugViewer) - if not self.embeddedShell: - self.__currentBottomWidget = self.bottomSidebar.currentWidget() - self.bottomSidebar.setCurrentWidget(self.shellAssembly) + self.__currentBottomWidget = self.bottomSidebar.currentWidget() + self.bottomSidebar.setCurrentWidget(self.shellAssembly) def __debuggingDone(self): """ Private slot to handle the end of a debugging session. """ self.__setEditProfile() - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": if self.__currentRightWidget: self.rToolbox.setCurrentWidget(self.__currentRightWidget) if self.__currentBottomWidget: self.hToolbox.setCurrentWidget(self.__currentBottomWidget) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": if self.__currentRightWidget: self.rightSidebar.setCurrentWidget(self.__currentRightWidget) if self.__currentBottomWidget: @@ -4031,15 +4117,24 @@ @return the name of the current view profile (string) """ return self.currentProfile - + + def getLayoutType(self): + """ + Public method to get the current layout type. + + @return current layout type + @rtype str + """ + return self.__layoutType + def __activateProjectBrowser(self): """ Private slot to handle the activation of the project browser. """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.lToolboxDock.show() self.lToolbox.setCurrentWidget(self.projectBrowser) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.leftSidebar.show() self.leftSidebar.setCurrentWidget(self.projectBrowser) else: @@ -4051,10 +4146,10 @@ """ Private slot to handle the activation of the project browser. """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.lToolboxDock.show() self.lToolbox.setCurrentWidget(self.multiProjectBrowser) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.leftSidebar.show() self.leftSidebar.setCurrentWidget(self.multiProjectBrowser) else: @@ -4065,10 +4160,10 @@ """ Public slot to handle the activation of the debug viewer. """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.debugViewer) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.rightSidebar.show() self.rightSidebar.setCurrentWidget(self.debugViewer) else: @@ -4079,35 +4174,24 @@ """ Private slot to handle the activation of the Shell window. """ - if self.embeddedShell: # embedded in debug browser - if self.layoutType == "Toolboxes": - self.rToolboxDock.show() - self.rToolbox.setCurrentWidget(self.debugViewer) - elif self.layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.debugViewer) - else: - self.debugViewer.show() - self.debugViewer.setCurrentWidget(self.debugViewer.shellAssembly) - else: # separate window - if self.layoutType == "Toolboxes": - self.hToolboxDock.show() - self.hToolbox.setCurrentWidget(self.shellAssembly) - elif self.layoutType == "Sidebars": - self.bottomSidebar.show() - self.bottomSidebar.setCurrentWidget(self.shellAssembly) - else: - self.shell.show() + if self.__layoutType == "Toolboxes": + self.hToolboxDock.show() + self.hToolbox.setCurrentWidget(self.shellAssembly) + elif self.__layoutType == "Sidebars": + self.bottomSidebar.show() + self.bottomSidebar.setCurrentWidget(self.shellAssembly) + else: + self.shell.show() self.shell.setFocus(Qt.ActiveWindowFocusReason) def __activateLogViewer(self): """ Private slot to handle the activation of the Log Viewer. """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.hToolboxDock.show() self.hToolbox.setCurrentWidget(self.logViewer) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.bottomSidebar.show() self.bottomSidebar.setCurrentWidget(self.logViewer) else: @@ -4118,10 +4202,10 @@ """ Private slot to handle the activation of the Task Viewer. """ - if self.layoutType == "Toolboxes": + if self.__layoutType == "Toolboxes": self.hToolboxDock.show() self.hToolbox.setCurrentWidget(self.taskViewer) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.bottomSidebar.show() self.bottomSidebar.setCurrentWidget(self.taskViewer) else: @@ -4132,50 +4216,31 @@ """ Private slot to handle the activation of the Template Viewer. """ - if self.layoutType == "Toolboxes": - self.lToolboxDock.show() - self.lToolbox.setCurrentWidget(self.templateViewer) - elif self.layoutType == "Sidebars": - self.leftSidebar.show() - self.leftSidebar.setCurrentWidget(self.templateViewer) - else: - self.templateViewer.show() - self.templateViewer.setFocus(Qt.ActiveWindowFocusReason) + if self.templateViewer is not None: + if self.__layoutType == "Toolboxes": + self.lToolboxDock.show() + self.lToolbox.setCurrentWidget(self.templateViewer) + elif self.__layoutType == "Sidebars": + self.leftSidebar.show() + self.leftSidebar.setCurrentWidget(self.templateViewer) + else: + self.templateViewer.show() + self.templateViewer.setFocus(Qt.ActiveWindowFocusReason) def __activateBrowser(self): """ Private slot to handle the activation of the file browser. """ - if self.embeddedFileBrowser == 0: # separate window - if self.layoutType == "Toolboxes": + if self.browser is not None: + if self.__layoutType == "Toolboxes": self.lToolboxDock.show() self.lToolbox.setCurrentWidget(self.browser) - elif self.layoutType == "Sidebars": + elif self.__layoutType == "Sidebars": self.leftSidebar.show() self.leftSidebar.setCurrentWidget(self.browser) else: self.browser.show() - elif self.embeddedFileBrowser == 1: # embedded in debug browser - if self.layoutType == "Toolboxes": - self.rToolboxDock.show() - self.rToolbox.setCurrentWidget(self.debugViewer) - elif self.layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.debugViewer) - else: - self.debugViewer.show() - self.debugViewer.setCurrentWidget(self.browser) - else: # embedded in project browser - if self.layoutType == "Toolboxes": - self.lToolboxDock.show() - self.lToolbox.setCurrentWidget(self.projectBrowser) - elif self.layoutType == "Sidebars": - self.leftSidebar.show() - self.leftSidebar.setCurrentWidget(self.projectBrowser) - else: - self.projectBrowser.show() - self.projectBrowser.setCurrentWidget(self.browser) - self.browser.setFocus(Qt.ActiveWindowFocusReason) + self.browser.setFocus(Qt.ActiveWindowFocusReason) def __toggleLeftToolbox(self): """ @@ -4256,57 +4321,61 @@ """ Public slot to handle the activation of the cooperation window. """ - if self.layoutType == "Toolboxes": - self.rToolboxDock.show() - self.rToolbox.setCurrentWidget(self.cooperation) - elif self.layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.cooperation) - else: - self.cooperation.show() - self.cooperation.setFocus(Qt.ActiveWindowFocusReason) + if self.cooperation is not None: + if self.__layoutType == "Toolboxes": + self.rToolboxDock.show() + self.rToolbox.setCurrentWidget(self.cooperation) + elif self.__layoutType == "Sidebars": + self.rightSidebar.show() + self.rightSidebar.setCurrentWidget(self.cooperation) + else: + self.cooperation.show() + self.cooperation.setFocus(Qt.ActiveWindowFocusReason) def __activateIRC(self): """ Private slot to handle the activation of the IRC window. """ - if self.layoutType == "Toolboxes": - self.rToolboxDock.show() - self.rToolbox.setCurrentWidget(self.irc) - elif self.layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.irc) - else: - self.irc.show() - self.irc.setFocus(Qt.ActiveWindowFocusReason) + if self.irc is not None: + if self.__layoutType == "Toolboxes": + self.rToolboxDock.show() + self.rToolbox.setCurrentWidget(self.irc) + elif self.__layoutType == "Sidebars": + self.rightSidebar.show() + self.rightSidebar.setCurrentWidget(self.irc) + else: + self.irc.show() + self.irc.setFocus(Qt.ActiveWindowFocusReason) def __activateSymbolsViewer(self): """ Private slot to handle the activation of the Symbols Viewer. """ - if self.layoutType == "Toolboxes": - self.lToolboxDock.show() - self.lToolbox.setCurrentWidget(self.symbolsViewer) - elif self.layoutType == "Sidebars": - self.leftSidebar.show() - self.leftSidebar.setCurrentWidget(self.symbolsViewer) - else: - self.symbolsViewer.show() - self.symbolsViewer.setFocus(Qt.ActiveWindowFocusReason) + if self.symbolsViewer is not None: + if self.__layoutType == "Toolboxes": + self.lToolboxDock.show() + self.lToolbox.setCurrentWidget(self.symbolsViewer) + elif self.__layoutType == "Sidebars": + self.leftSidebar.show() + self.leftSidebar.setCurrentWidget(self.symbolsViewer) + else: + self.symbolsViewer.show() + self.symbolsViewer.setFocus(Qt.ActiveWindowFocusReason) def __activateNumbersViewer(self): """ Private slot to handle the activation of the Numbers Viewer. """ - if self.layoutType == "Toolboxes": - self.hToolboxDock.show() - self.hToolboxDock.setCurrentWidget(self.numbersViewer) - elif self.layoutType == "Sidebars": - self.bottomSidebar.show() - self.bottomSidebar.setCurrentWidget(self.numbersViewer) - else: - self.numbersViewer.show() - self.numbersViewer.setFocus(Qt.ActiveWindowFocusReason) + if self.numbersViewer is not None: + if self.__layoutType == "Toolboxes": + self.hToolboxDock.show() + self.hToolbox.setCurrentWidget(self.numbersViewer) + elif self.__layoutType == "Sidebars": + self.bottomSidebar.show() + self.bottomSidebar.setCurrentWidget(self.numbersViewer) + else: + self.numbersViewer.show() + self.numbersViewer.setFocus(Qt.ActiveWindowFocusReason) def __activateViewmanager(self): """ @@ -4323,16 +4392,19 @@ @param switchFocus flag indicating to transfer the input focus @type bool """ - if self.layoutType == "Toolboxes": - self.rToolboxDock.show() - self.rToolbox.setCurrentWidget(self.codeDocumentationViewer) - elif self.layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.codeDocumentationViewer) - else: - self.codeDocumentationViewer.show() - if switchFocus: - self.codeDocumentationViewer.setFocus(Qt.ActiveWindowFocusReason) + if self.codeDocumentationViewer is not None: + if self.__layoutType == "Toolboxes": + self.rToolboxDock.show() + self.rToolbox.setCurrentWidget(self.codeDocumentationViewer) + elif self.__layoutType == "Sidebars": + self.rightSidebar.show() + self.rightSidebar.setCurrentWidget( + self.codeDocumentationViewer) + else: + self.codeDocumentationViewer.show() + if switchFocus: + self.codeDocumentationViewer.setFocus( + Qt.ActiveWindowFocusReason) def __toggleWindow(self, w): """ @@ -5735,7 +5807,7 @@ SpellChecker.setDefaultLanguage( Preferences.getEditor("SpellCheckingDefaultLanguage")) - if self.layoutType == "Sidebars": + if self.__layoutType == "Sidebars": delay = Preferences.getUI("SidebarDelay") self.leftSidebar.setDelay(delay) self.bottomSidebar.setDelay(delay) @@ -5799,7 +5871,7 @@ Private slot to configure the various view profiles. """ from Preferences.ViewProfileDialog import ViewProfileDialog - dlg = ViewProfileDialog(self.layoutType, self.profiles['edit'][1], + dlg = ViewProfileDialog(self.__layoutType, self.profiles['edit'][1], self.profiles['debug'][1]) if dlg.exec_() == QDialog.Accepted: edit, debug = dlg.getVisibilities() @@ -6338,7 +6410,7 @@ self) dlg.exec_() if dlg.restartNeeded(): - self.__restart() + self.__restart(ask=True) def __deinstallPlugin(self): """ @@ -6458,8 +6530,9 @@ if not self.helpWindow.shutdown(): return False - if not self.irc.shutdown(): - return False + if self.irc is not None: + if not self.irc.shutdown(): + return False sessionCreated = self.__writeSession() @@ -6475,14 +6548,17 @@ if sessionCreated and not self.__disableCrashSession: self.__deleteCrashSession() - self.codeDocumentationViewer.shutdown() + if self.codeDocumentationViewer is not None: + self.codeDocumentationViewer.shutdown() self.__previewer.shutdown() self.shell.closeShell() self.__writeTasks() - self.templateViewer.save() + + if self.templateViewer is not None: + self.templateViewer.save() if not self.debuggerUI.shutdownServer(): return False @@ -6490,13 +6566,14 @@ self.backgroundService.shutdown() - self.cooperation.shutdown() + if self.cooperation is not None: + self.cooperation.shutdown() self.pluginManager.doShutdown() self.virtualenvManager.shutdown() - if self.layoutType == "Sidebars": + if self.__layoutType == "Sidebars": self.leftSidebar.shutdown() self.bottomSidebar.shutdown() self.rightSidebar.shutdown() @@ -6508,7 +6585,9 @@ Preferences.setGeometry("MainMaximized", self.isMaximized()) if not self.isMaximized(): Preferences.setGeometry("MainGeometry", self.saveGeometry()) - self.browser.saveToplevelDirs() + + if self.browser is not None: + self.browser.saveToplevelDirs() Preferences.setUI( "ToolbarManagerState", self.toolbarManager.saveState()) @@ -7008,7 +7087,8 @@ """ Public method to initiate the IRC auto connection. """ - self.irc.autoConnect() + if self.irc is not None: + self.irc.autoConnect() def __ircAutoConnected(self): """