7 Module implementing a toolbar configuration dialog. |
7 Module implementing a toolbar configuration dialog. |
8 """ |
8 """ |
9 |
9 |
10 from dataclasses import dataclass |
10 from dataclasses import dataclass |
11 |
11 |
12 from PyQt6.QtCore import Qt, pyqtSlot |
12 from PyQt6.QtCore import QItemSelectionModel, Qt, pyqtSlot |
13 from PyQt6.QtGui import QColor |
13 from PyQt6.QtGui import QColor |
14 from PyQt6.QtWidgets import ( |
14 from PyQt6.QtWidgets import ( |
15 QAbstractButton, |
15 QAbstractButton, |
|
16 QAbstractItemView, |
16 QDialog, |
17 QDialog, |
17 QDialogButtonBox, |
18 QDialogButtonBox, |
18 QInputDialog, |
19 QInputDialog, |
19 QLineEdit, |
20 QLineEdit, |
20 QListWidgetItem, |
21 QListWidgetItem, |
135 if aID in self.__widgetActionToToolBarItemID: |
136 if aID in self.__widgetActionToToolBarItemID: |
136 self.__widgetActionToToolBarItemID[aID] = id(tbItem) |
137 self.__widgetActionToToolBarItemID[aID] = id(tbItem) |
137 self.__toolBarItemToWidgetActionID[id(tbItem)].append(aID) |
138 self.__toolBarItemToWidgetActionID[id(tbItem)].append(aID) |
138 tbItem.actionIDs = actionIDs |
139 tbItem.actionIDs = actionIDs |
139 self.toolbarComboBox.addItem(tb.windowTitle(), int(id(tbItem))) |
140 self.toolbarComboBox.addItem(tb.windowTitle(), int(id(tbItem))) |
140 if default: |
|
141 self.toolbarComboBox.setItemData( |
|
142 self.toolbarComboBox.count() - 1, |
|
143 QColor(Qt.GlobalColor.darkGreen), |
|
144 Qt.ItemDataRole.ForegroundRole, |
|
145 ) |
|
146 self.toolbarComboBox.model().sort(0) |
141 self.toolbarComboBox.model().sort(0) |
147 |
142 |
148 self.toolbarComboBox.currentIndexChanged[int].connect( |
143 self.toolbarComboBox.currentIndexChanged[int].connect( |
149 self.__toolbarComboBox_currentIndexChanged |
144 self.__toolbarComboBox_currentIndexChanged |
150 ) |
145 ) |
299 item.setData(EricToolBarDialog.WidgetActionRole, True) |
294 item.setData(EricToolBarDialog.WidgetActionRole, True) |
300 item.setData( |
295 item.setData( |
301 Qt.ItemDataRole.ForegroundRole, QColor(Qt.GlobalColor.blue) |
296 Qt.ItemDataRole.ForegroundRole, QColor(Qt.GlobalColor.blue) |
302 ) |
297 ) |
303 self.toolbarActionsList.setCurrentRow(0) |
298 self.toolbarActionsList.setCurrentRow(0) |
|
299 |
|
300 category = self.toolbarComboBox.itemText(index) |
|
301 for index in range(self.actionsTree.topLevelItemCount()): |
|
302 topItem = self.actionsTree.topLevelItem(index) |
|
303 if topItem.text(0) == category: |
|
304 self.actionsTree.setCurrentItem( |
|
305 topItem, 0, QItemSelectionModel.SelectionFlag.SelectCurrent |
|
306 ) |
|
307 self.actionsTree.scrollToItem( |
|
308 topItem, QAbstractItemView.ScrollHint.PositionAtTop |
|
309 ) |
|
310 break |
304 |
311 |
305 self.__setupButtons() |
312 self.__setupButtons() |
306 |
313 |
307 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
314 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
308 def on_actionsTree_currentItemChanged(self, _current, _previous): |
315 def on_actionsTree_currentItemChanged(self, _current, _previous): |