diff -r 12c25acee031 -r e2f8a0fbf738 eric7/UI/UserInterface.py --- a/eric7/UI/UserInterface.py Tue Oct 26 18:03:56 2021 +0200 +++ b/eric7/UI/UserInterface.py Wed Oct 27 19:15:50 2021 +0200 @@ -1160,6 +1160,10 @@ ## Populate the bottom toolbox #################################################### + self.hToolbox.addItem(self.shellAssembly, + UI.PixmapCache.getIcon("shell"), + self.tr("Shell")) + self.hToolbox.addItem(self.taskViewer, UI.PixmapCache.getIcon("task"), self.tr("Task-Viewer")) @@ -1174,21 +1178,6 @@ self.tr("Numbers")) #################################################### - ## Populate the configurable widgets - #################################################### - - self.__shellPosition = Preferences.getUI("ShellPosition") - if self.__shellPosition == "left": - self.__shellParent = self.lToolboxDock - elif self.__shellPosition == "right": - self.__shellParent = self.rToolboxDock - else: - self.__shellParent = self.hToolboxDock - self.__shellParent.widget().insertItem( - 0, self.shellAssembly, UI.PixmapCache.getIcon("shell"), - self.tr("Shell")) - - #################################################### ## Set the start index of each toolbox #################################################### @@ -1215,10 +1204,15 @@ self.bottomSidebar.setIconBarColor(Preferences.getUI("IconBarColor")) # Create the right sidebar - self.rightSidebar = EricSideBar(EricSideBarSide.EAST, - Preferences.getUI("IconBarSize")) - self.rightSidebar.setIconBarColor(Preferences.getUI("IconBarColor")) - + if Preferences.getUI("CombinedLeftRightSidebar"): + # combine left and right sidebar on the left side + self.rightSidebar = None + else: + self.rightSidebar = EricSideBar( + EricSideBarSide.EAST, Preferences.getUI("IconBarSize")) + self.rightSidebar.setIconBarColor( + Preferences.getUI("IconBarColor")) + #################################################### ## Populate the left side bar #################################################### @@ -1266,61 +1260,72 @@ UI.PixmapCache.getIcon("sbSymbolsViewer96"), self.tr("Symbols")) - #################################################### - ## Populate the right side bar - #################################################### + ############################################################## + ## Populate the right side bar or combined left sidebar + ############################################################## # TODO: add option to add all tools to the left sidebar # possibly with different order (e.g. debug after VCS) - self.rightSidebar.addTab( - self.debugViewer, - UI.PixmapCache.getIcon("sbDebugViewer96"), - self.tr("Debug-Viewer")) + sidebar = self.rightSidebar or self.leftSidebar + + if sidebar is self.leftSidebar: + # place debug viewer after 'VCS Status' widget + index = self.leftSidebar.indexOf(self.__vcsStatusWidget) + 1 + sidebar.insertTab( + index, + self.debugViewer, + UI.PixmapCache.getIcon("sbDebugViewer96"), + self.tr("Debug-Viewer")) + else: + sidebar.addTab( + self.debugViewer, + UI.PixmapCache.getIcon("sbDebugViewer96"), + self.tr("Debug-Viewer")) if self.codeDocumentationViewer: - self.rightSidebar.addTab( + sidebar.addTab( self.codeDocumentationViewer, UI.PixmapCache.getIcon("sbCodeDocuViewer96"), self.tr("Code Documentation Viewer")) if self.__helpViewerWidget: - self.rightSidebar.addTab( + sidebar.addTab( self.__helpViewerWidget, UI.PixmapCache.getIcon("sbHelpViewer96"), self.tr("Help Viewer")) - self.rightSidebar.addTab( + sidebar.addTab( self.pluginRepositoryViewer, UI.PixmapCache.getIcon("sbPluginRepository96"), self.tr("Plugin Repository")) - self.rightSidebar.addTab( + sidebar.addTab( self.__virtualenvManagerWidget, UI.PixmapCache.getIcon("sbVirtenvManager96"), self.tr("Virtual Environments")) if self.pipWidget: - self.rightSidebar.addTab( + sidebar.addTab( self.pipWidget, UI.PixmapCache.getIcon("sbPyPI96"), self.tr("PyPI")) if self.condaWidget: - self.rightSidebar.addTab( + sidebar.addTab( self.condaWidget, UI.PixmapCache.getIcon("sbMiniconda96"), self.tr("Conda")) if self.cooperation: - self.rightSidebar.addTab( + sidebar.addTab( self.cooperation, UI.PixmapCache.getIcon("sbCooperation96"), self.tr("Cooperation")) if self.irc: - self.rightSidebar.addTab( + sidebar.addTab( self.irc, UI.PixmapCache.getIcon("sbIrc96"), self.tr("IRC")) if self.microPythonWidget: - self.rightSidebar.addTab( + sidebar.addTab( self.microPythonWidget, UI.PixmapCache.getIcon("sbMicroPython96"), self.tr("MicroPython")) @@ -1329,6 +1334,10 @@ ## Populate the bottom side bar #################################################### + self.bottomSidebar.addTab(self.shellAssembly, + UI.PixmapCache.getIcon("sbShell96"), + self.tr("Shell")) + self.bottomSidebar.addTab(self.taskViewer, UI.PixmapCache.getIcon("sbTasksViewer96"), self.tr("Task-Viewer")) @@ -1343,26 +1352,12 @@ self.tr("Numbers")) #################################################### - ## Populate the configurable widgets - #################################################### - - self.__shellPosition = Preferences.getUI("ShellPosition") - if self.__shellPosition == "left": - self.__shellParent = self.leftSidebar - elif self.__shellPosition == "right": - self.__shellParent = self.rightSidebar - else: - self.__shellParent = self.bottomSidebar - self.__shellParent.insertTab(0, self.shellAssembly, - UI.PixmapCache.getIcon("sbShell96"), - self.tr("Shell")) - - #################################################### ## Set the start index of each side bar #################################################### self.leftSidebar.setCurrentIndex(0) - self.rightSidebar.setCurrentIndex(0) + if self.rightSidebar: + self.rightSidebar.setCurrentIndex(0) self.bottomSidebar.setCurrentIndex(0) # create the central widget @@ -1376,7 +1371,8 @@ self.verticalSplitter.addWidget(self.bottomSidebar) self.horizontalSplitter.addWidget(self.leftSidebar) self.horizontalSplitter.addWidget(self.verticalSplitter) - self.horizontalSplitter.addWidget(self.rightSidebar) + if self.rightSidebar: + self.horizontalSplitter.addWidget(self.rightSidebar) self.setCentralWidget(self.horizontalSplitter) def addSideWidget(self, side, widget, icon, label): @@ -1408,7 +1404,10 @@ elif side == UserInterface.BottomSide: self.bottomSidebar.addTab(widget, icon, label) elif side == UserInterface.RightSide: - self.rightSidebar.addTab(widget, icon, label) + if self.rightSidebar: + self.rightSidebar.addTab(widget, icon, label) + else: + self.leftSidebar.addTab(widget, icon, label) def removeSideWidget(self, widget): """ @@ -1425,9 +1424,10 @@ elif self.__layoutType == "Sidebars": for container in [self.leftSidebar, self.bottomSidebar, self.rightSidebar]: - index = container.indexOf(widget) - if index != -1: - container.removeTab(index) + if container is not None: + index = container.indexOf(widget) + if index != -1: + container.removeTab(index) def showSideWidget(self, widget): """ @@ -1448,11 +1448,12 @@ elif self.__layoutType == "Sidebars": for container in [self.leftSidebar, self.bottomSidebar, self.rightSidebar]: - index = container.indexOf(widget) - if index != -1: - container.show() - container.setCurrentIndex(index) - container.raise_() + if container is not None: + index = container.indexOf(widget) + if index != -1: + container.show() + container.setCurrentIndex(index) + container.raise_() def showLogViewer(self): """ @@ -2075,19 +2076,22 @@ self.lsbAct.triggered.connect(self.__toggleLeftSidebar) self.actions.append(self.lsbAct) - self.rsbAct = EricAction( - self.tr('Right Sidebar'), - self.tr('&Right Sidebar'), - 0, 0, self, 'right_sidebar', True) - self.rsbAct.setStatusTip(self.tr( - 'Toggle the right sidebar window')) - self.rsbAct.setWhatsThis(self.tr( - """<b>Toggle the right sidebar window</b>""" - """<p>If the right sidebar window is hidden then display it.""" - """ If it is displayed then close it.</p>""" - )) - self.rsbAct.triggered.connect(self.__toggleRightSidebar) - self.actions.append(self.rsbAct) + if self.rightSidebar: + self.rsbAct = EricAction( + self.tr('Right Sidebar'), + self.tr('&Right Sidebar'), + 0, 0, self, 'right_sidebar', True) + self.rsbAct.setStatusTip(self.tr( + 'Toggle the right sidebar window')) + self.rsbAct.setWhatsThis(self.tr( + """<b>Toggle the right sidebar window</b>""" + """<p>If the right sidebar window is hidden then display it.""" + """ If it is displayed then close it.</p>""" + )) + self.rsbAct.triggered.connect(self.__toggleRightSidebar) + self.actions.append(self.rsbAct) + else: + self.rsbAct = None self.bsbAct = EricAction( self.tr('Bottom Sidebar'), @@ -3436,13 +3440,13 @@ # left side self.__menus["subwindow"].addSection(self.tr("Left Side")) - if self.__shellPosition == "left": - self.__menus["subwindow"].addAction(self.shellActivateAct) self.__menus["subwindow"].addAction(self.mpbActivateAct) self.__menus["subwindow"].addAction(self.pbActivateAct) self.__menus["subwindow"].addAction(self.findFileActivateAct) self.__menus["subwindow"].addAction(self.findLocationActivateAct) self.__menus["subwindow"].addAction(self.vcsStatusListActivateAct) + if not self.rightSidebar: + self.__menus["subwindow"].addAction(self.debugViewerActivateAct) if self.templateViewer is not None: self.__menus["subwindow"].addAction(self.templateViewerActivateAct) if self.browser is not None: @@ -3451,10 +3455,9 @@ self.__menus["subwindow"].addAction(self.symbolsViewerActivateAct) # right side - self.__menus["subwindow"].addSection(self.tr("Right Side")) - if self.__shellPosition == "right": - self.__menus["subwindow"].addAction(self.shellActivateAct) - self.__menus["subwindow"].addAction(self.debugViewerActivateAct) + if self.rightSidebar: + self.__menus["subwindow"].addSection(self.tr("Right Side")) + self.__menus["subwindow"].addAction(self.debugViewerActivateAct) if self.codeDocumentationViewer is not None: self.__menus["subwindow"].addAction( self.codeDocumentationViewerActivateAct) @@ -3478,8 +3481,7 @@ # bottom side self.__menus["subwindow"].addSection(self.tr("Bottom Side")) - if self.__shellPosition == "bottom": - self.__menus["subwindow"].addAction(self.shellActivateAct) + self.__menus["subwindow"].addAction(self.shellActivateAct) self.__menus["subwindow"].addAction(self.taskViewerActivateAct) self.__menus["subwindow"].addAction(self.logViewerActivateAct) if self.numbersViewer is not None: @@ -4503,8 +4505,9 @@ elif self.__layoutType == "Sidebars": self.__menus["window"].addAction(self.lsbAct) self.lsbAct.setChecked(not self.leftSidebar.isHidden()) - self.__menus["window"].addAction(self.rsbAct) - self.rsbAct.setChecked(not self.rightSidebar.isHidden()) + if self.rsbAct: + self.__menus["window"].addAction(self.rsbAct) + self.rsbAct.setChecked(not self.rightSidebar.isHidden()) self.__menus["window"].addAction(self.bsbAct) self.bsbAct.setChecked(not self.bottomSidebar.isHidden()) @@ -4641,8 +4644,9 @@ self.profiles[self.currentProfile][2][2] = state state = self.bottomSidebar.saveState() self.profiles[self.currentProfile][2][3] = state - state = self.rightSidebar.saveState() - self.profiles[self.currentProfile][2][4] = state + if self.rightSidebar: + state = self.rightSidebar.saveState() + self.profiles[self.currentProfile][2][4] = state # step 2: save the visibility of the windows of the active profile if self.__layoutType == "Toolboxes": @@ -4662,9 +4666,10 @@ self.profiles[self.currentProfile][1][1] = ( self.bottomSidebar.isVisible() ) - self.profiles[self.currentProfile][1][2] = ( - self.rightSidebar.isVisible() - ) + if self.rightSidebar: + self.profiles[self.currentProfile][1][2] = ( + self.rightSidebar.isVisible() + ) Preferences.setUI("ViewProfiles", self.profiles) def __activateViewProfile(self, name, save=True): @@ -4698,9 +4703,10 @@ state = self.profiles[name][2][3] if state: self.bottomSidebar.restoreState(state) - state = self.profiles[name][2][4] - if state: - self.rightSidebar.restoreState(state) + if self.rightSidebar: + state = self.profiles[name][2][4] + if state: + self.rightSidebar.restoreState(state) if self.__layoutType == "Toolboxes": # set the corner usages @@ -4721,7 +4727,8 @@ 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]) + if self.rightSidebar: + self.rightSidebar.setVisible(self.profiles[name][1][2]) # step 4: remember the new profile self.currentProfile = name @@ -4747,8 +4754,12 @@ 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 self.rightSidebar: + self.__currentRightWidget = self.rightSidebar.currentWidget() + self.rightSidebar.setCurrentWidget(self.debugViewer) + else: + self.__currentRightWidget = self.leftSidebar.currentWidget() + self.leftSidebar.setCurrentWidget(self.debugViewer) self.__currentBottomWidget = self.bottomSidebar.currentWidget() self.bottomSidebar.setCurrentWidget(self.shellAssembly) @@ -4764,7 +4775,12 @@ self.hToolbox.setCurrentWidget(self.__currentBottomWidget) elif self.__layoutType == "Sidebars": if self.__currentRightWidget: - self.rightSidebar.setCurrentWidget(self.__currentRightWidget) + if self.rightSidebar: + self.rightSidebar.setCurrentWidget( + self.__currentRightWidget) + else: + self.leftSidebar.setCurrentWidget( + self.__currentRightWidget) if self.__currentBottomWidget: self.bottomSidebar.setCurrentWidget(self.__currentBottomWidget) self.__currentRightWidget = None @@ -4812,6 +4828,22 @@ """ return self.__layoutType + def __activateLeftRightSidebarWidget(self, widget): + """ + Private method to activate the given widget in the left or right + sidebar. + + @param widget reference to the widget to be activated + @type QWidget + """ + sidebar = ( + self.leftSidebar + if Preferences.getUI("CombinedLeftRightSidebar") else + self.rightSidebar + ) + sidebar.show() + sidebar.setCurrentWidget(widget) + def __activateProjectBrowser(self): """ Private slot to handle the activation of the project browser. @@ -4846,8 +4878,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.debugViewer) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.debugViewer) + self.__activateLeftRightSidebarWidget(self.debugViewer) self.debugViewer.currentWidget().setFocus( Qt.FocusReason.ActiveWindowFocusReason) @@ -5001,8 +5032,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.cooperation) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.cooperation) + self.__activateLeftRightSidebarWidget(self.cooperation) self.cooperation.setFocus(Qt.FocusReason.ActiveWindowFocusReason) def __activateIRC(self): @@ -5014,8 +5044,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.irc) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.irc) + self.__activateLeftRightSidebarWidget(self.irc) self.irc.setFocus(Qt.FocusReason.ActiveWindowFocusReason) def __activateSymbolsViewer(self): @@ -5064,8 +5093,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.codeDocumentationViewer) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget( + self.__activateLeftRightSidebarWidget( self.codeDocumentationViewer) if switchFocus: self.codeDocumentationViewer.setFocus( @@ -5080,8 +5108,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.pipWidget) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.pipWidget) + self.__activateLeftRightSidebarWidget(self.pipWidget) self.pipWidget.setFocus(Qt.FocusReason.ActiveWindowFocusReason) def __activateCondaWidget(self): @@ -5093,8 +5120,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.condaWidget) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.condaWidget) + self.__activateLeftRightSidebarWidget(self.condaWidget) self.condaWidget.setFocus(Qt.FocusReason.ActiveWindowFocusReason) def __activateMicroPython(self): @@ -5106,8 +5132,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.microPythonWidget) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.microPythonWidget) + self.__activateLeftRightSidebarWidget(self.microPythonWidget) self.microPythonWidget.setFocus( Qt.FocusReason.ActiveWindowFocusReason) @@ -6402,17 +6427,19 @@ if self.__layoutType == "Sidebars": self.leftSidebar.setIconBarColor( Preferences.getUI("IconBarColor")) + self.leftSidebar.setIconBarSize( + Preferences.getUI("IconBarSize")) + self.bottomSidebar.setIconBarColor( Preferences.getUI("IconBarColor")) - self.rightSidebar.setIconBarColor( - Preferences.getUI("IconBarColor")) - - self.leftSidebar.setIconBarSize( - Preferences.getUI("IconBarSize")) self.bottomSidebar.setIconBarSize( Preferences.getUI("IconBarSize")) - self.rightSidebar.setIconBarSize( - Preferences.getUI("IconBarSize")) + + if self.rightSidebar: + self.rightSidebar.setIconBarColor( + Preferences.getUI("IconBarColor")) + self.rightSidebar.setIconBarSize( + Preferences.getUI("IconBarSize")) self.maxEditorPathLen = Preferences.getUI("CaptionFilenameLength") self.captionShowsFilename = Preferences.getUI("CaptionShowsFilename") @@ -7056,8 +7083,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.__helpViewerWidget) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.__helpViewerWidget) + self.__activateLeftRightSidebarWidget(self.__helpViewerWidget) self.__helpViewerWidget.setFocus( Qt.FocusReason.ActiveWindowFocusReason) @@ -7190,8 +7216,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.pluginRepositoryViewer) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.pluginRepositoryViewer) + self.__activateLeftRightSidebarWidget(self.pluginRepositoryViewer) self.pluginRepositoryViewer.setFocus( Qt.FocusReason.ActiveWindowFocusReason) @@ -7936,7 +7961,7 @@ self.rToolboxDock.show() self.rToolbox.setCurrentWidget(self.__virtualenvManagerWidget) elif self.__layoutType == "Sidebars": - self.rightSidebar.show() - self.rightSidebar.setCurrentWidget(self.__virtualenvManagerWidget) + self.__activateLeftRightSidebarWidget( + self.__virtualenvManagerWidget) self.__virtualenvManagerWidget.setFocus( Qt.FocusReason.ActiveWindowFocusReason)