12 from PyQt6.QtCore import pyqtSignal, Qt, QSignalMapper, QEvent, QRectF, QMarginsF |
12 from PyQt6.QtCore import pyqtSignal, Qt, QSignalMapper, QEvent, QRectF, QMarginsF |
13 from PyQt6.QtGui import QAction, QPageLayout |
13 from PyQt6.QtGui import QAction, QPageLayout |
14 from PyQt6.QtWidgets import QGraphicsView, QToolBar, QDialog |
14 from PyQt6.QtWidgets import QGraphicsView, QToolBar, QDialog |
15 from PyQt6.QtPrintSupport import QPrinter, QPrintDialog |
15 from PyQt6.QtPrintSupport import QPrinter, QPrintDialog |
16 |
16 |
17 from EricGraphics.EricGraphicsView import EricGraphicsView |
17 from eric7.EricGraphics.EricGraphicsView import EricGraphicsView |
18 |
18 |
19 from EricWidgets import EricMessageBox, EricFileDialog |
19 from eric7.EricWidgets import EricMessageBox, EricFileDialog |
20 from EricWidgets.EricZoomWidget import EricZoomWidget |
20 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
21 |
21 |
22 from .UMLItem import UMLItem |
22 from .UMLItem import UMLItem |
23 |
23 |
24 import UI.Config |
24 from eric7.EricGui import EricPixmapCache |
25 import UI.PixmapCache |
25 from eric7.UI import Config |
26 |
26 |
27 import Preferences |
27 from eric7 import Preferences |
28 |
28 |
29 |
29 |
30 class UMLGraphicsView(EricGraphicsView): |
30 class UMLGraphicsView(EricGraphicsView): |
31 """ |
31 """ |
32 Class implementing a specialized EricGraphicsView for our diagrams. |
32 Class implementing a specialized EricGraphicsView for our diagrams. |
85 except AttributeError: |
85 except AttributeError: |
86 # pre Qt 5.15 |
86 # pre Qt 5.15 |
87 self.alignMapper.mapped[int].connect(self.__alignShapes) |
87 self.alignMapper.mapped[int].connect(self.__alignShapes) |
88 |
88 |
89 self.deleteShapeAct = QAction( |
89 self.deleteShapeAct = QAction( |
90 UI.PixmapCache.getIcon("deleteShape"), self.tr("Delete shapes"), self |
90 EricPixmapCache.getIcon("deleteShape"), self.tr("Delete shapes"), self |
91 ) |
91 ) |
92 self.deleteShapeAct.triggered.connect(self.__deleteShape) |
92 self.deleteShapeAct.triggered.connect(self.__deleteShape) |
93 |
93 |
94 self.incWidthAct = QAction( |
94 self.incWidthAct = QAction( |
95 UI.PixmapCache.getIcon("sceneWidthInc"), |
95 EricPixmapCache.getIcon("sceneWidthInc"), |
96 self.tr("Increase width by {0} points").format(self.deltaSize), |
96 self.tr("Increase width by {0} points").format(self.deltaSize), |
97 self, |
97 self, |
98 ) |
98 ) |
99 self.incWidthAct.triggered.connect(self.__incWidth) |
99 self.incWidthAct.triggered.connect(self.__incWidth) |
100 |
100 |
101 self.incHeightAct = QAction( |
101 self.incHeightAct = QAction( |
102 UI.PixmapCache.getIcon("sceneHeightInc"), |
102 EricPixmapCache.getIcon("sceneHeightInc"), |
103 self.tr("Increase height by {0} points").format(self.deltaSize), |
103 self.tr("Increase height by {0} points").format(self.deltaSize), |
104 self, |
104 self, |
105 ) |
105 ) |
106 self.incHeightAct.triggered.connect(self.__incHeight) |
106 self.incHeightAct.triggered.connect(self.__incHeight) |
107 |
107 |
108 self.decWidthAct = QAction( |
108 self.decWidthAct = QAction( |
109 UI.PixmapCache.getIcon("sceneWidthDec"), |
109 EricPixmapCache.getIcon("sceneWidthDec"), |
110 self.tr("Decrease width by {0} points").format(self.deltaSize), |
110 self.tr("Decrease width by {0} points").format(self.deltaSize), |
111 self, |
111 self, |
112 ) |
112 ) |
113 self.decWidthAct.triggered.connect(self.__decWidth) |
113 self.decWidthAct.triggered.connect(self.__decWidth) |
114 |
114 |
115 self.decHeightAct = QAction( |
115 self.decHeightAct = QAction( |
116 UI.PixmapCache.getIcon("sceneHeightDec"), |
116 EricPixmapCache.getIcon("sceneHeightDec"), |
117 self.tr("Decrease height by {0} points").format(self.deltaSize), |
117 self.tr("Decrease height by {0} points").format(self.deltaSize), |
118 self, |
118 self, |
119 ) |
119 ) |
120 self.decHeightAct.triggered.connect(self.__decHeight) |
120 self.decHeightAct.triggered.connect(self.__decHeight) |
121 |
121 |
122 self.setSizeAct = QAction( |
122 self.setSizeAct = QAction( |
123 UI.PixmapCache.getIcon("sceneSize"), self.tr("Set size"), self |
123 EricPixmapCache.getIcon("sceneSize"), self.tr("Set size"), self |
124 ) |
124 ) |
125 self.setSizeAct.triggered.connect(self.__setSize) |
125 self.setSizeAct.triggered.connect(self.__setSize) |
126 |
126 |
127 self.rescanAct = QAction( |
127 self.rescanAct = QAction( |
128 UI.PixmapCache.getIcon("rescan"), self.tr("Re-Scan"), self |
128 EricPixmapCache.getIcon("rescan"), self.tr("Re-Scan"), self |
129 ) |
129 ) |
130 self.rescanAct.triggered.connect(self.__rescan) |
130 self.rescanAct.triggered.connect(self.__rescan) |
131 |
131 |
132 self.relayoutAct = QAction( |
132 self.relayoutAct = QAction( |
133 UI.PixmapCache.getIcon("relayout"), self.tr("Re-Layout"), self |
133 EricPixmapCache.getIcon("relayout"), self.tr("Re-Layout"), self |
134 ) |
134 ) |
135 self.relayoutAct.triggered.connect(self.__relayout) |
135 self.relayoutAct.triggered.connect(self.__relayout) |
136 |
136 |
137 self.alignLeftAct = QAction( |
137 self.alignLeftAct = QAction( |
138 UI.PixmapCache.getIcon("shapesAlignLeft"), self.tr("Align Left"), self |
138 EricPixmapCache.getIcon("shapesAlignLeft"), self.tr("Align Left"), self |
139 ) |
139 ) |
140 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignmentFlag.AlignLeft) |
140 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignmentFlag.AlignLeft) |
141 self.alignLeftAct.triggered.connect(self.alignMapper.map) |
141 self.alignLeftAct.triggered.connect(self.alignMapper.map) |
142 |
142 |
143 self.alignHCenterAct = QAction( |
143 self.alignHCenterAct = QAction( |
144 UI.PixmapCache.getIcon("shapesAlignHCenter"), |
144 EricPixmapCache.getIcon("shapesAlignHCenter"), |
145 self.tr("Align Center Horizontal"), |
145 self.tr("Align Center Horizontal"), |
146 self, |
146 self, |
147 ) |
147 ) |
148 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignmentFlag.AlignHCenter) |
148 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignmentFlag.AlignHCenter) |
149 self.alignHCenterAct.triggered.connect(self.alignMapper.map) |
149 self.alignHCenterAct.triggered.connect(self.alignMapper.map) |
150 |
150 |
151 self.alignRightAct = QAction( |
151 self.alignRightAct = QAction( |
152 UI.PixmapCache.getIcon("shapesAlignRight"), self.tr("Align Right"), self |
152 EricPixmapCache.getIcon("shapesAlignRight"), self.tr("Align Right"), self |
153 ) |
153 ) |
154 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignmentFlag.AlignRight) |
154 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignmentFlag.AlignRight) |
155 self.alignRightAct.triggered.connect(self.alignMapper.map) |
155 self.alignRightAct.triggered.connect(self.alignMapper.map) |
156 |
156 |
157 self.alignTopAct = QAction( |
157 self.alignTopAct = QAction( |
158 UI.PixmapCache.getIcon("shapesAlignTop"), self.tr("Align Top"), self |
158 EricPixmapCache.getIcon("shapesAlignTop"), self.tr("Align Top"), self |
159 ) |
159 ) |
160 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignmentFlag.AlignTop) |
160 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignmentFlag.AlignTop) |
161 self.alignTopAct.triggered.connect(self.alignMapper.map) |
161 self.alignTopAct.triggered.connect(self.alignMapper.map) |
162 |
162 |
163 self.alignVCenterAct = QAction( |
163 self.alignVCenterAct = QAction( |
164 UI.PixmapCache.getIcon("shapesAlignVCenter"), |
164 EricPixmapCache.getIcon("shapesAlignVCenter"), |
165 self.tr("Align Center Vertical"), |
165 self.tr("Align Center Vertical"), |
166 self, |
166 self, |
167 ) |
167 ) |
168 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignmentFlag.AlignVCenter) |
168 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignmentFlag.AlignVCenter) |
169 self.alignVCenterAct.triggered.connect(self.alignMapper.map) |
169 self.alignVCenterAct.triggered.connect(self.alignMapper.map) |
170 |
170 |
171 self.alignBottomAct = QAction( |
171 self.alignBottomAct = QAction( |
172 UI.PixmapCache.getIcon("shapesAlignBottom"), self.tr("Align Bottom"), self |
172 EricPixmapCache.getIcon("shapesAlignBottom"), self.tr("Align Bottom"), self |
173 ) |
173 ) |
174 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignmentFlag.AlignBottom) |
174 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignmentFlag.AlignBottom) |
175 self.alignBottomAct.triggered.connect(self.alignMapper.map) |
175 self.alignBottomAct.triggered.connect(self.alignMapper.map) |
176 |
176 |
177 def setLayoutActionsEnabled(self, enable): |
177 def setLayoutActionsEnabled(self, enable): |