4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing a toolbar configuration dialog. |
7 Module implementing a toolbar configuration dialog. |
8 """ |
8 """ |
|
9 |
|
10 from dataclasses import dataclass |
9 |
11 |
10 from PyQt6.QtCore import Qt, pyqtSlot |
12 from PyQt6.QtCore import Qt, pyqtSlot |
11 from PyQt6.QtGui import QColor |
13 from PyQt6.QtGui import QColor |
12 from PyQt6.QtWidgets import ( |
14 from PyQt6.QtWidgets import ( |
13 QAbstractButton, |
15 QAbstractButton, |
23 from eric7.EricWidgets import EricMessageBox |
25 from eric7.EricWidgets import EricMessageBox |
24 |
26 |
25 from .Ui_EricToolBarDialog import Ui_EricToolBarDialog |
27 from .Ui_EricToolBarDialog import Ui_EricToolBarDialog |
26 |
28 |
27 |
29 |
|
30 @dataclass |
28 class EricToolBarItem: |
31 class EricToolBarItem: |
29 """ |
32 """ |
30 Class storing data belonging to a toolbar entry of the toolbar dialog. |
33 Class storing data belonging to a toolbar entry of the toolbar dialog. |
31 """ |
34 """ |
32 |
35 |
33 def __init__(self, toolBarId, actionIDs, default): |
36 toolBarId: int |
34 """ |
37 actionIDs: list[int] |
35 Constructor |
38 isDefault: bool |
36 |
39 title: str = "" |
37 @param toolBarId id of the toolbar object (integer) |
40 isChanged: bool = False |
38 @param actionIDs list of action IDs belonging to the toolbar |
|
39 (list of integer) |
|
40 @param default flag indicating a default toolbar (boolean) |
|
41 """ |
|
42 self.toolBarId = toolBarId |
|
43 self.actionIDs = actionIDs[:] |
|
44 self.isDefault = default |
|
45 self.title = "" |
|
46 self.isChanged = False |
|
47 |
41 |
48 |
42 |
49 class EricToolBarDialog(QDialog, Ui_EricToolBarDialog): |
43 class EricToolBarDialog(QDialog, Ui_EricToolBarDialog): |
50 """ |
44 """ |
51 Class implementing a toolbar configuration dialog. |
45 Class implementing a toolbar configuration dialog. |
114 categoryItem.setExpanded(True) |
108 categoryItem.setExpanded(True) |
115 |
109 |
116 for tbID, actions in list(self.__manager.toolBarsActions().items()): |
110 for tbID, actions in list(self.__manager.toolBarsActions().items()): |
117 tb = self.__manager.toolBarById(tbID) |
111 tb = self.__manager.toolBarById(tbID) |
118 default = self.__manager.isDefaultToolBar(tb) |
112 default = self.__manager.isDefaultToolBar(tb) |
119 tbItem = EricToolBarItem(tbID, [], default) |
113 tbItem = EricToolBarItem( |
|
114 toolBarId=tbID, |
|
115 actionIDs=[], |
|
116 isDefault=default, |
|
117 ) |
120 self.__toolbarItems[id(tbItem)] = tbItem |
118 self.__toolbarItems[id(tbItem)] = tbItem |
121 self.__toolBarItemToWidgetActionID[id(tbItem)] = [] |
119 self.__toolBarItemToWidgetActionID[id(tbItem)] = [] |
122 actionIDs = [] |
120 actionIDs = [] |
123 for action in actions: |
121 for action in actions: |
124 if action is None: |
122 if action is None: |
165 """A toolbar with the name <b>{0}</b> already""" """ exists.""" |
163 """A toolbar with the name <b>{0}</b> already""" """ exists.""" |
166 ).format(name), |
164 ).format(name), |
167 ) |
165 ) |
168 return |
166 return |
169 |
167 |
170 tbItem = EricToolBarItem(None, [], False) |
168 tbItem = EricToolBarItem( |
|
169 toolBarId=None, |
|
170 actionIDs=[], |
|
171 isDefault=False, |
|
172 ) |
171 tbItem.title = name |
173 tbItem.title = name |
172 tbItem.isChanged = True |
174 tbItem.isChanged = True |
173 self.__toolbarItems[id(tbItem)] = tbItem |
175 self.__toolbarItems[id(tbItem)] = tbItem |
174 self.__toolBarItemToWidgetActionID[id(tbItem)] = [] |
176 self.__toolBarItemToWidgetActionID[id(tbItem)] = [] |
175 self.toolbarComboBox.addItem(name, int(id(tbItem))) |
177 self.toolbarComboBox.addItem(name, int(id(tbItem))) |