src/eric7/UI/UserInterface.py

branch
eric7-maintenance
changeset 10534
783d835d7fe4
parent 10460
3b34efa2857c
parent 10518
1682f3203ae5
child 10616
4aa36fcd4a30
--- a/src/eric7/UI/UserInterface.py	Mon Jan 01 11:11:21 2024 +0100
+++ b/src/eric7/UI/UserInterface.py	Wed Jan 31 09:13:13 2024 +0100
@@ -9,6 +9,7 @@
 
 import contextlib
 import datetime
+import enum
 import functools
 import getpass
 import json
@@ -174,6 +175,16 @@
         self.__nWrite(self.__bufferedWrite())
 
 
+class UserInterfaceSide(enum.Enum):
+    """
+    Class defining the supported sides of the user interface.
+    """
+
+    Left = 1
+    Bottom = 2
+    Right = 3
+
+
 class UserInterface(EricMainWindow):
     """
     Class implementing the main user interface.
@@ -201,10 +212,6 @@
     maxFilePathLen = 100
     maxMenuFilePathLen = 75
 
-    LeftSide = 1
-    BottomSide = 2
-    RightSide = 3
-
     ErrorLogFileName = "eric7_error.log"
 
     def __init__(
@@ -578,6 +585,11 @@
         if self.pipWidget is not None:
             self.preferencesChanged.connect(self.pipWidget.preferencesChanged)
 
+        if self.microPythonWidget is not None:
+            self.microPythonWidget.aboutToDisconnect.connect(
+                self.viewmanager.closeDeviceEditors
+            )
+
         # create the toolbar manager object
         self.toolbarManager = EricToolBarManager(self, self)
         self.toolbarManager.setMainWindow(self)
@@ -1080,6 +1092,7 @@
             self.hToolbox,
             self.tr("Horizontal Toolbox"),
         )
+        self.hToolbox.currentChanged.connect(self.__hToolboxCurrentChanged)
 
         # Create the right toolbox
         self.rToolboxDock = self.__createDockWindow("rToolboxDock")
@@ -1263,6 +1276,7 @@
             EricSideBarSide.SOUTH, Preferences.getUI("IconBarSize")
         )
         self.bottomSidebar.setIconBarColor(Preferences.getUI("IconBarColor"))
+        self.bottomSidebar.currentChanged.connect(self.__bottomSidebarCurrentChanged)
 
         # Create the right sidebar
         if Preferences.getUI("CombinedLeftRightSidebar"):
@@ -1467,8 +1481,7 @@
         Public method to add a widget to the sides.
 
         @param side side to add the widget to
-        @type int (one of UserInterface.LeftSide, UserInterface.BottomSide,
-            UserInterface.RightSide)
+        @type UserInterfaceSide
         @param widget reference to the widget to add
         @type QWidget
         @param icon icon to be used
@@ -1476,28 +1489,23 @@
         @param label label text to be shown
         @type str
         """
-        if side in [
-            UserInterface.LeftSide,
-            UserInterface.BottomSide,
-            UserInterface.RightSide,
-        ]:
-            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":
-                if side == UserInterface.LeftSide:
+        if self.__layoutType == "Toolboxes":
+            if side == UserInterfaceSide.Left:
+                self.lToolbox.addItem(widget, icon, label)
+            elif side == UserInterfaceSide.Bottom:
+                self.hToolbox.addItem(widget, icon, label)
+            elif side == UserInterfaceSide.Right:
+                self.rToolbox.addItem(widget, icon, label)
+        elif self.__layoutType == "Sidebars":
+            if side == UserInterfaceSide.Left:
+                self.leftSidebar.addTab(widget, icon, label)
+            elif side == UserInterfaceSide.Bottom:
+                self.bottomSidebar.addTab(widget, icon, label)
+            elif side == UserInterfaceSide.Right:
+                if self.rightSidebar:
+                    self.rightSidebar.addTab(widget, icon, label)
+                else:
                     self.leftSidebar.addTab(widget, icon, label)
-                elif side == UserInterface.BottomSide:
-                    self.bottomSidebar.addTab(widget, icon, label)
-                elif side == UserInterface.RightSide:
-                    if self.rightSidebar:
-                        self.rightSidebar.addTab(widget, icon, label)
-                    else:
-                        self.leftSidebar.addTab(widget, icon, label)
 
     def removeSideWidget(self, widget):
         """
@@ -1555,6 +1563,19 @@
                 self.bottomSidebar.show()
                 self.bottomSidebar.setCurrentWidget(self.logViewer)
                 self.bottomSidebar.raise_()
+        else:
+            if self.__layoutType == "Toolboxes":
+                logViewerIndex = self.hToolbox.indexOf(self.logViewer)
+                if self.hToolbox.currentIndex() != logViewerIndex:
+                    self.hToolbox.setTabIcon(
+                        logViewerIndex, EricPixmapCache.getIcon("logViewerNew")
+                    )
+            elif self.__layoutType == "Sidebars":
+                logViewerIndex = self.bottomSidebar.indexOf(self.logViewer)
+                if self.bottomSidebar.currentIndex() != logViewerIndex:
+                    self.bottomSidebar.setTabIcon(
+                        logViewerIndex, EricPixmapCache.getIcon("sbLogViewerNew96")
+                    )
 
     def __openOnStartup(self, startupType=None):
         """
