Shell: added capability to place the Shell window in the left or right side container.

Sat, 04 May 2019 14:44:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 04 May 2019 14:44:11 +0200
changeset 6998
a63ca2373f44
parent 6997
24eabcea4c59
child 6999
f23e546a7eb9

Shell: added capability to place the Shell window in the left or right side container.

docs/changelog file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/InterfacePage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/InterfacePage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sat May 04 14:34:51 2019 +0200
+++ b/docs/changelog	Sat May 04 14:44:11 2019 +0200
@@ -10,6 +10,9 @@
   -- Ruby Typing
      --- changed the indentation when the previous line ends with
          '(', '[' or '{'
+- Shell
+  -- added capability to place the Shell window in the left or right side
+     container
 - Third Party packages
   -- updated EditorConfig to 0.12.2
 
--- a/eric6/Preferences/ConfigurationPages/InterfacePage.py	Sat May 04 14:34:51 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/InterfacePage.py	Sat May 04 14:44:11 2019 +0200
@@ -47,6 +47,7 @@
         # set initial values
         self.__populateStyleCombo()
         self.__populateLanguageCombo()
+        self.__populateShellPositionCombo()
         
         self.uiBrowsersListFoldersFirstCheckBox.setChecked(
             Preferences.getUI("BrowsersListFoldersFirst"))
@@ -97,10 +98,6 @@
         self.numbersCheckBox.setChecked(
             Preferences.getUI("ShowNumbersViewer"))
         
-        self.tabsGroupBox.setEnabled(True)
-        self.tabsCloseButtonCheckBox.setChecked(
-            Preferences.getUI("SingleCloseButton"))
-        
         self.delaySpinBox.setValue(Preferences.getUI("SidebarDelay"))
         
     def save(self):
@@ -157,6 +154,11 @@
             layoutType = "Sidebars"    # just in case
         Preferences.setUI("LayoutType", layoutType)
         
+        # save the shell position setting
+        shellPositionIndex = self.shellPositionComboBox.currentIndex()
+        shellPosition = self.shellPositionComboBox.itemData(shellPositionIndex)
+        Preferences.setUI("ShellPosition", shellPosition)
+        
         # save the integrated tools activation
         # left side
         Preferences.setUI(
@@ -189,10 +191,6 @@
             "ShowNumbersViewer",
             self.numbersCheckBox.isChecked())
         
-        Preferences.setUI(
-            "SingleCloseButton",
-            self.tabsCloseButtonCheckBox.isChecked())
-        
         Preferences.setUI("SidebarDelay", self.delaySpinBox.value())
         
     def __populateStyleCombo(self):
@@ -211,8 +209,7 @@
         
     def __populateLanguageCombo(self):
         """
-        Private method to initialize the language combobox of the Interface
-        configuration page.
+        Private method to initialize the language combo box.
         """
         self.languageComboBox.clear()
         
@@ -248,7 +245,21 @@
         for locale in localeList:
             self.languageComboBox.addItem(locales[locale], locale)
         self.languageComboBox.setCurrentIndex(currentIndex)
+    
+    def __populateShellPositionCombo(self):
+        """
+        Private method to initialize the shell position combo box.
+        """
+        self.shellPositionComboBox.addItem(self.tr("Left Side"), "left")
+        self.shellPositionComboBox.addItem(self.tr("Right Side"), "right")
+        self.shellPositionComboBox.addItem(self.tr("Bottom Side"), "bottom")
         
