Graphics/UMLGraphicsView.py

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

eric ide

mercurial