@@ -1800,31 +1821,37 @@
 
         if self.passiveMode:
             if not self.capProject and not self.capEditor:
-                self.setWindowTitle(self.tr("{0} - Passive Mode").format(Program))
+                self.setWindowTitle(self.tr("{0} - Passive Mode").format("eric-ide"))
             elif self.capProject and not self.capEditor:
                 self.setWindowTitle(
-                    self.tr("{0} - {1} - Passive Mode").format(self.capProject, Program)
+                    self.tr("{0} - {1} - Passive Mode").format(
+                        self.capProject, "eric-ide"
+                    )
                 )
             elif not self.capProject and self.capEditor:
                 self.setWindowTitle(
-                    self.tr("{0} - {1} - Passive Mode").format(self.capEditor, Program)
+                    self.tr("{0} - {1} - Passive Mode").format(
+                        self.capEditor, "eric-ide"
+                    )
                 )
             else:
                 self.setWindowTitle(
                     self.tr("{0} - {1} - {2} - Passive Mode").format(
-                        self.capProject, self.capEditor, Program
+                        self.capProject, self.capEditor, "eric-ide"
                     )
                 )
         else:
             if not self.capProject and not self.capEditor:
-                self.setWindowTitle(Program)
+                self.setWindowTitle("eric-ide")
             elif self.capProject and not self.capEditor:
-                self.setWindowTitle("{0} - {1}".format(self.capProject, Program))
+                self.setWindowTitle("{0} - {1}".format(self.capProject, "eric-ide"))
             elif not self.capProject and self.capEditor:
-                self.setWindowTitle("{0} - {1}".format(self.capEditor, Program))
+                self.setWindowTitle("{0} - {1}".format(self.capEditor, "eric-ide"))
             else:
                 self.setWindowTitle(
-                    "{0} - {1} - {2}".format(self.capProject, self.capEditor, Program)
+                    "{0} - {1} - {2}".format(
+                        self.capProject, self.capEditor, "eric-ide"
+                    )
                 )
 
     def __initActions(self):
@@ -5594,9 +5621,17 @@
         if self.__layoutType == "Toolboxes":
             self.hToolboxDock.show()
             self.hToolbox.setCurrentWidget(self.logViewer)
+            self.hToolbox.setTabIcon(
+                self.hToolbox.currentIndex(),
+                EricPixmapCache.getIcon("logViewer"),
+            )
         elif self.__layoutType == "Sidebars":
             self.bottomSidebar.show()
             self.bottomSidebar.setCurrentWidget(self.logViewer)
+            self.bottomSidebar.setTabIcon(
+                self.bottomSidebar.currentIndex(),
+                EricPixmapCache.getIcon("sbLogViewer96"),
+            )
         self.logViewer.setFocus(Qt.FocusReason.ActiveWindowFocusReason)
 
     def __activateTaskViewer(self):
@@ -5679,6 +5714,17 @@
             if hasFocus:
                 self.__activateViewmanager()
 
+    @pyqtSlot(int)
+    def __hToolboxCurrentChanged(self, index):
+        """
+        Private slot handling a change of the current index of the Horizontal Toolbox.
+
+        @param index current index of the horizontal toolbox
+        @type int
+        """
+        if index == self.hToolbox.indexOf(self.logViewer):
+            self.hToolbox.setTabIcon(index, EricPixmapCache.getIcon("logViewer"))
+
     def __toggleLeftSidebar(self):
         """
         Private slot to handle the toggle of the left sidebar window.
@@ -5721,6 +5767,19 @@
             if hasFocus:
                 self.__activateViewmanager()
 
+    @pyqtSlot(int)
+    def __bottomSidebarCurrentChanged(self, index):
+        """
+        Private slot handling a change of the current index of the Bottom Sidebar.
+
+        @param index current index of the bottom sidebar
+        @type int
+        """
+        if index == self.bottomSidebar.indexOf(self.logViewer):
+            self.bottomSidebar.setTabIcon(
+                index, EricPixmapCache.getIcon("sbLogViewer96")
+            )
+
     def activateCooperationViewer(self):
         """
         Public slot to handle the activation of the cooperation window.
@@ -8343,29 +8402,14 @@
         if not Preferences.isConfigured():
             self.__initDebugToolbarsLayout()
 
-            if Preferences.hasEric6Configuration():
-                yes = EricMessageBox.yesNo(
-                    self,
-                    self.tr("First time usage"),
-                    self.tr(
-                        "eric7 has not been configured yet but an eric6"
-                        " configuration was found. Shall this be"
-                        " imported?"
-                    ),
-                    yesDefault=True,
-                )
-                if yes:
-                    Preferences.importEric6Configuration()
-            else:
-                EricMessageBox.information(
-                    self,
-                    self.tr("First time usage"),
-                    self.tr(
-                        """eric has not been configured yet. """
-                        """The configuration dialog will be started."""
-                    ),
-                )
-
+            EricMessageBox.information(
+                self,
+                self.tr("First time usage"),
+                self.tr(
+                    """eric has not been configured yet. """
+                    """The configuration dialog will be started."""
+                ),
+            )
             self.showPreferences()
             Preferences.setConfigured()
 

eric ide

mercurial