+        shellPosition = Preferences.getUI("ShellPosition")
+        if shellPosition not in ("left", "right", "bottom"):
+            shellPosition = "bottom"
+        index = self.shellPositionComboBox.findData(shellPosition)
+        self.shellPositionComboBox.setCurrentIndex(index)
+    
     @pyqtSlot()
     def on_resetLayoutButton_clicked(self):
         """
--- a/eric6/Preferences/ConfigurationPages/InterfacePage.ui	Sat May 04 14:34:51 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/InterfacePage.ui	Sat May 04 14:44:11 2019 +0200
@@ -7,10 +7,10 @@
     <x>0</x>
     <y>0</y>
     <width>557</width>
-    <height>1300</height>
+    <height>858</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_3">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <widget class="QLabel" name="headerLabel">
      <property name="text">
@@ -328,6 +328,20 @@
        </item>
       </widget>
      </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_6">
+       <property name="text">
+        <string>Shell Position:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QComboBox" name="shellPositionComboBox">
+       <property name="toolTip">
+        <string>Select the position for the Shell window</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
@@ -457,22 +471,6 @@
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="tabsGroupBox">
-     <property name="title">
-      <string>Tabs</string>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_2">
-      <item>
-       <widget class="QCheckBox" name="tabsCloseButtonCheckBox">
-        <property name="text">
-         <string>Show only one close button instead of one for each tab</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -515,6 +513,7 @@
   <tabstop>delaySpinBox</tabstop>
   <tabstop>languageComboBox</tabstop>
   <tabstop>layoutComboBox</tabstop>
+  <tabstop>shellPositionComboBox</tabstop>
   <tabstop>templateViewerCheckBox</tabstop>
   <tabstop>fileBrowserCheckBox</tabstop>
   <tabstop>symbolsCheckBox</tabstop>
@@ -524,7 +523,6 @@
   <tabstop>cooperationCheckBox</tabstop>
   <tabstop>ircCheckBox</tabstop>
   <tabstop>numbersCheckBox</tabstop>
-  <tabstop>tabsCloseButtonCheckBox</tabstop>
   <tabstop>resetLayoutButton</tabstop>
  </tabstops>
  <resources/>
--- a/eric6/Preferences/__init__.py	Sat May 04 14:34:51 2019 +0200
+++ b/eric6/Preferences/__init__.py	Sat May 04 14:44:11 2019 +0200
@@ -138,6 +138,7 @@
         "StyleSheet": "",
         "ViewManager": "tabview",
         "LayoutType": "Sidebars",           # "Toolboxes" or "Sidebars"
+        "ShellPosition": "bottom",          # "left", "right" or "bottom"
         "SidebarDelay": 200,
         "BrowsersListFoldersFirst": True,
         "BrowsersHideNonPublic": False,
@@ -197,7 +198,6 @@
         "ToolbarManagerState": QByteArray(),
         "PreviewSplitterState": QByteArray(),
         "ShowSplash": True,
-        "SingleCloseButton": False,
         "SplitOrientationVertical": False,
         "UseNativeMenuBar": True,
         
@@ -1985,7 +1985,7 @@
                "SingleApplicationMode", "TabViewManagerFilenameOnly",
                "ShowFilePreview", "ShowFilePreviewJS", "ShowFilePreviewSSI",
                "CaptionShowsFilename", "ShowSplash",
-               "SingleCloseButton", "SplitOrientationVertical",
+               "SplitOrientationVertical",
                "UseProxy", "UseSystemProxy", "UseHttpProxyForAll",
                "RequestDownloadFilename",
                "CheckErrorLog", "NotificationsEnabled", "DynamicOnlineCheck",
--- a/eric6/UI/UserInterface.py	Sat May 04 14:34:51 2019 +0200
+++ b/eric6/UI/UserInterface.py	Sat May 04 14:44:11 2019 +0200
@@ -316,6 +316,7 @@
         self.__notification = None
         self.__readingSession = False
         self.__versionsDialog = None
+        self.__configurationDialog = None
         
         # now setup the connections
         splash.showMessage(self.tr("Setting up connections..."))
@@ -809,6 +810,10 @@
         self.__setupDockWindow(self.rToolboxDock, Qt.RightDockWidgetArea,
                                self.rToolbox, self.tr("Right Toolbox"))
         
+        ####################################################
+        ## Populate the left toolbox
+        ####################################################
+        
         # Create the project browser
         logging.debug("Creating Project Browser...")
         from Project.ProjectBrowser import ProjectBrowser
@@ -836,6 +841,10 @@
                                   UI.PixmapCache.getIcon("templateViewer.png"),
                                   self.tr("Template-Viewer"))
         
+        ####################################################
+        ## Populate the right toolbox
+        ####################################################
+        
         if Preferences.getUI("ShowCodeDocumentationViewer"):
             # Create the code documentation viewer
             logging.debug("Creating Code Documentation Viewer...")
@@ -889,6 +898,10 @@
                                   UI.PixmapCache.getIcon("irc.png"),
                                   self.tr("IRC"))
         
+        ####################################################
+        ## Populate the bottom toolbox
+        ####################################################
+        
         # Create the task viewer part of the user interface
         logging.debug("Creating Task Viewer...")
         from Tasks.TaskViewer import TaskViewer
@@ -905,18 +918,6 @@
                               UI.PixmapCache.getIcon("logViewer.png"),
                               self.tr("Log-Viewer"))
 
-        # Create the shell
-        # TODO: shell should be available in left or right toolbox
-        #       alternatively
-        logging.debug("Creating Shell...")
-        from QScintilla.Shell import ShellAssembly
-        self.shellAssembly = \
-            ShellAssembly(debugServer, self.viewmanager, self.project, 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...")
@@ -944,6 +945,33 @@
                                   UI.PixmapCache.getIcon("numbers.png"),
                                   self.tr("Numbers"))
         
+        ####################################################
+        ## Populate the configurable widgets
+        ####################################################
+        
+        # Create the shell
+        logging.debug("Creating Shell...")
+        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
+        from QScintilla.Shell import ShellAssembly
+        self.shellAssembly = \
+            ShellAssembly(debugServer, self.viewmanager, self.project, True)
+        self.shell = self.shellAssembly.shell()
+        self.__shellParent.widget().insertItem(
+            0, self.shellAssembly, UI.PixmapCache.getIcon("shell.png"),
+            self.tr("Shell"))
+        
+        ####################################################
+        ## Set the start index of each toolbox
+        ####################################################
+        
+        self.lToolbox.setCurrentIndex(0)
+        self.rToolbox.setCurrentIndex(0)
         self.hToolbox.setCurrentIndex(0)
         
     def __createSidebarsLayout(self, debugServer):
@@ -966,6 +994,10 @@
         # Create the right sidebar
         self.rightSidebar = E5SideBar(E5SideBar.East, delay)
         
+        ####################################################
+        ## Populate the left side bar
+        ####################################################
+        
         # Create the project browser
         logging.debug("Creating Project Browser...")
         from Project.ProjectBrowser import ProjectBrowser
@@ -996,6 +1028,10 @@
                 UI.PixmapCache.getIcon("templateViewer.png"),
                 self.tr("Template-Viewer"))
 
+        ####################################################
+        ## Populate the right side bar
+        ####################################################
+        
         if Preferences.getUI("ShowCodeDocumentationViewer"):
             # Create the code documentation viewer
             logging.debug("Creating Code Documentation Viewer...")
@@ -1050,6 +1086,10 @@
                 self.irc, UI.PixmapCache.getIcon("irc.png"),
                 self.tr("IRC"))
         
+        ####################################################
+        ## Populate the bottom side bar
+        ####################################################
+        
         # Create the task viewer part of the user interface
         logging.debug("Creating Task Viewer...")
         from Tasks.TaskViewer import TaskViewer
@@ -1066,18 +1106,6 @@
                                   UI.PixmapCache.getIcon("logViewer.png"),
                                   self.tr("Log-Viewer"))
 
-        # Create the shell
-        # TODO: shell should be available in left or right sidebar
-        #       alternatively
-        logging.debug("Creating Shell...")
-        from QScintilla.Shell import ShellAssembly
-        self.shellAssembly = \
-            ShellAssembly(debugServer, self.viewmanager, self.project, True)
-        self.shell = self.shellAssembly.shell()
-        self.bottomSidebar.insertTab(0, self.shellAssembly,
-                                     UI.PixmapCache.getIcon("shell.png"),
-                                     self.tr("Shell"))
-
         if Preferences.getUI("ShowFileBrowser"):
             # Create the file browser
             logging.debug("Creating File Browser...")
@@ -1105,6 +1133,33 @@
                                       UI.PixmapCache.getIcon("numbers.png"),
                                       self.tr("Numbers"))
         
+        ####################################################
+        ## Populate the configurable widgets
+        ####################################################
+        
+        # Create the shell
+        logging.debug("Creating Shell...")
+        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
+        from QScintilla.Shell import ShellAssembly
+        self.shellAssembly = \
+            ShellAssembly(debugServer, self.viewmanager, self.project, True)
+        self.shell = self.shellAssembly.shell()
+        self.__shellParent.insertTab(0, self.shellAssembly,
+                                     UI.PixmapCache.getIcon("shell.png"),
+                                     self.tr("Shell"))
+        
+        ####################################################
+        ## Set the start index of each side bar
+        ####################################################
+        
+        self.leftSidebar.setCurrentIndex(0)
+        self.rightSidebar.setCurrentIndex(0)
         self.bottomSidebar.setCurrentIndex(0)
         
         # create the central widget
@@ -2833,6 +2888,8 @@
         except AttributeError:
             # Qt4
             pass
+        if self.__shellPosition == "left":
+            self.__menus["subwindow"].addAction(self.shellActivateAct)
         self.__menus["subwindow"].addAction(self.pbActivateAct)
         self.__menus["subwindow"].addAction(self.mpbActivateAct)
         if self.templateViewer is not None:
@@ -2847,7 +2904,8 @@
         except AttributeError:
             # Qt4
             self.__menus["subwindow"].addSeparator()
-        self.__menus["subwindow"].addAction(self.shellActivateAct)
+        if self.__shellPosition == "bottom":
+            self.__menus["subwindow"].addAction(self.shellActivateAct)
         self.__menus["subwindow"].addAction(self.taskViewerActivateAct)
         self.__menus["subwindow"].addAction(self.logViewerActivateAct)
         if self.numbersViewer is not None:
@@ -2858,6 +2916,8 @@
             # Qt4
             self.__menus["subwindow"].addSeparator()
         # right side
+        if self.__shellPosition == "right":
+            self.__menus["subwindow"].addAction(self.shellActivateAct)
         if self.codeDocumentationViewer is not None:
             self.__menus["subwindow"].addAction(
                 self.tr("Code Documentation Viewer"),
@@ -4189,8 +4249,6 @@
         elif self.__layoutType == "Sidebars":
             self.leftSidebar.show()
             self.leftSidebar.setCurrentWidget(self.projectBrowser)
-        else:
-            self.projectBrowser.show()
         self.projectBrowser.currentWidget().setFocus(
             Qt.ActiveWindowFocusReason)
         
@@ -4204,8 +4262,6 @@
         elif self.__layoutType == "Sidebars":
             self.leftSidebar.show()
             self.leftSidebar.setCurrentWidget(self.multiProjectBrowser)
-        else:
-            self.multiProjectBrowser.show()
         self.multiProjectBrowser.setFocus(Qt.ActiveWindowFocusReason)
         
     def activateDebugViewer(self):
@@ -4218,8 +4274,6 @@
         elif self.__layoutType == "Sidebars":
             self.rightSidebar.show()
             self.rightSidebar.setCurrentWidget(self.debugViewer)
-        else:
-            self.debugViewer.show()
         self.debugViewer.currentWidget().setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateShell(self):
@@ -4227,13 +4281,11 @@
         Private slot to handle the activation of the Shell window.
         """
         if self.__layoutType == "Toolboxes":
