src/eric7/EricWidgets/EricToolBarDialog.py

branch
eric7
changeset 10869
3ea51d5cd462
parent 10689
3ede487187f2
child 10885
f6544d6924d0
--- a/src/eric7/EricWidgets/EricToolBarDialog.py	Sat Jul 27 14:22:24 2024 +0200
+++ b/src/eric7/EricWidgets/EricToolBarDialog.py	Sat Jul 27 17:23:40 2024 +0200
@@ -9,10 +9,11 @@
 
 from dataclasses import dataclass
 
-from PyQt6.QtCore import Qt, pyqtSlot
+from PyQt6.QtCore import QItemSelectionModel, Qt, pyqtSlot
 from PyQt6.QtGui import QColor
 from PyQt6.QtWidgets import (
     QAbstractButton,
+    QAbstractItemView,
     QDialog,
     QDialogButtonBox,
     QInputDialog,
@@ -137,12 +138,6 @@
                         self.__toolBarItemToWidgetActionID[id(tbItem)].append(aID)
             tbItem.actionIDs = actionIDs
             self.toolbarComboBox.addItem(tb.windowTitle(), int(id(tbItem)))
-            if default:
-                self.toolbarComboBox.setItemData(
-                    self.toolbarComboBox.count() - 1,
-                    QColor(Qt.GlobalColor.darkGreen),
-                    Qt.ItemDataRole.ForegroundRole,
-                )
         self.toolbarComboBox.model().sort(0)
 
         self.toolbarComboBox.currentIndexChanged[int].connect(
@@ -302,6 +297,18 @@
                     )
         self.toolbarActionsList.setCurrentRow(0)
 
+        category = self.toolbarComboBox.itemText(index)
+        for index in range(self.actionsTree.topLevelItemCount()):
+            topItem = self.actionsTree.topLevelItem(index)
+            if topItem.text(0) == category:
+                self.actionsTree.setCurrentItem(
+                    topItem, 0, QItemSelectionModel.SelectionFlag.SelectCurrent
+                )
+                self.actionsTree.scrollToItem(
+                    topItem, QAbstractItemView.ScrollHint.PositionAtTop
+                )
+                break
+
         self.__setupButtons()
 
     @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)

eric ide

mercurial