Graphics/UMLGraphicsView.py

changeset 3190
a9a94491c4fd
parent 3160
209a07d7e401
child 3345
071afe8be2a1
equal deleted inserted replaced
3189:9a21c547de5f 3190:a9a94491c4fd
74 self.alignMapper = QSignalMapper(self) 74 self.alignMapper = QSignalMapper(self)
75 self.alignMapper.mapped[int].connect(self.__alignShapes) 75 self.alignMapper.mapped[int].connect(self.__alignShapes)
76 76
77 self.deleteShapeAct = \ 77 self.deleteShapeAct = \
78 QAction(UI.PixmapCache.getIcon("deleteShape.png"), 78 QAction(UI.PixmapCache.getIcon("deleteShape.png"),
79 self.trUtf8("Delete shapes"), self) 79 self.tr("Delete shapes"), self)
80 self.deleteShapeAct.triggered[()].connect(self.__deleteShape) 80 self.deleteShapeAct.triggered[()].connect(self.__deleteShape)
81 81
82 self.incWidthAct = \ 82 self.incWidthAct = \
83 QAction(UI.PixmapCache.getIcon("sceneWidthInc.png"), 83 QAction(UI.PixmapCache.getIcon("sceneWidthInc.png"),
84 self.trUtf8("Increase width by {0} points").format( 84 self.tr("Increase width by {0} points").format(
85 self.deltaSize), 85 self.deltaSize),
86 self) 86 self)
87 self.incWidthAct.triggered[()].connect(self.__incWidth) 87 self.incWidthAct.triggered[()].connect(self.__incWidth)
88 88
89 self.incHeightAct = \ 89 self.incHeightAct = \
90 QAction(UI.PixmapCache.getIcon("sceneHeightInc.png"), 90 QAction(UI.PixmapCache.getIcon("sceneHeightInc.png"),
91 self.trUtf8("Increase height by {0} points").format( 91 self.tr("Increase height by {0} points").format(
92 self.deltaSize), 92 self.deltaSize),
93 self) 93 self)
94 self.incHeightAct.triggered[()].connect(self.__incHeight) 94 self.incHeightAct.triggered[()].connect(self.__incHeight)
95 95
96 self.decWidthAct = \ 96 self.decWidthAct = \
97 QAction(UI.PixmapCache.getIcon("sceneWidthDec.png"), 97 QAction(UI.PixmapCache.getIcon("sceneWidthDec.png"),
98 self.trUtf8("Decrease width by {0} points").format( 98 self.tr("Decrease width by {0} points").format(
99 self.deltaSize), 99 self.deltaSize),
100 self) 100 self)
101 self.decWidthAct.triggered[()].connect(self.__decWidth) 101 self.decWidthAct.triggered[()].connect(self.__decWidth)
102 102
103 self.decHeightAct = \ 103 self.decHeightAct = \
104 QAction(UI.PixmapCache.getIcon("sceneHeightDec.png"), 104 QAction(UI.PixmapCache.getIcon("sceneHeightDec.png"),
105 self.trUtf8("Decrease height by {0} points").format( 105 self.tr("Decrease height by {0} points").format(
106 self.deltaSize), 106 self.deltaSize),
107 self) 107 self)
108 self.decHeightAct.triggered[()].connect(self.__decHeight) 108 self.decHeightAct.triggered[()].connect(self.__decHeight)
109 109
110 self.setSizeAct = \ 110 self.setSizeAct = \
111 QAction(UI.PixmapCache.getIcon("sceneSize.png"), 111 QAction(UI.PixmapCache.getIcon("sceneSize.png"),
112 self.trUtf8("Set size"), self) 112 self.tr("Set size"), self)
113 self.setSizeAct.triggered[()].connect(self.__setSize) 113 self.setSizeAct.triggered[()].connect(self.__setSize)
114 114
115 self.rescanAct = \ 115 self.rescanAct = \
116 QAction(UI.PixmapCache.getIcon("rescan.png"), 116 QAction(UI.PixmapCache.getIcon("rescan.png"),
117 self.trUtf8("Re-Scan"), self) 117 self.tr("Re-Scan"), self)
118 self.rescanAct.triggered[()].connect(self.__rescan) 118 self.rescanAct.triggered[()].connect(self.__rescan)
119 119
120 self.relayoutAct = \ 120 self.relayoutAct = \
121 QAction(UI.PixmapCache.getIcon("relayout.png"), 121 QAction(UI.PixmapCache.getIcon("relayout.png"),
122 self.trUtf8("Re-Layout"), self) 122 self.tr("Re-Layout"), self)
123 self.relayoutAct.triggered[()].connect(self.__relayout) 123 self.relayoutAct.triggered[()].connect(self.__relayout)
124 124
125 self.alignLeftAct = \ 125 self.alignLeftAct = \
126 QAction(UI.PixmapCache.getIcon("shapesAlignLeft.png"), 126 QAction(UI.PixmapCache.getIcon("shapesAlignLeft.png"),
127 self.trUtf8("Align Left"), self) 127 self.tr("Align Left"), self)
128 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignLeft) 128 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignLeft)
129 self.alignLeftAct.triggered[()].connect(self.alignMapper.map) 129 self.alignLeftAct.triggered[()].connect(self.alignMapper.map)
130 130
131 self.alignHCenterAct = \ 131 self.alignHCenterAct = \
132 QAction(UI.PixmapCache.getIcon("shapesAlignHCenter.png"), 132 QAction(UI.PixmapCache.getIcon("shapesAlignHCenter.png"),
133 self.trUtf8("Align Center Horizontal"), self) 133 self.tr("Align Center Horizontal"), self)
134 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignHCenter) 134 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignHCenter)
135 self.alignHCenterAct.triggered[()].connect(self.alignMapper.map) 135 self.alignHCenterAct.triggered[()].connect(self.alignMapper.map)
136 136
137 self.alignRightAct = \ 137 self.alignRightAct = \
138 QAction(UI.PixmapCache.getIcon("shapesAlignRight.png"), 138 QAction(UI.PixmapCache.getIcon("shapesAlignRight.png"),
139 self.trUtf8("Align Right"), self) 139 self.tr("Align Right"), self)
140 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignRight) 140 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignRight)
141 self.alignRightAct.triggered[()].connect(self.alignMapper.map) 141 self.alignRightAct.triggered[()].connect(self.alignMapper.map)
142 142
143 self.alignTopAct = \ 143 self.alignTopAct = \
144 QAction(UI.PixmapCache.getIcon("shapesAlignTop.png"), 144 QAction(UI.PixmapCache.getIcon("shapesAlignTop.png"),
145 self.trUtf8("Align Top"), self) 145 self.tr("Align Top"), self)
146 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignTop) 146 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignTop)
147 self.alignTopAct.triggered[()].connect(self.alignMapper.map) 147 self.alignTopAct.triggered[()].connect(self.alignMapper.map)
148 148
149 self.alignVCenterAct = \ 149 self.alignVCenterAct = \
150 QAction(UI.PixmapCache.getIcon("shapesAlignVCenter.png"), 150 QAction(UI.PixmapCache.getIcon("shapesAlignVCenter.png"),
151 self.trUtf8("Align Center Vertical"), self) 151 self.tr("Align Center Vertical"), self)
152 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignVCenter) 152 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignVCenter)
153 self.alignVCenterAct.triggered[()].connect(self.alignMapper.map) 153 self.alignVCenterAct.triggered[()].connect(self.alignMapper.map)
154 154
155 self.alignBottomAct = \ 155 self.alignBottomAct = \
156 QAction(UI.PixmapCache.getIcon("shapesAlignBottom.png"), 156 QAction(UI.PixmapCache.getIcon("shapesAlignBottom.png"),
157 self.trUtf8("Align Bottom"), self) 157 self.tr("Align Bottom"), self)
158 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignBottom) 158 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignBottom)
159 self.alignBottomAct.triggered[()].connect(self.alignMapper.map) 159 self.alignBottomAct.triggered[()].connect(self.alignMapper.map)
160 160
161 def __checkSizeActions(self): 161 def __checkSizeActions(self):
162 """ 162 """
202 """ 202 """
203 Public method to populate a toolbar with our actions. 203 Public method to populate a toolbar with our actions.
204 204
205 @return the populated toolBar (QToolBar) 205 @return the populated toolBar (QToolBar)
206 """ 206 """
207 toolBar = QToolBar(self.trUtf8("Graphics"), self) 207 toolBar = QToolBar(self.tr("Graphics"), self)
208 toolBar.setIconSize(UI.Config.ToolBarIconSize) 208 toolBar.setIconSize(UI.Config.ToolBarIconSize)
209 toolBar.addAction(self.deleteShapeAct) 209 toolBar.addAction(self.deleteShapeAct)
210 toolBar.addSeparator() 210 toolBar.addSeparator()
211 toolBar.addAction(self.alignLeftAct) 211 toolBar.addAction(self.alignLeftAct)
212 toolBar.addAction(self.alignHCenterAct) 212 toolBar.addAction(self.alignHCenterAct)
326 """ 326 """
327 Public method to handle the save context menu entry. 327 Public method to handle the save context menu entry.
328 """ 328 """
329 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 329 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
330 self, 330 self,
331 self.trUtf8("Save Diagram"), 331 self.tr("Save Diagram"),
332 "", 332 "",
333 self.trUtf8("Portable Network Graphics (*.png);;" 333 self.tr("Portable Network Graphics (*.png);;"
334 "Scalable Vector Graphics (*.svg)"), 334 "Scalable Vector Graphics (*.svg)"),
335 "", 335 "",
336 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 336 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
337 if fname: 337 if fname:
338 ext = QFileInfo(fname).suffix() 338 ext = QFileInfo(fname).suffix()
339 if not ext: 339 if not ext:
341 if ex: 341 if ex:
342 fname += ex 342 fname += ex
343 if QFileInfo(fname).exists(): 343 if QFileInfo(fname).exists():
344 res = E5MessageBox.yesNo( 344 res = E5MessageBox.yesNo(
345 self, 345 self,
346 self.trUtf8("Save Diagram"), 346 self.tr("Save Diagram"),
347 self.trUtf8("<p>The file <b>{0}</b> already exists." 347 self.tr("<p>The file <b>{0}</b> already exists."
348 " Overwrite it?</p>").format(fname), 348 " Overwrite it?</p>").format(fname),
349 icon=E5MessageBox.Warning) 349 icon=E5MessageBox.Warning)
350 if not res: 350 if not res:
351 return 351 return
352 352
353 success = super().saveImage( 353 success = super().saveImage(
354 fname, QFileInfo(fname).suffix().upper()) 354 fname, QFileInfo(fname).suffix().upper())
355 if not success: 355 if not success:
356 E5MessageBox.critical( 356 E5MessageBox.critical(
357 self, 357 self,
358 self.trUtf8("Save Diagram"), 358 self.tr("Save Diagram"),
359 self.trUtf8( 359 self.tr(
360 """<p>The file <b>{0}</b> could not be saved.</p>""") 360 """<p>The file <b>{0}</b> could not be saved.</p>""")
361 .format(fname)) 361 .format(fname))
362 362
363 def __relayout(self): 363 def __relayout(self):
364 """ 364 """

eric ide

mercurial