-            self.hToolboxDock.show()
-            self.hToolbox.setCurrentWidget(self.shellAssembly)
+            self.__shellParent.show()
+            self.__shellParent.widget().setCurrentWidget(self.shellAssembly)
         elif self.__layoutType == "Sidebars":
-            self.bottomSidebar.show()
-            self.bottomSidebar.setCurrentWidget(self.shellAssembly)
-        else:
-            self.shell.show()
+            self.__shellParent.show()
+            self.__shellParent.setCurrentWidget(self.shellAssembly)
         self.shell.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateLogViewer(self):
@@ -4246,8 +4298,6 @@
         elif self.__layoutType == "Sidebars":
             self.bottomSidebar.show()
             self.bottomSidebar.setCurrentWidget(self.logViewer)
-        else:
-            self.logViewer.show()
         self.logViewer.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateTaskViewer(self):
@@ -4260,8 +4310,6 @@
         elif self.__layoutType == "Sidebars":
             self.bottomSidebar.show()
             self.bottomSidebar.setCurrentWidget(self.taskViewer)
-        else:
-            self.taskViewer.show()
         self.taskViewer.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateTemplateViewer(self):
@@ -4275,8 +4323,6 @@
             elif self.__layoutType == "Sidebars":
                 self.leftSidebar.show()
                 self.leftSidebar.setCurrentWidget(self.templateViewer)
-            else:
-                self.templateViewer.show()
             self.templateViewer.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateBrowser(self):
@@ -4290,8 +4336,6 @@
             elif self.__layoutType == "Sidebars":
                 self.leftSidebar.show()
                 self.leftSidebar.setCurrentWidget(self.browser)
-            else:
-                self.browser.show()
             self.browser.setFocus(Qt.ActiveWindowFocusReason)
         
     def __toggleLeftToolbox(self):
@@ -4380,8 +4424,6 @@
             elif self.__layoutType == "Sidebars":
                 self.rightSidebar.show()
                 self.rightSidebar.setCurrentWidget(self.cooperation)
-            else:
-                self.cooperation.show()
             self.cooperation.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateIRC(self):
@@ -4395,8 +4437,6 @@
             elif self.__layoutType == "Sidebars":
                 self.rightSidebar.show()
                 self.rightSidebar.setCurrentWidget(self.irc)
-            else:
-                self.irc.show()
             self.irc.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateSymbolsViewer(self):
@@ -4410,8 +4450,6 @@
             elif self.__layoutType == "Sidebars":
                 self.leftSidebar.show()
                 self.leftSidebar.setCurrentWidget(self.symbolsViewer)
-            else:
-                self.symbolsViewer.show()
             self.symbolsViewer.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateNumbersViewer(self):
@@ -4425,8 +4463,6 @@
             elif self.__layoutType == "Sidebars":
                 self.bottomSidebar.show()
                 self.bottomSidebar.setCurrentWidget(self.numbersViewer)
-            else:
-                self.numbersViewer.show()
             self.numbersViewer.setFocus(Qt.ActiveWindowFocusReason)
         
     def __activateViewmanager(self):
@@ -4452,8 +4488,6 @@
                 self.rightSidebar.show()
                 self.rightSidebar.setCurrentWidget(
                     self.codeDocumentationViewer)
-            else:
-                self.codeDocumentationViewer.show()
             if switchFocus:
                 self.codeDocumentationViewer.setFocus(
                     Qt.ActiveWindowFocusReason)
@@ -4469,8 +4503,6 @@
             elif self.__layoutType == "Sidebars":
                 self.rightSidebar.show()
                 self.rightSidebar.setCurrentWidget(self.pipWidget)
-            else:
-                self.pipWidget.show()
             self.pipWidget.setFocus(Qt.ActiveWindowFocusReason)
     
     def __activateCondaWidget(self):
@@ -4484,8 +4516,6 @@
             elif self.__layoutType == "Sidebars":
                 self.rightSidebar.show()
                 self.rightSidebar.setCurrentWidget(self.condaWidget)
-            else:
-                self.condaWidget.show()
             self.condaWidget.setFocus(Qt.ActiveWindowFocusReason)
     
     def __toggleWindow(self, w):
@@ -5846,28 +5876,39 @@
         
         @param pageName name of the configuration page to show (string)
         """
-        from Preferences.ConfigurationDialog import ConfigurationDialog
-        dlg = ConfigurationDialog(
-            self, 'Configuration',
-            expandedEntries=self.__expandedConfigurationEntries,
-        )
-        dlg.preferencesChanged.connect(self.__preferencesChanged)
-        dlg.masterPasswordChanged.connect(self.__masterPasswordChanged)
-        dlg.show()
-        if pageName is not None:
-            dlg.showConfigurationPageByName(pageName)
-        elif self.__lastConfigurationPageName:
-            dlg.showConfigurationPageByName(self.__lastConfigurationPageName)
-        else:
-            dlg.showConfigurationPageByName("empty")
-        dlg.exec_()
-        QApplication.processEvents()
-        if dlg.result() == QDialog.Accepted:
-            dlg.setPreferences()
-            Preferences.syncPreferences()
-            self.__preferencesChanged()
-        self.__lastConfigurationPageName = dlg.getConfigurationPageName()
-        self.__expandedConfigurationEntries = dlg.getExpandedEntries()
+        if self.__configurationDialog is None:
+            # only one invocation at a time is allowed
+            from Preferences.ConfigurationDialog import ConfigurationDialog
+            self.__configurationDialog = ConfigurationDialog(
+                self, 'Configuration',
+                expandedEntries=self.__expandedConfigurationEntries,
+            )
+            self.__configurationDialog.preferencesChanged.connect(
+                self.__preferencesChanged)
+            self.__configurationDialog.masterPasswordChanged.connect(
+                self.__masterPasswordChanged)
+            self.__configurationDialog.show()
+            if pageName is not None:
+                self.__configurationDialog.showConfigurationPageByName(
+                    pageName)
+            elif self.__lastConfigurationPageName:
+                self.__configurationDialog.showConfigurationPageByName(
+                    self.__lastConfigurationPageName)
+            else:
+                self.__configurationDialog.showConfigurationPageByName("empty")
+            self.__configurationDialog.exec_()
+            QApplication.processEvents()
+            if self.__configurationDialog.result() == QDialog.Accepted:
+                self.__configurationDialog.setPreferences()
+                Preferences.syncPreferences()
+                self.__preferencesChanged()
+            self.__lastConfigurationPageName = \
+                self.__configurationDialog.getConfigurationPageName()
+            self.__expandedConfigurationEntries = \
+                self.__configurationDialog.getExpandedEntries()
+            
+            self.__configurationDialog.deleteLater()
+            self.__configurationDialog = None
         
     def __exportPreferences(self):
         """

eric ide

mercurial