IconEditor/IconEditorWindow.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3345
071afe8be2a1
child 3591
2f2a4a76dd22
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
52 keyboard shortcuts (boolean) 52 keyboard shortcuts (boolean)
53 @keyparam project reference to the project object (Project) 53 @keyparam project reference to the project object (Project)
54 """ 54 """
55 super(IconEditorWindow, self).__init__(parent) 55 super(IconEditorWindow, self).__init__(parent)
56 self.setObjectName("eric5_icon_editor") 56 self.setObjectName("eric5_icon_editor")
57 self.setAttribute(Qt.WA_DeleteOnClose)
58 57
59 self.fromEric = fromEric 58 self.fromEric = fromEric
60 self.initShortcutsOnly = initShortcutsOnly 59 self.initShortcutsOnly = initShortcutsOnly
61 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png")) 60 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png"))
62 61
120 def __initFileFilters(self): 119 def __initFileFilters(self):
121 """ 120 """
122 Private method to define the supported image file filters. 121 Private method to define the supported image file filters.
123 """ 122 """
124 filters = { 123 filters = {
125 'bmp': self.trUtf8("Windows Bitmap File (*.bmp)"), 124 'bmp': self.tr("Windows Bitmap File (*.bmp)"),
126 'gif': self.trUtf8("Graphic Interchange Format File (*.gif)"), 125 'gif': self.tr("Graphic Interchange Format File (*.gif)"),
127 'ico': self.trUtf8("Windows Icon File (*.ico)"), 126 'ico': self.tr("Windows Icon File (*.ico)"),
128 'jpg': self.trUtf8("JPEG File (*.jpg)"), 127 'jpg': self.tr("JPEG File (*.jpg)"),
129 'jpeg': self.trUtf8("JPEG File (*.jpeg)"), 128 'jpeg': self.tr("JPEG File (*.jpeg)"),
130 'mng': self.trUtf8("Multiple-Image Network Graphics File (*.mng)"), 129 'mng': self.tr("Multiple-Image Network Graphics File (*.mng)"),
131 'pbm': self.trUtf8("Portable Bitmap File (*.pbm)"), 130 'pbm': self.tr("Portable Bitmap File (*.pbm)"),
132 'pcx': self.trUtf8("Paintbrush Bitmap File (*.pcx)"), 131 'pcx': self.tr("Paintbrush Bitmap File (*.pcx)"),
133 'pgm': self.trUtf8("Portable Graymap File (*.pgm)"), 132 'pgm': self.tr("Portable Graymap File (*.pgm)"),
134 'png': self.trUtf8("Portable Network Graphics File (*.png)"), 133 'png': self.tr("Portable Network Graphics File (*.png)"),
135 'ppm': self.trUtf8("Portable Pixmap File (*.ppm)"), 134 'ppm': self.tr("Portable Pixmap File (*.ppm)"),
136 'sgi': self.trUtf8("Silicon Graphics Image File (*.sgi)"), 135 'sgi': self.tr("Silicon Graphics Image File (*.sgi)"),
137 'svg': self.trUtf8("Scalable Vector Graphics File (*.svg)"), 136 'svg': self.tr("Scalable Vector Graphics File (*.svg)"),
138 'svgz': self.trUtf8("Compressed Scalable Vector Graphics File" 137 'svgz': self.tr("Compressed Scalable Vector Graphics File"
139 " (*.svgz)"), 138 " (*.svgz)"),
140 'tga': self.trUtf8("Targa Graphic File (*.tga)"), 139 'tga': self.tr("Targa Graphic File (*.tga)"),
141 'tif': self.trUtf8("TIFF File (*.tif)"), 140 'tif': self.tr("TIFF File (*.tif)"),
142 'tiff': self.trUtf8("TIFF File (*.tiff)"), 141 'tiff': self.tr("TIFF File (*.tiff)"),
143 'wbmp': self.trUtf8("WAP Bitmap File (*.wbmp)"), 142 'wbmp': self.tr("WAP Bitmap File (*.wbmp)"),
144 'xbm': self.trUtf8("X11 Bitmap File (*.xbm)"), 143 'xbm': self.tr("X11 Bitmap File (*.xbm)"),
145 'xpm': self.trUtf8("X11 Pixmap File (*.xpm)"), 144 'xpm': self.tr("X11 Pixmap File (*.xpm)"),
146 } 145 }
147 146
148 inputFormats = [] 147 inputFormats = []
149 readFormats = QImageReader.supportedImageFormats() 148 readFormats = QImageReader.supportedImageFormats()
150 for readFormat in readFormats: 149 for readFormat in readFormats:
151 try: 150 try:
152 inputFormats.append(filters[bytes(readFormat).decode()]) 151 inputFormats.append(filters[bytes(readFormat).decode()])
153 except KeyError: 152 except KeyError:
154 pass 153 pass
155 inputFormats.sort() 154 inputFormats.sort()
156 inputFormats.append(self.trUtf8("All Files (*)")) 155 inputFormats.append(self.tr("All Files (*)"))
157 self.__inputFilter = ';;'.join(inputFormats) 156 self.__inputFilter = ';;'.join(inputFormats)
158 157
159 outputFormats = [] 158 outputFormats = []
160 writeFormats = QImageWriter.supportedImageFormats() 159 writeFormats = QImageWriter.supportedImageFormats()
161 for writeFormat in writeFormats: 160 for writeFormat in writeFormats:
184 def __initFileActions(self): 183 def __initFileActions(self):
185 """ 184 """
186 Private method to define the file related user interface actions. 185 Private method to define the file related user interface actions.
187 """ 186 """
188 self.newAct = E5Action( 187 self.newAct = E5Action(
189 self.trUtf8('New'), 188 self.tr('New'),
190 UI.PixmapCache.getIcon("new.png"), 189 UI.PixmapCache.getIcon("new.png"),
191 self.trUtf8('&New'), 190 self.tr('&New'),
192 QKeySequence(self.trUtf8("Ctrl+N", "File|New")), 191 QKeySequence(self.tr("Ctrl+N", "File|New")),
193 0, self, 'iconEditor_file_new') 192 0, self, 'iconEditor_file_new')
194 self.newAct.setStatusTip(self.trUtf8('Create a new icon')) 193 self.newAct.setStatusTip(self.tr('Create a new icon'))
195 self.newAct.setWhatsThis(self.trUtf8( 194 self.newAct.setWhatsThis(self.tr(
196 """<b>New</b>""" 195 """<b>New</b>"""
197 """<p>This creates a new icon.</p>""" 196 """<p>This creates a new icon.</p>"""
198 )) 197 ))
199 self.newAct.triggered[()].connect(self.__newIcon) 198 self.newAct.triggered.connect(self.__newIcon)
200 self.__actions.append(self.newAct) 199 self.__actions.append(self.newAct)
201 200
202 self.newWindowAct = E5Action( 201 self.newWindowAct = E5Action(
203 self.trUtf8('New Window'), 202 self.tr('New Window'),
204 UI.PixmapCache.getIcon("newWindow.png"), 203 UI.PixmapCache.getIcon("newWindow.png"),
205 self.trUtf8('New &Window'), 204 self.tr('New &Window'),
206 0, 0, self, 'iconEditor_file_new_window') 205 0, 0, self, 'iconEditor_file_new_window')
207 self.newWindowAct.setStatusTip(self.trUtf8( 206 self.newWindowAct.setStatusTip(self.tr(
208 'Open a new icon editor window')) 207 'Open a new icon editor window'))
209 self.newWindowAct.setWhatsThis(self.trUtf8( 208 self.newWindowAct.setWhatsThis(self.tr(
210 """<b>New Window</b>""" 209 """<b>New Window</b>"""
211 """<p>This opens a new icon editor window.</p>""" 210 """<p>This opens a new icon editor window.</p>"""
212 )) 211 ))
213 self.newWindowAct.triggered[()].connect(self.__newWindow) 212 self.newWindowAct.triggered.connect(self.__newWindow)
214 self.__actions.append(self.newWindowAct) 213 self.__actions.append(self.newWindowAct)
215 214
216 self.openAct = E5Action( 215 self.openAct = E5Action(
217 self.trUtf8('Open'), 216 self.tr('Open'),
218 UI.PixmapCache.getIcon("open.png"), 217 UI.PixmapCache.getIcon("open.png"),
219 self.trUtf8('&Open...'), 218 self.tr('&Open...'),
220 QKeySequence(self.trUtf8("Ctrl+O", "File|Open")), 219 QKeySequence(self.tr("Ctrl+O", "File|Open")),
221 0, self, 'iconEditor_file_open') 220 0, self, 'iconEditor_file_open')
222 self.openAct.setStatusTip(self.trUtf8('Open an icon file for editing')) 221 self.openAct.setStatusTip(self.tr('Open an icon file for editing'))
223 self.openAct.setWhatsThis(self.trUtf8( 222 self.openAct.setWhatsThis(self.tr(
224 """<b>Open File</b>""" 223 """<b>Open File</b>"""
225 """<p>This opens a new icon file for editing.""" 224 """<p>This opens a new icon file for editing."""
226 """ It pops up a file selection dialog.</p>""" 225 """ It pops up a file selection dialog.</p>"""
227 )) 226 ))
228 self.openAct.triggered[()].connect(self.__openIcon) 227 self.openAct.triggered.connect(self.__openIcon)
229 self.__actions.append(self.openAct) 228 self.__actions.append(self.openAct)
230 229
231 self.saveAct = E5Action( 230 self.saveAct = E5Action(
232 self.trUtf8('Save'), 231 self.tr('Save'),
233 UI.PixmapCache.getIcon("fileSave.png"), 232 UI.PixmapCache.getIcon("fileSave.png"),
234 self.trUtf8('&Save'), 233 self.tr('&Save'),
235 QKeySequence(self.trUtf8("Ctrl+S", "File|Save")), 234 QKeySequence(self.tr("Ctrl+S", "File|Save")),
236 0, self, 'iconEditor_file_save') 235 0, self, 'iconEditor_file_save')
237 self.saveAct.setStatusTip(self.trUtf8('Save the current icon')) 236 self.saveAct.setStatusTip(self.tr('Save the current icon'))
238 self.saveAct.setWhatsThis(self.trUtf8( 237 self.saveAct.setWhatsThis(self.tr(
239 """<b>Save File</b>""" 238 """<b>Save File</b>"""
240 """<p>Save the contents of the icon editor window.</p>""" 239 """<p>Save the contents of the icon editor window.</p>"""
241 )) 240 ))
242 self.saveAct.triggered[()].connect(self.__saveIcon) 241 self.saveAct.triggered.connect(self.__saveIcon)
243 self.__actions.append(self.saveAct) 242 self.__actions.append(self.saveAct)
244 243
245 self.saveAsAct = E5Action( 244 self.saveAsAct = E5Action(
246 self.trUtf8('Save As'), 245 self.tr('Save As'),
247 UI.PixmapCache.getIcon("fileSaveAs.png"), 246 UI.PixmapCache.getIcon("fileSaveAs.png"),
248 self.trUtf8('Save &As...'), 247 self.tr('Save &As...'),
249 QKeySequence(self.trUtf8("Shift+Ctrl+S", "File|Save As")), 248 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
250 0, self, 'iconEditor_file_save_as') 249 0, self, 'iconEditor_file_save_as')
251 self.saveAsAct.setStatusTip( 250 self.saveAsAct.setStatusTip(
252 self.trUtf8('Save the current icon to a new file')) 251 self.tr('Save the current icon to a new file'))
253 self.saveAsAct.setWhatsThis(self.trUtf8( 252 self.saveAsAct.setWhatsThis(self.tr(
254 """<b>Save As...</b>""" 253 """<b>Save As...</b>"""
255 """<p>Saves the current icon to a new file.</p>""" 254 """<p>Saves the current icon to a new file.</p>"""
256 )) 255 ))
257 self.saveAsAct.triggered[()].connect(self.__saveIconAs) 256 self.saveAsAct.triggered.connect(self.__saveIconAs)
258 self.__actions.append(self.saveAsAct) 257 self.__actions.append(self.saveAsAct)
259 258
260 self.closeAct = E5Action( 259 self.closeAct = E5Action(
261 self.trUtf8('Close'), 260 self.tr('Close'),
262 UI.PixmapCache.getIcon("close.png"), 261 UI.PixmapCache.getIcon("close.png"),
263 self.trUtf8('&Close'), 262 self.tr('&Close'),
264 QKeySequence(self.trUtf8("Ctrl+W", "File|Close")), 263 QKeySequence(self.tr("Ctrl+W", "File|Close")),
265 0, self, 'iconEditor_file_close') 264 0, self, 'iconEditor_file_close')
266 self.closeAct.setStatusTip(self.trUtf8( 265 self.closeAct.setStatusTip(self.tr(
267 'Close the current icon editor window')) 266 'Close the current icon editor window'))
268 self.closeAct.setWhatsThis(self.trUtf8( 267 self.closeAct.setWhatsThis(self.tr(
269 """<b>Close</b>""" 268 """<b>Close</b>"""
270 """<p>Closes the current icon editor window.</p>""" 269 """<p>Closes the current icon editor window.</p>"""
271 )) 270 ))
272 self.closeAct.triggered[()].connect(self.close) 271 self.closeAct.triggered.connect(self.close)
273 self.__actions.append(self.closeAct) 272 self.__actions.append(self.closeAct)
274 273
275 self.closeAllAct = E5Action( 274 self.closeAllAct = E5Action(
276 self.trUtf8('Close All'), 275 self.tr('Close All'),
277 self.trUtf8('Close &All'), 276 self.tr('Close &All'),
278 0, 0, self, 'iconEditor_file_close_all') 277 0, 0, self, 'iconEditor_file_close_all')
279 self.closeAllAct.setStatusTip(self.trUtf8( 278 self.closeAllAct.setStatusTip(self.tr(
280 'Close all icon editor windows')) 279 'Close all icon editor windows'))
281 self.closeAllAct.setWhatsThis(self.trUtf8( 280 self.closeAllAct.setWhatsThis(self.tr(
282 """<b>Close All</b>""" 281 """<b>Close All</b>"""
283 """<p>Closes all icon editor windows except the first one.</p>""" 282 """<p>Closes all icon editor windows except the first one.</p>"""
284 )) 283 ))
285 self.closeAllAct.triggered[()].connect(self.__closeAll) 284 self.closeAllAct.triggered.connect(self.__closeAll)
286 self.__actions.append(self.closeAllAct) 285 self.__actions.append(self.closeAllAct)
287 286
288 self.exitAct = E5Action( 287 self.exitAct = E5Action(
289 self.trUtf8('Quit'), 288 self.tr('Quit'),
290 UI.PixmapCache.getIcon("exit.png"), 289 UI.PixmapCache.getIcon("exit.png"),
291 self.trUtf8('&Quit'), 290 self.tr('&Quit'),
292 QKeySequence(self.trUtf8("Ctrl+Q", "File|Quit")), 291 QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
293 0, self, 'iconEditor_file_quit') 292 0, self, 'iconEditor_file_quit')
294 self.exitAct.setStatusTip(self.trUtf8('Quit the icon editor')) 293 self.exitAct.setStatusTip(self.tr('Quit the icon editor'))
295 self.exitAct.setWhatsThis(self.trUtf8( 294 self.exitAct.setWhatsThis(self.tr(
296 """<b>Quit</b>""" 295 """<b>Quit</b>"""
297 """<p>Quit the icon editor.</p>""" 296 """<p>Quit the icon editor.</p>"""
298 )) 297 ))
299 if not self.fromEric: 298 if not self.fromEric:
300 self.exitAct.triggered[()].connect(self.__closeAll) 299 self.exitAct.triggered.connect(self.__closeAll)
301 self.__actions.append(self.exitAct) 300 self.__actions.append(self.exitAct)
302 301
303 def __initEditActions(self): 302 def __initEditActions(self):
304 """ 303 """
305 Private method to create the Edit actions. 304 Private method to create the Edit actions.
306 """ 305 """
307 self.undoAct = E5Action( 306 self.undoAct = E5Action(
308 self.trUtf8('Undo'), 307 self.tr('Undo'),
309 UI.PixmapCache.getIcon("editUndo.png"), 308 UI.PixmapCache.getIcon("editUndo.png"),
310 self.trUtf8('&Undo'), 309 self.tr('&Undo'),
311 QKeySequence(self.trUtf8("Ctrl+Z", "Edit|Undo")), 310 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
312 QKeySequence(self.trUtf8("Alt+Backspace", "Edit|Undo")), 311 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")),
313 self, 'iconEditor_edit_undo') 312 self, 'iconEditor_edit_undo')
314 self.undoAct.setStatusTip(self.trUtf8('Undo the last change')) 313 self.undoAct.setStatusTip(self.tr('Undo the last change'))
315 self.undoAct.setWhatsThis(self.trUtf8( 314 self.undoAct.setWhatsThis(self.tr(
316 """<b>Undo</b>""" 315 """<b>Undo</b>"""
317 """<p>Undo the last change done.</p>""" 316 """<p>Undo the last change done.</p>"""
318 )) 317 ))
319 self.undoAct.triggered[()].connect(self.__editor.editUndo) 318 self.undoAct.triggered.connect(self.__editor.editUndo)
320 self.__actions.append(self.undoAct) 319 self.__actions.append(self.undoAct)
321 320
322 self.redoAct = E5Action( 321 self.redoAct = E5Action(
323 self.trUtf8('Redo'), 322 self.tr('Redo'),
324 UI.PixmapCache.getIcon("editRedo.png"), 323 UI.PixmapCache.getIcon("editRedo.png"),
325 self.trUtf8('&Redo'), 324 self.tr('&Redo'),
326 QKeySequence(self.trUtf8("Ctrl+Shift+Z", "Edit|Redo")), 325 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
327 0, self, 'iconEditor_edit_redo') 326 0, self, 'iconEditor_edit_redo')
328 self.redoAct.setStatusTip(self.trUtf8('Redo the last change')) 327 self.redoAct.setStatusTip(self.tr('Redo the last change'))
329 self.redoAct.setWhatsThis(self.trUtf8( 328 self.redoAct.setWhatsThis(self.tr(
330 """<b>Redo</b>""" 329 """<b>Redo</b>"""
331 """<p>Redo the last change done.</p>""" 330 """<p>Redo the last change done.</p>"""
332 )) 331 ))
333 self.redoAct.triggered[()].connect(self.__editor.editRedo) 332 self.redoAct.triggered.connect(self.__editor.editRedo)
334 self.__actions.append(self.redoAct) 333 self.__actions.append(self.redoAct)
335 334
336 self.cutAct = E5Action( 335 self.cutAct = E5Action(
337 self.trUtf8('Cut'), 336 self.tr('Cut'),
338 UI.PixmapCache.getIcon("editCut.png"), 337 UI.PixmapCache.getIcon("editCut.png"),
339 self.trUtf8('Cu&t'), 338 self.tr('Cu&t'),
340 QKeySequence(self.trUtf8("Ctrl+X", "Edit|Cut")), 339 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
341 QKeySequence(self.trUtf8("Shift+Del", "Edit|Cut")), 340 QKeySequence(self.tr("Shift+Del", "Edit|Cut")),
342 self, 'iconEditor_edit_cut') 341 self, 'iconEditor_edit_cut')
343 self.cutAct.setStatusTip(self.trUtf8('Cut the selection')) 342 self.cutAct.setStatusTip(self.tr('Cut the selection'))
344 self.cutAct.setWhatsThis(self.trUtf8( 343 self.cutAct.setWhatsThis(self.tr(
345 """<b>Cut</b>""" 344 """<b>Cut</b>"""
346 """<p>Cut the selected image area to the clipboard.</p>""" 345 """<p>Cut the selected image area to the clipboard.</p>"""
347 )) 346 ))
348 self.cutAct.triggered[()].connect(self.__editor.editCut) 347 self.cutAct.triggered.connect(self.__editor.editCut)
349 self.__actions.append(self.cutAct) 348 self.__actions.append(self.cutAct)
350 349
351 self.copyAct = E5Action( 350 self.copyAct = E5Action(
352 self.trUtf8('Copy'), 351 self.tr('Copy'),
353 UI.PixmapCache.getIcon("editCopy.png"), 352 UI.PixmapCache.getIcon("editCopy.png"),
354 self.trUtf8('&Copy'), 353 self.tr('&Copy'),
355 QKeySequence(self.trUtf8("Ctrl+C", "Edit|Copy")), 354 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
356 QKeySequence(self.trUtf8("Ctrl+Ins", "Edit|Copy")), 355 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")),
357 self, 'iconEditor_edit_copy') 356 self, 'iconEditor_edit_copy')
358 self.copyAct.setStatusTip(self.trUtf8('Copy the selection')) 357 self.copyAct.setStatusTip(self.tr('Copy the selection'))
359 self.copyAct.setWhatsThis(self.trUtf8( 358 self.copyAct.setWhatsThis(self.tr(
360 """<b>Copy</b>""" 359 """<b>Copy</b>"""
361 """<p>Copy the selected image area to the clipboard.</p>""" 360 """<p>Copy the selected image area to the clipboard.</p>"""
362 )) 361 ))
363 self.copyAct.triggered[()].connect(self.__editor.editCopy) 362 self.copyAct.triggered.connect(self.__editor.editCopy)
364 self.__actions.append(self.copyAct) 363 self.__actions.append(self.copyAct)
365 364
366 self.pasteAct = E5Action( 365 self.pasteAct = E5Action(
367 self.trUtf8('Paste'), 366 self.tr('Paste'),
368 UI.PixmapCache.getIcon("editPaste.png"), 367 UI.PixmapCache.getIcon("editPaste.png"),
369 self.trUtf8('&Paste'), 368 self.tr('&Paste'),
370 QKeySequence(self.trUtf8("Ctrl+V", "Edit|Paste")), 369 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
371 QKeySequence(self.trUtf8("Shift+Ins", "Edit|Paste")), 370 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")),
372 self, 'iconEditor_edit_paste') 371 self, 'iconEditor_edit_paste')
373 self.pasteAct.setStatusTip(self.trUtf8('Paste the clipboard image')) 372 self.pasteAct.setStatusTip(self.tr('Paste the clipboard image'))
374 self.pasteAct.setWhatsThis(self.trUtf8( 373 self.pasteAct.setWhatsThis(self.tr(
375 """<b>Paste</b>""" 374 """<b>Paste</b>"""
376 """<p>Paste the clipboard image.</p>""" 375 """<p>Paste the clipboard image.</p>"""
377 )) 376 ))
378 self.pasteAct.triggered[()].connect(self.__editor.editPaste) 377 self.pasteAct.triggered.connect(self.__editor.editPaste)
379 self.__actions.append(self.pasteAct) 378 self.__actions.append(self.pasteAct)
380 379
381 self.pasteNewAct = E5Action( 380 self.pasteNewAct = E5Action(
382 self.trUtf8('Paste as New'), 381 self.tr('Paste as New'),
383 self.trUtf8('Paste as &New'), 382 self.tr('Paste as &New'),
384 0, 0, self, 'iconEditor_edit_paste_as_new') 383 0, 0, self, 'iconEditor_edit_paste_as_new')
385 self.pasteNewAct.setStatusTip(self.trUtf8( 384 self.pasteNewAct.setStatusTip(self.tr(
386 'Paste the clipboard image replacing the current one')) 385 'Paste the clipboard image replacing the current one'))
387 self.pasteNewAct.setWhatsThis(self.trUtf8( 386 self.pasteNewAct.setWhatsThis(self.tr(
388 """<b>Paste as New</b>""" 387 """<b>Paste as New</b>"""
389 """<p>Paste the clipboard image replacing the current one.</p>""" 388 """<p>Paste the clipboard image replacing the current one.</p>"""
390 )) 389 ))
391 self.pasteNewAct.triggered[()].connect(self.__editor.editPasteAsNew) 390 self.pasteNewAct.triggered.connect(self.__editor.editPasteAsNew)
392 self.__actions.append(self.pasteNewAct) 391 self.__actions.append(self.pasteNewAct)
393 392
394 self.deleteAct = E5Action( 393 self.deleteAct = E5Action(
395 self.trUtf8('Clear'), 394 self.tr('Clear'),
396 UI.PixmapCache.getIcon("editDelete.png"), 395 UI.PixmapCache.getIcon("editDelete.png"),
397 self.trUtf8('Cl&ear'), 396 self.tr('Cl&ear'),
398 QKeySequence(self.trUtf8("Alt+Shift+C", "Edit|Clear")), 397 QKeySequence(self.tr("Alt+Shift+C", "Edit|Clear")),
399 0, 398 0,
400 self, 'iconEditor_edit_clear') 399 self, 'iconEditor_edit_clear')
401 self.deleteAct.setStatusTip(self.trUtf8('Clear the icon image')) 400 self.deleteAct.setStatusTip(self.tr('Clear the icon image'))
402 self.deleteAct.setWhatsThis(self.trUtf8( 401 self.deleteAct.setWhatsThis(self.tr(
403 """<b>Clear</b>""" 402 """<b>Clear</b>"""
404 """<p>Clear the icon image and set it to be completely""" 403 """<p>Clear the icon image and set it to be completely"""
405 """ transparent.</p>""" 404 """ transparent.</p>"""
406 )) 405 ))
407 self.deleteAct.triggered[()].connect(self.__editor.editClear) 406 self.deleteAct.triggered.connect(self.__editor.editClear)
408 self.__actions.append(self.deleteAct) 407 self.__actions.append(self.deleteAct)
409 408
410 self.selectAllAct = E5Action( 409 self.selectAllAct = E5Action(
411 self.trUtf8('Select All'), 410 self.tr('Select All'),
412 self.trUtf8('&Select All'), 411 self.tr('&Select All'),
413 QKeySequence(self.trUtf8("Ctrl+A", "Edit|Select All")), 412 QKeySequence(self.tr("Ctrl+A", "Edit|Select All")),
414 0, 413 0,
415 self, 'iconEditor_edit_select_all') 414 self, 'iconEditor_edit_select_all')
416 self.selectAllAct.setStatusTip(self.trUtf8( 415 self.selectAllAct.setStatusTip(self.tr(
417 'Select the complete icon image')) 416 'Select the complete icon image'))
418 self.selectAllAct.setWhatsThis(self.trUtf8( 417 self.selectAllAct.setWhatsThis(self.tr(
419 """<b>Select All</b>""" 418 """<b>Select All</b>"""
420 """<p>Selects the complete icon image.</p>""" 419 """<p>Selects the complete icon image.</p>"""
421 )) 420 ))
422 self.selectAllAct.triggered[()].connect(self.__editor.editSelectAll) 421 self.selectAllAct.triggered.connect(self.__editor.editSelectAll)
423 self.__actions.append(self.selectAllAct) 422 self.__actions.append(self.selectAllAct)
424 423
425 self.resizeAct = E5Action( 424 self.resizeAct = E5Action(
426 self.trUtf8('Change Size'), 425 self.tr('Change Size'),
427 UI.PixmapCache.getIcon("transformResize.png"), 426 UI.PixmapCache.getIcon("transformResize.png"),
428 self.trUtf8('Change Si&ze...'), 427 self.tr('Change Si&ze...'),
429 0, 0, 428 0, 0,
430 self, 'iconEditor_edit_change_size') 429 self, 'iconEditor_edit_change_size')
431 self.resizeAct.setStatusTip(self.trUtf8('Change the icon size')) 430 self.resizeAct.setStatusTip(self.tr('Change the icon size'))
432 self.resizeAct.setWhatsThis(self.trUtf8( 431 self.resizeAct.setWhatsThis(self.tr(
433 """<b>Change Size...</b>""" 432 """<b>Change Size...</b>"""
434 """<p>Changes the icon size.</p>""" 433 """<p>Changes the icon size.</p>"""
435 )) 434 ))
436 self.resizeAct.triggered[()].connect(self.__editor.editResize) 435 self.resizeAct.triggered.connect(self.__editor.editResize)
437 self.__actions.append(self.resizeAct) 436 self.__actions.append(self.resizeAct)
438 437
439 self.grayscaleAct = E5Action( 438 self.grayscaleAct = E5Action(
440 self.trUtf8('Grayscale'), 439 self.tr('Grayscale'),
441 UI.PixmapCache.getIcon("grayscale.png"), 440 UI.PixmapCache.getIcon("grayscale.png"),
442 self.trUtf8('&Grayscale'), 441 self.tr('&Grayscale'),
443 0, 0, 442 0, 0,
444 self, 'iconEditor_edit_grayscale') 443 self, 'iconEditor_edit_grayscale')
445 self.grayscaleAct.setStatusTip(self.trUtf8( 444 self.grayscaleAct.setStatusTip(self.tr(
446 'Change the icon to grayscale')) 445 'Change the icon to grayscale'))
447 self.grayscaleAct.setWhatsThis(self.trUtf8( 446 self.grayscaleAct.setWhatsThis(self.tr(
448 """<b>Grayscale</b>""" 447 """<b>Grayscale</b>"""
449 """<p>Changes the icon to grayscale.</p>""" 448 """<p>Changes the icon to grayscale.</p>"""
450 )) 449 ))
451 self.grayscaleAct.triggered[()].connect(self.__editor.grayScale) 450 self.grayscaleAct.triggered.connect(self.__editor.grayScale)
452 self.__actions.append(self.grayscaleAct) 451 self.__actions.append(self.grayscaleAct)
453 452
454 self.redoAct.setEnabled(False) 453 self.redoAct.setEnabled(False)
455 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled) 454 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled)
456 455
472 def __initViewActions(self): 471 def __initViewActions(self):
473 """ 472 """
474 Private method to create the View actions. 473 Private method to create the View actions.
475 """ 474 """
476 self.zoomInAct = E5Action( 475 self.zoomInAct = E5Action(
477 self.trUtf8('Zoom in'), 476 self.tr('Zoom in'),
478 UI.PixmapCache.getIcon("zoomIn.png"), 477 UI.PixmapCache.getIcon("zoomIn.png"),
479 self.trUtf8('Zoom &in'), 478 self.tr('Zoom &in'),
480 QKeySequence(self.trUtf8("Ctrl++", "View|Zoom in")), 479 QKeySequence(self.tr("Ctrl++", "View|Zoom in")),
481 0, self, 'iconEditor_view_zoom_in') 480 0, self, 'iconEditor_view_zoom_in')
482 self.zoomInAct.setStatusTip(self.trUtf8('Zoom in on the icon')) 481 self.zoomInAct.setStatusTip(self.tr('Zoom in on the icon'))
483 self.zoomInAct.setWhatsThis(self.trUtf8( 482 self.zoomInAct.setWhatsThis(self.tr(
484 """<b>Zoom in</b>""" 483 """<b>Zoom in</b>"""
485 """<p>Zoom in on the icon. This makes the grid bigger.</p>""" 484 """<p>Zoom in on the icon. This makes the grid bigger.</p>"""
486 )) 485 ))
487 self.zoomInAct.triggered[()].connect(self.__zoomIn) 486 self.zoomInAct.triggered.connect(self.__zoomIn)
488 self.__actions.append(self.zoomInAct) 487 self.__actions.append(self.zoomInAct)
489 488
490 self.zoomOutAct = E5Action( 489 self.zoomOutAct = E5Action(
491 self.trUtf8('Zoom out'), 490 self.tr('Zoom out'),
492 UI.PixmapCache.getIcon("zoomOut.png"), 491 UI.PixmapCache.getIcon("zoomOut.png"),
493 self.trUtf8('Zoom &out'), 492 self.tr('Zoom &out'),
494 QKeySequence(self.trUtf8("Ctrl+-", "View|Zoom out")), 493 QKeySequence(self.tr("Ctrl+-", "View|Zoom out")),
495 0, self, 'iconEditor_view_zoom_out') 494 0, self, 'iconEditor_view_zoom_out')
496 self.zoomOutAct.setStatusTip(self.trUtf8('Zoom out on the icon')) 495 self.zoomOutAct.setStatusTip(self.tr('Zoom out on the icon'))
497 self.zoomOutAct.setWhatsThis(self.trUtf8( 496 self.zoomOutAct.setWhatsThis(self.tr(
498 """<b>Zoom out</b>""" 497 """<b>Zoom out</b>"""
499 """<p>Zoom out on the icon. This makes the grid smaller.</p>""" 498 """<p>Zoom out on the icon. This makes the grid smaller.</p>"""
500 )) 499 ))
501 self.zoomOutAct.triggered[()].connect(self.__zoomOut) 500 self.zoomOutAct.triggered.connect(self.__zoomOut)
502 self.__actions.append(self.zoomOutAct) 501 self.__actions.append(self.zoomOutAct)
503 502
504 self.zoomResetAct = E5Action( 503 self.zoomResetAct = E5Action(
505 self.trUtf8('Zoom reset'), 504 self.tr('Zoom reset'),
506 UI.PixmapCache.getIcon("zoomReset.png"), 505 UI.PixmapCache.getIcon("zoomReset.png"),
507 self.trUtf8('Zoom &reset'), 506 self.tr('Zoom &reset'),
508 QKeySequence(self.trUtf8("Ctrl+0", "View|Zoom reset")), 507 QKeySequence(self.tr("Ctrl+0", "View|Zoom reset")),
509 0, self, 'iconEditor_view_zoom_reset') 508 0, self, 'iconEditor_view_zoom_reset')
510 self.zoomResetAct.setStatusTip(self.trUtf8( 509 self.zoomResetAct.setStatusTip(self.tr(
511 'Reset the zoom of the icon')) 510 'Reset the zoom of the icon'))
512 self.zoomResetAct.setWhatsThis(self.trUtf8( 511 self.zoomResetAct.setWhatsThis(self.tr(
513 """<b>Zoom reset</b>""" 512 """<b>Zoom reset</b>"""
514 """<p>Reset the zoom of the icon. """ 513 """<p>Reset the zoom of the icon. """
515 """This sets the zoom factor to 100%.</p>""" 514 """This sets the zoom factor to 100%.</p>"""
516 )) 515 ))
517 self.zoomResetAct.triggered[()].connect(self.__zoomReset) 516 self.zoomResetAct.triggered.connect(self.__zoomReset)
518 self.__actions.append(self.zoomResetAct) 517 self.__actions.append(self.zoomResetAct)
519 518
520 self.showGridAct = E5Action( 519 self.showGridAct = E5Action(
521 self.trUtf8('Show Grid'), 520 self.tr('Show Grid'),
522 UI.PixmapCache.getIcon("grid.png"), 521 UI.PixmapCache.getIcon("grid.png"),
523 self.trUtf8('Show &Grid'), 522 self.tr('Show &Grid'),
524 0, 0, 523 0, 0,
525 self, 'iconEditor_view_show_grid') 524 self, 'iconEditor_view_show_grid')
526 self.showGridAct.setStatusTip(self.trUtf8( 525 self.showGridAct.setStatusTip(self.tr(
527 'Toggle the display of the grid')) 526 'Toggle the display of the grid'))
528 self.showGridAct.setWhatsThis(self.trUtf8( 527 self.showGridAct.setWhatsThis(self.tr(
529 """<b>Show Grid</b>""" 528 """<b>Show Grid</b>"""
530 """<p>Toggle the display of the grid.</p>""" 529 """<p>Toggle the display of the grid.</p>"""
531 )) 530 ))
532 self.showGridAct.triggered[bool].connect(self.__editor.setGridEnabled) 531 self.showGridAct.triggered[bool].connect(self.__editor.setGridEnabled)
533 self.__actions.append(self.showGridAct) 532 self.__actions.append(self.showGridAct)
543 542
544 self.drawingActGrp = createActionGroup(self) 543 self.drawingActGrp = createActionGroup(self)
545 self.drawingActGrp.setExclusive(True) 544 self.drawingActGrp.setExclusive(True)
546 545
547 self.drawPencilAct = E5Action( 546 self.drawPencilAct = E5Action(
548 self.trUtf8('Freehand'), 547 self.tr('Freehand'),
549 UI.PixmapCache.getIcon("drawBrush.png"), 548 UI.PixmapCache.getIcon("drawBrush.png"),
550 self.trUtf8('&Freehand'), 549 self.tr('&Freehand'),
551 0, 0, 550 0, 0,
552 self.drawingActGrp, 'iconEditor_tools_pencil') 551 self.drawingActGrp, 'iconEditor_tools_pencil')
553 self.drawPencilAct.setWhatsThis(self.trUtf8( 552 self.drawPencilAct.setWhatsThis(self.tr(
554 """<b>Free hand</b>""" 553 """<b>Free hand</b>"""
555 """<p>Draws non linear lines.</p>""" 554 """<p>Draws non linear lines.</p>"""
556 )) 555 ))
557 self.drawPencilAct.setCheckable(True) 556 self.drawPencilAct.setCheckable(True)
558 self.esm.setMapping(self.drawPencilAct, IconEditorGrid.Pencil) 557 self.esm.setMapping(self.drawPencilAct, IconEditorGrid.Pencil)
559 self.drawPencilAct.triggered[()].connect(self.esm.map) 558 self.drawPencilAct.triggered.connect(self.esm.map)
560 self.__actions.append(self.drawPencilAct) 559 self.__actions.append(self.drawPencilAct)
561 560
562 self.drawColorPickerAct = E5Action( 561 self.drawColorPickerAct = E5Action(
563 self.trUtf8('Color Picker'), 562 self.tr('Color Picker'),
564 UI.PixmapCache.getIcon("colorPicker.png"), 563 UI.PixmapCache.getIcon("colorPicker.png"),
565 self.trUtf8('&Color Picker'), 564 self.tr('&Color Picker'),
566 0, 0, 565 0, 0,
567 self.drawingActGrp, 'iconEditor_tools_color_picker') 566 self.drawingActGrp, 'iconEditor_tools_color_picker')
568 self.drawColorPickerAct.setWhatsThis(self.trUtf8( 567 self.drawColorPickerAct.setWhatsThis(self.tr(
569 """<b>Color Picker</b>""" 568 """<b>Color Picker</b>"""
570 """<p>The color of the pixel clicked on will become """ 569 """<p>The color of the pixel clicked on will become """
571 """the current draw color.</p>""" 570 """the current draw color.</p>"""
572 )) 571 ))
573 self.drawColorPickerAct.setCheckable(True) 572 self.drawColorPickerAct.setCheckable(True)
574 self.esm.setMapping(self.drawColorPickerAct, 573 self.esm.setMapping(self.drawColorPickerAct,
575 IconEditorGrid.ColorPicker) 574 IconEditorGrid.ColorPicker)
576 self.drawColorPickerAct.triggered[()].connect(self.esm.map) 575 self.drawColorPickerAct.triggered.connect(self.esm.map)
577 self.__actions.append(self.drawColorPickerAct) 576 self.__actions.append(self.drawColorPickerAct)
578 577
579 self.drawRectangleAct = E5Action( 578 self.drawRectangleAct = E5Action(
580 self.trUtf8('Rectangle'), 579 self.tr('Rectangle'),
581 UI.PixmapCache.getIcon("drawRectangle.png"), 580 UI.PixmapCache.getIcon("drawRectangle.png"),
582 self.trUtf8('&Rectangle'), 581 self.tr('&Rectangle'),
583 0, 0, 582 0, 0,
584 self.drawingActGrp, 'iconEditor_tools_rectangle') 583 self.drawingActGrp, 'iconEditor_tools_rectangle')
585 self.drawRectangleAct.setWhatsThis(self.trUtf8( 584 self.drawRectangleAct.setWhatsThis(self.tr(
586 """<b>Rectangle</b>""" 585 """<b>Rectangle</b>"""
587 """<p>Draw a rectangle.</p>""" 586 """<p>Draw a rectangle.</p>"""
588 )) 587 ))
589 self.drawRectangleAct.setCheckable(True) 588 self.drawRectangleAct.setCheckable(True)
590 self.esm.setMapping(self.drawRectangleAct, IconEditorGrid.Rectangle) 589 self.esm.setMapping(self.drawRectangleAct, IconEditorGrid.Rectangle)
591 self.drawRectangleAct.triggered[()].connect(self.esm.map) 590 self.drawRectangleAct.triggered.connect(self.esm.map)
592 self.__actions.append(self.drawRectangleAct) 591 self.__actions.append(self.drawRectangleAct)
593 592
594 self.drawFilledRectangleAct = E5Action( 593 self.drawFilledRectangleAct = E5Action(
595 self.trUtf8('Filled Rectangle'), 594 self.tr('Filled Rectangle'),
596 UI.PixmapCache.getIcon("drawRectangleFilled.png"), 595 UI.PixmapCache.getIcon("drawRectangleFilled.png"),
597 self.trUtf8('F&illed Rectangle'), 596 self.tr('F&illed Rectangle'),
598 0, 0, 597 0, 0,
599 self.drawingActGrp, 'iconEditor_tools_filled_rectangle') 598 self.drawingActGrp, 'iconEditor_tools_filled_rectangle')
600 self.drawFilledRectangleAct.setWhatsThis(self.trUtf8( 599 self.drawFilledRectangleAct.setWhatsThis(self.tr(
601 """<b>Filled Rectangle</b>""" 600 """<b>Filled Rectangle</b>"""
602 """<p>Draw a filled rectangle.</p>""" 601 """<p>Draw a filled rectangle.</p>"""
603 )) 602 ))
604 self.drawFilledRectangleAct.setCheckable(True) 603 self.drawFilledRectangleAct.setCheckable(True)
605 self.esm.setMapping(self.drawFilledRectangleAct, 604 self.esm.setMapping(self.drawFilledRectangleAct,
606 IconEditorGrid.FilledRectangle) 605 IconEditorGrid.FilledRectangle)
607 self.drawFilledRectangleAct.triggered[()].connect(self.esm.map) 606 self.drawFilledRectangleAct.triggered.connect(self.esm.map)
608 self.__actions.append(self.drawFilledRectangleAct) 607 self.__actions.append(self.drawFilledRectangleAct)
609 608
610 self.drawCircleAct = E5Action( 609 self.drawCircleAct = E5Action(
611 self.trUtf8('Circle'), 610 self.tr('Circle'),
612 UI.PixmapCache.getIcon("drawCircle.png"), 611 UI.PixmapCache.getIcon("drawCircle.png"),
613 self.trUtf8('Circle'), 612 self.tr('Circle'),
614 0, 0, 613 0, 0,
615 self.drawingActGrp, 'iconEditor_tools_circle') 614 self.drawingActGrp, 'iconEditor_tools_circle')
616 self.drawCircleAct.setWhatsThis(self.trUtf8( 615 self.drawCircleAct.setWhatsThis(self.tr(
617 """<b>Circle</b>""" 616 """<b>Circle</b>"""
618 """<p>Draw a circle.</p>""" 617 """<p>Draw a circle.</p>"""
619 )) 618 ))
620 self.drawCircleAct.setCheckable(True) 619 self.drawCircleAct.setCheckable(True)
621 self.esm.setMapping(self.drawCircleAct, IconEditorGrid.Circle) 620 self.esm.setMapping(self.drawCircleAct, IconEditorGrid.Circle)
622 self.drawCircleAct.triggered[()].connect(self.esm.map) 621 self.drawCircleAct.triggered.connect(self.esm.map)
623 self.__actions.append(self.drawCircleAct) 622 self.__actions.append(self.drawCircleAct)
624 623
625 self.drawFilledCircleAct = E5Action( 624 self.drawFilledCircleAct = E5Action(
626 self.trUtf8('Filled Circle'), 625 self.tr('Filled Circle'),
627 UI.PixmapCache.getIcon("drawCircleFilled.png"), 626 UI.PixmapCache.getIcon("drawCircleFilled.png"),
628 self.trUtf8('Fille&d Circle'), 627 self.tr('Fille&d Circle'),
629 0, 0, 628 0, 0,
630 self.drawingActGrp, 'iconEditor_tools_filled_circle') 629 self.drawingActGrp, 'iconEditor_tools_filled_circle')
631 self.drawFilledCircleAct.setWhatsThis(self.trUtf8( 630 self.drawFilledCircleAct.setWhatsThis(self.tr(
632 """<b>Filled Circle</b>""" 631 """<b>Filled Circle</b>"""
633 """<p>Draw a filled circle.</p>""" 632 """<p>Draw a filled circle.</p>"""
634 )) 633 ))
635 self.drawFilledCircleAct.setCheckable(True) 634 self.drawFilledCircleAct.setCheckable(True)
636 self.esm.setMapping(self.drawFilledCircleAct, 635 self.esm.setMapping(self.drawFilledCircleAct,
637 IconEditorGrid.FilledCircle) 636 IconEditorGrid.FilledCircle)
638 self.drawFilledCircleAct.triggered[()].connect(self.esm.map) 637 self.drawFilledCircleAct.triggered.connect(self.esm.map)
639 self.__actions.append(self.drawFilledCircleAct) 638 self.__actions.append(self.drawFilledCircleAct)
640 639
641 self.drawEllipseAct = E5Action( 640 self.drawEllipseAct = E5Action(
642 self.trUtf8('Ellipse'), 641 self.tr('Ellipse'),
643 UI.PixmapCache.getIcon("drawEllipse.png"), 642 UI.PixmapCache.getIcon("drawEllipse.png"),
644 self.trUtf8('&Ellipse'), 643 self.tr('&Ellipse'),
645 0, 0, 644 0, 0,
646 self.drawingActGrp, 'iconEditor_tools_ellipse') 645 self.drawingActGrp, 'iconEditor_tools_ellipse')
647 self.drawEllipseAct.setWhatsThis(self.trUtf8( 646 self.drawEllipseAct.setWhatsThis(self.tr(
648 """<b>Ellipse</b>""" 647 """<b>Ellipse</b>"""
649 """<p>Draw an ellipse.</p>""" 648 """<p>Draw an ellipse.</p>"""
650 )) 649 ))
651 self.drawEllipseAct.setCheckable(True) 650 self.drawEllipseAct.setCheckable(True)
652 self.esm.setMapping(self.drawEllipseAct, IconEditorGrid.Ellipse) 651 self.esm.setMapping(self.drawEllipseAct, IconEditorGrid.Ellipse)
653 self.drawEllipseAct.triggered[()].connect(self.esm.map) 652 self.drawEllipseAct.triggered.connect(self.esm.map)
654 self.__actions.append(self.drawEllipseAct) 653 self.__actions.append(self.drawEllipseAct)
655 654
656 self.drawFilledEllipseAct = E5Action( 655 self.drawFilledEllipseAct = E5Action(
657 self.trUtf8('Filled Ellipse'), 656 self.tr('Filled Ellipse'),
658 UI.PixmapCache.getIcon("drawEllipseFilled.png"), 657 UI.PixmapCache.getIcon("drawEllipseFilled.png"),
659 self.trUtf8('Fille&d Elli&pse'), 658 self.tr('Fille&d Elli&pse'),
660 0, 0, 659 0, 0,
661 self.drawingActGrp, 'iconEditor_tools_filled_ellipse') 660 self.drawingActGrp, 'iconEditor_tools_filled_ellipse')
662 self.drawFilledEllipseAct.setWhatsThis(self.trUtf8( 661 self.drawFilledEllipseAct.setWhatsThis(self.tr(
663 """<b>Filled Ellipse</b>""" 662 """<b>Filled Ellipse</b>"""
664 """<p>Draw a filled ellipse.</p>""" 663 """<p>Draw a filled ellipse.</p>"""
665 )) 664 ))
666 self.drawFilledEllipseAct.setCheckable(True) 665 self.drawFilledEllipseAct.setCheckable(True)
667 self.esm.setMapping(self.drawFilledEllipseAct, 666 self.esm.setMapping(self.drawFilledEllipseAct,
668 IconEditorGrid.FilledEllipse) 667 IconEditorGrid.FilledEllipse)
669 self.drawFilledEllipseAct.triggered[()].connect(self.esm.map) 668 self.drawFilledEllipseAct.triggered.connect(self.esm.map)
670 self.__actions.append(self.drawFilledEllipseAct) 669 self.__actions.append(self.drawFilledEllipseAct)
671 670
672 self.drawFloodFillAct = E5Action( 671 self.drawFloodFillAct = E5Action(
673 self.trUtf8('Flood Fill'), 672 self.tr('Flood Fill'),
674 UI.PixmapCache.getIcon("drawFill.png"), 673 UI.PixmapCache.getIcon("drawFill.png"),
675 self.trUtf8('Fl&ood Fill'), 674 self.tr('Fl&ood Fill'),
676 0, 0, 675 0, 0,
677 self.drawingActGrp, 'iconEditor_tools_flood_fill') 676 self.drawingActGrp, 'iconEditor_tools_flood_fill')
678 self.drawFloodFillAct.setWhatsThis(self.trUtf8( 677 self.drawFloodFillAct.setWhatsThis(self.tr(
679 """<b>Flood Fill</b>""" 678 """<b>Flood Fill</b>"""
680 """<p>Fill adjoining pixels with the same color with """ 679 """<p>Fill adjoining pixels with the same color with """
681 """the current color.</p>""" 680 """the current color.</p>"""
682 )) 681 ))
683 self.drawFloodFillAct.setCheckable(True) 682 self.drawFloodFillAct.setCheckable(True)
684 self.esm.setMapping(self.drawFloodFillAct, IconEditorGrid.Fill) 683 self.esm.setMapping(self.drawFloodFillAct, IconEditorGrid.Fill)
685 self.drawFloodFillAct.triggered[()].connect(self.esm.map) 684 self.drawFloodFillAct.triggered.connect(self.esm.map)
686 self.__actions.append(self.drawFloodFillAct) 685 self.__actions.append(self.drawFloodFillAct)
687 686
688 self.drawLineAct = E5Action( 687 self.drawLineAct = E5Action(
689 self.trUtf8('Line'), 688 self.tr('Line'),
690 UI.PixmapCache.getIcon("drawLine.png"), 689 UI.PixmapCache.getIcon("drawLine.png"),
691 self.trUtf8('&Line'), 690 self.tr('&Line'),
692 0, 0, 691 0, 0,
693 self.drawingActGrp, 'iconEditor_tools_line') 692 self.drawingActGrp, 'iconEditor_tools_line')
694 self.drawLineAct.setWhatsThis(self.trUtf8( 693 self.drawLineAct.setWhatsThis(self.tr(
695 """<b>Line</b>""" 694 """<b>Line</b>"""
696 """<p>Draw a line.</p>""" 695 """<p>Draw a line.</p>"""
697 )) 696 ))
698 self.drawLineAct.setCheckable(True) 697 self.drawLineAct.setCheckable(True)
699 self.esm.setMapping(self.drawLineAct, IconEditorGrid.Line) 698 self.esm.setMapping(self.drawLineAct, IconEditorGrid.Line)
700 self.drawLineAct.triggered[()].connect(self.esm.map) 699 self.drawLineAct.triggered.connect(self.esm.map)
701 self.__actions.append(self.drawLineAct) 700 self.__actions.append(self.drawLineAct)
702 701
703 self.drawEraserAct = E5Action( 702 self.drawEraserAct = E5Action(
704 self.trUtf8('Eraser (Transparent)'), 703 self.tr('Eraser (Transparent)'),
705 UI.PixmapCache.getIcon("drawEraser.png"), 704 UI.PixmapCache.getIcon("drawEraser.png"),
706 self.trUtf8('Eraser (&Transparent)'), 705 self.tr('Eraser (&Transparent)'),
707 0, 0, 706 0, 0,
708 self.drawingActGrp, 'iconEditor_tools_eraser') 707 self.drawingActGrp, 'iconEditor_tools_eraser')
709 self.drawEraserAct.setWhatsThis(self.trUtf8( 708 self.drawEraserAct.setWhatsThis(self.tr(
710 """<b>Eraser (Transparent)</b>""" 709 """<b>Eraser (Transparent)</b>"""
711 """<p>Erase pixels by setting them to transparent.</p>""" 710 """<p>Erase pixels by setting them to transparent.</p>"""
712 )) 711 ))
713 self.drawEraserAct.setCheckable(True) 712 self.drawEraserAct.setCheckable(True)
714 self.esm.setMapping(self.drawEraserAct, IconEditorGrid.Rubber) 713 self.esm.setMapping(self.drawEraserAct, IconEditorGrid.Rubber)
715 self.drawEraserAct.triggered[()].connect(self.esm.map) 714 self.drawEraserAct.triggered.connect(self.esm.map)
716 self.__actions.append(self.drawEraserAct) 715 self.__actions.append(self.drawEraserAct)
717 716
718 self.drawRectangleSelectionAct = E5Action( 717 self.drawRectangleSelectionAct = E5Action(
719 self.trUtf8('Rectangular Selection'), 718 self.tr('Rectangular Selection'),
720 UI.PixmapCache.getIcon("selectRectangle.png"), 719 UI.PixmapCache.getIcon("selectRectangle.png"),
721 self.trUtf8('Rect&angular Selection'), 720 self.tr('Rect&angular Selection'),
722 0, 0, 721 0, 0,
723 self.drawingActGrp, 'iconEditor_tools_selection_rectangle') 722 self.drawingActGrp, 'iconEditor_tools_selection_rectangle')
724 self.drawRectangleSelectionAct.setWhatsThis(self.trUtf8( 723 self.drawRectangleSelectionAct.setWhatsThis(self.tr(
725 """<b>Rectangular Selection</b>""" 724 """<b>Rectangular Selection</b>"""
726 """<p>Select a rectangular section of the icon using""" 725 """<p>Select a rectangular section of the icon using"""
727 """ the mouse.</p>""" 726 """ the mouse.</p>"""
728 )) 727 ))
729 self.drawRectangleSelectionAct.setCheckable(True) 728 self.drawRectangleSelectionAct.setCheckable(True)
730 self.esm.setMapping(self.drawRectangleSelectionAct, 729 self.esm.setMapping(self.drawRectangleSelectionAct,
731 IconEditorGrid.RectangleSelection) 730 IconEditorGrid.RectangleSelection)
732 self.drawRectangleSelectionAct.triggered[()].connect(self.esm.map) 731 self.drawRectangleSelectionAct.triggered.connect(self.esm.map)
733 self.__actions.append(self.drawRectangleSelectionAct) 732 self.__actions.append(self.drawRectangleSelectionAct)
734 733
735 self.drawCircleSelectionAct = E5Action( 734 self.drawCircleSelectionAct = E5Action(
736 self.trUtf8('Circular Selection'), 735 self.tr('Circular Selection'),
737 UI.PixmapCache.getIcon("selectCircle.png"), 736 UI.PixmapCache.getIcon("selectCircle.png"),
738 self.trUtf8('Rect&angular Selection'), 737 self.tr('Rect&angular Selection'),
739 0, 0, 738 0, 0,
740 self.drawingActGrp, 'iconEditor_tools_selection_circle') 739 self.drawingActGrp, 'iconEditor_tools_selection_circle')
741 self.drawCircleSelectionAct.setWhatsThis(self.trUtf8( 740 self.drawCircleSelectionAct.setWhatsThis(self.tr(
742 """<b>Circular Selection</b>""" 741 """<b>Circular Selection</b>"""
743 """<p>Select a circular section of the icon using""" 742 """<p>Select a circular section of the icon using"""
744 """ the mouse.</p>""" 743 """ the mouse.</p>"""
745 )) 744 ))
746 self.drawCircleSelectionAct.setCheckable(True) 745 self.drawCircleSelectionAct.setCheckable(True)
747 self.esm.setMapping(self.drawCircleSelectionAct, 746 self.esm.setMapping(self.drawCircleSelectionAct,
748 IconEditorGrid.CircleSelection) 747 IconEditorGrid.CircleSelection)
749 self.drawCircleSelectionAct.triggered[()].connect(self.esm.map) 748 self.drawCircleSelectionAct.triggered.connect(self.esm.map)
750 self.__actions.append(self.drawCircleSelectionAct) 749 self.__actions.append(self.drawCircleSelectionAct)
751 750
752 self.drawPencilAct.setChecked(True) 751 self.drawPencilAct.setChecked(True)
753 752
754 def __initHelpActions(self): 753 def __initHelpActions(self):
755 """ 754 """
756 Private method to create the Help actions. 755 Private method to create the Help actions.
757 """ 756 """
758 self.aboutAct = E5Action( 757 self.aboutAct = E5Action(
759 self.trUtf8('About'), 758 self.tr('About'),
760 self.trUtf8('&About'), 759 self.tr('&About'),
761 0, 0, self, 'iconEditor_help_about') 760 0, 0, self, 'iconEditor_help_about')
762 self.aboutAct.setStatusTip(self.trUtf8( 761 self.aboutAct.setStatusTip(self.tr(
763 'Display information about this software')) 762 'Display information about this software'))
764 self.aboutAct.setWhatsThis(self.trUtf8( 763 self.aboutAct.setWhatsThis(self.tr(
765 """<b>About</b>""" 764 """<b>About</b>"""
766 """<p>Display some information about this software.</p>""")) 765 """<p>Display some information about this software.</p>"""))
767 self.aboutAct.triggered[()].connect(self.__about) 766 self.aboutAct.triggered.connect(self.__about)
768 self.__actions.append(self.aboutAct) 767 self.__actions.append(self.aboutAct)
769 768
770 self.aboutQtAct = E5Action( 769 self.aboutQtAct = E5Action(
771 self.trUtf8('About Qt'), 770 self.tr('About Qt'),
772 self.trUtf8('About &Qt'), 771 self.tr('About &Qt'),
773 0, 0, self, 'iconEditor_help_about_qt') 772 0, 0, self, 'iconEditor_help_about_qt')
774 self.aboutQtAct.setStatusTip( 773 self.aboutQtAct.setStatusTip(
775 self.trUtf8('Display information about the Qt toolkit')) 774 self.tr('Display information about the Qt toolkit'))
776 self.aboutQtAct.setWhatsThis(self.trUtf8( 775 self.aboutQtAct.setWhatsThis(self.tr(
777 """<b>About Qt</b>""" 776 """<b>About Qt</b>"""
778 """<p>Display some information about the Qt toolkit.</p>""" 777 """<p>Display some information about the Qt toolkit.</p>"""
779 )) 778 ))
780 self.aboutQtAct.triggered[()].connect(self.__aboutQt) 779 self.aboutQtAct.triggered.connect(self.__aboutQt)
781 self.__actions.append(self.aboutQtAct) 780 self.__actions.append(self.aboutQtAct)
782 781
783 self.whatsThisAct = E5Action( 782 self.whatsThisAct = E5Action(
784 self.trUtf8('What\'s This?'), 783 self.tr('What\'s This?'),
785 UI.PixmapCache.getIcon("whatsThis.png"), 784 UI.PixmapCache.getIcon("whatsThis.png"),
786 self.trUtf8('&What\'s This?'), 785 self.tr('&What\'s This?'),
787 QKeySequence(self.trUtf8("Shift+F1", "Help|What's This?'")), 786 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
788 0, self, 'iconEditor_help_whats_this') 787 0, self, 'iconEditor_help_whats_this')
789 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help')) 788 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help'))
790 self.whatsThisAct.setWhatsThis(self.trUtf8( 789 self.whatsThisAct.setWhatsThis(self.tr(
791 """<b>Display context sensitive help</b>""" 790 """<b>Display context sensitive help</b>"""
792 """<p>In What's This? mode, the mouse cursor shows an arrow""" 791 """<p>In What's This? mode, the mouse cursor shows an arrow"""
793 """ with a question mark, and you can click on the interface""" 792 """ with a question mark, and you can click on the interface"""
794 """ elements to get a short description of what they do and""" 793 """ elements to get a short description of what they do and"""
795 """ how to use them. In dialogs, this feature can be accessed""" 794 """ how to use them. In dialogs, this feature can be accessed"""
796 """ using the context help button in the titlebar.</p>""" 795 """ using the context help button in the titlebar.</p>"""
797 )) 796 ))
798 self.whatsThisAct.triggered[()].connect(self.__whatsThis) 797 self.whatsThisAct.triggered.connect(self.__whatsThis)
799 self.__actions.append(self.whatsThisAct) 798 self.__actions.append(self.whatsThisAct)
800 799
801 def __initMenus(self): 800 def __initMenus(self):
802 """ 801 """
803 Private method to create the menus. 802 Private method to create the menus.
804 """ 803 """
805 mb = self.menuBar() 804 mb = self.menuBar()
806 805
807 menu = mb.addMenu(self.trUtf8('&File')) 806 menu = mb.addMenu(self.tr('&File'))
808 menu.setTearOffEnabled(True) 807 menu.setTearOffEnabled(True)
809 menu.addAction(self.newAct) 808 menu.addAction(self.newAct)
810 menu.addAction(self.newWindowAct) 809 menu.addAction(self.newWindowAct)
811 menu.addAction(self.openAct) 810 menu.addAction(self.openAct)
812 menu.addSeparator() 811 menu.addSeparator()
813 menu.addAction(self.saveAct) 812 menu.addAction(self.saveAct)
814 menu.addAction(self.saveAsAct) 813 menu.addAction(self.saveAsAct)
815 menu.addSeparator() 814 menu.addSeparator()
816 menu.addAction(self.closeAct) 815 menu.addAction(self.closeAct)
817 menu.addAction(self.closeAllAct) 816 if self.fromEric:
818 if not self.fromEric: 817 menu.addAction(self.closeAllAct)
818 else:
819 menu.addSeparator() 819 menu.addSeparator()
820 menu.addAction(self.exitAct) 820 menu.addAction(self.exitAct)
821 821
822 menu = mb.addMenu(self.trUtf8("&Edit")) 822 menu = mb.addMenu(self.tr("&Edit"))
823 menu.setTearOffEnabled(True) 823 menu.setTearOffEnabled(True)
824 menu.addAction(self.undoAct) 824 menu.addAction(self.undoAct)
825 menu.addAction(self.redoAct) 825 menu.addAction(self.redoAct)
826 menu.addSeparator() 826 menu.addSeparator()
827 menu.addAction(self.cutAct) 827 menu.addAction(self.cutAct)
833 menu.addAction(self.selectAllAct) 833 menu.addAction(self.selectAllAct)
834 menu.addSeparator() 834 menu.addSeparator()
835 menu.addAction(self.resizeAct) 835 menu.addAction(self.resizeAct)
836 menu.addAction(self.grayscaleAct) 836 menu.addAction(self.grayscaleAct)
837 837
838 menu = mb.addMenu(self.trUtf8('&View')) 838 menu = mb.addMenu(self.tr('&View'))
839 menu.setTearOffEnabled(True) 839 menu.setTearOffEnabled(True)
840 menu.addAction(self.zoomInAct) 840 menu.addAction(self.zoomInAct)
841 menu.addAction(self.zoomResetAct) 841 menu.addAction(self.zoomResetAct)
842 menu.addAction(self.zoomOutAct) 842 menu.addAction(self.zoomOutAct)
843 menu.addSeparator() 843 menu.addSeparator()
844 menu.addAction(self.showGridAct) 844 menu.addAction(self.showGridAct)
845 845
846 menu = mb.addMenu(self.trUtf8('&Tools')) 846 menu = mb.addMenu(self.tr('&Tools'))
847 menu.setTearOffEnabled(True) 847 menu.setTearOffEnabled(True)
848 menu.addAction(self.drawPencilAct) 848 menu.addAction(self.drawPencilAct)
849 menu.addAction(self.drawColorPickerAct) 849 menu.addAction(self.drawColorPickerAct)
850 menu.addAction(self.drawRectangleAct) 850 menu.addAction(self.drawRectangleAct)
851 menu.addAction(self.drawFilledRectangleAct) 851 menu.addAction(self.drawFilledRectangleAct)
860 menu.addAction(self.drawRectangleSelectionAct) 860 menu.addAction(self.drawRectangleSelectionAct)
861 menu.addAction(self.drawCircleSelectionAct) 861 menu.addAction(self.drawCircleSelectionAct)
862 862
863 mb.addSeparator() 863 mb.addSeparator()
864 864
865 menu = mb.addMenu(self.trUtf8("&Help")) 865 menu = mb.addMenu(self.tr("&Help"))
866 menu.addAction(self.aboutAct) 866 menu.addAction(self.aboutAct)
867 menu.addAction(self.aboutQtAct) 867 menu.addAction(self.aboutQtAct)
868 menu.addSeparator() 868 menu.addSeparator()
869 menu.addAction(self.whatsThisAct) 869 menu.addAction(self.whatsThisAct)
870 870
871 def __initToolbars(self): 871 def __initToolbars(self):
872 """ 872 """
873 Private method to create the toolbars. 873 Private method to create the toolbars.
874 """ 874 """
875 filetb = self.addToolBar(self.trUtf8("File")) 875 filetb = self.addToolBar(self.tr("File"))
876 filetb.setObjectName("FileToolBar") 876 filetb.setObjectName("FileToolBar")
877 filetb.setIconSize(UI.Config.ToolBarIconSize) 877 filetb.setIconSize(UI.Config.ToolBarIconSize)
878 filetb.addAction(self.newAct) 878 filetb.addAction(self.newAct)
879 filetb.addAction(self.newWindowAct) 879 filetb.addAction(self.newWindowAct)
880 filetb.addAction(self.openAct) 880 filetb.addAction(self.openAct)
884 filetb.addSeparator() 884 filetb.addSeparator()
885 filetb.addAction(self.closeAct) 885 filetb.addAction(self.closeAct)
886 if not self.fromEric: 886 if not self.fromEric:
887 filetb.addAction(self.exitAct) 887 filetb.addAction(self.exitAct)
888 888
889 edittb = self.addToolBar(self.trUtf8("Edit")) 889 edittb = self.addToolBar(self.tr("Edit"))
890 edittb.setObjectName("EditToolBar") 890 edittb.setObjectName("EditToolBar")
891 edittb.setIconSize(UI.Config.ToolBarIconSize) 891 edittb.setIconSize(UI.Config.ToolBarIconSize)
892 edittb.addAction(self.undoAct) 892 edittb.addAction(self.undoAct)
893 edittb.addAction(self.redoAct) 893 edittb.addAction(self.redoAct)
894 edittb.addSeparator() 894 edittb.addSeparator()
897 edittb.addAction(self.pasteAct) 897 edittb.addAction(self.pasteAct)
898 edittb.addSeparator() 898 edittb.addSeparator()
899 edittb.addAction(self.resizeAct) 899 edittb.addAction(self.resizeAct)
900 edittb.addAction(self.grayscaleAct) 900 edittb.addAction(self.grayscaleAct)
901 901
902 viewtb = self.addToolBar(self.trUtf8("View")) 902 viewtb = self.addToolBar(self.tr("View"))
903 viewtb.setObjectName("ViewToolBar") 903 viewtb.setObjectName("ViewToolBar")
904 viewtb.setIconSize(UI.Config.ToolBarIconSize) 904 viewtb.setIconSize(UI.Config.ToolBarIconSize)
905 viewtb.addAction(self.showGridAct) 905 viewtb.addAction(self.showGridAct)
906 906
907 toolstb = self.addToolBar(self.trUtf8("Tools")) 907 toolstb = self.addToolBar(self.tr("Tools"))
908 toolstb.setObjectName("ToolsToolBar") 908 toolstb.setObjectName("ToolsToolBar")
909 toolstb.setIconSize(UI.Config.ToolBarIconSize) 909 toolstb.setIconSize(UI.Config.ToolBarIconSize)
910 toolstb.addAction(self.drawPencilAct) 910 toolstb.addAction(self.drawPencilAct)
911 toolstb.addAction(self.drawColorPickerAct) 911 toolstb.addAction(self.drawColorPickerAct)
912 toolstb.addAction(self.drawRectangleAct) 912 toolstb.addAction(self.drawRectangleAct)
920 toolstb.addAction(self.drawEraserAct) 920 toolstb.addAction(self.drawEraserAct)
921 toolstb.addSeparator() 921 toolstb.addSeparator()
922 toolstb.addAction(self.drawRectangleSelectionAct) 922 toolstb.addAction(self.drawRectangleSelectionAct)
923 toolstb.addAction(self.drawCircleSelectionAct) 923 toolstb.addAction(self.drawCircleSelectionAct)
924 924
925 helptb = self.addToolBar(self.trUtf8("Help")) 925 helptb = self.addToolBar(self.tr("Help"))
926 helptb.setObjectName("HelpToolBar") 926 helptb.setObjectName("HelpToolBar")
927 helptb.setIconSize(UI.Config.ToolBarIconSize) 927 helptb.setIconSize(UI.Config.ToolBarIconSize)
928 helptb.addAction(self.whatsThisAct) 928 helptb.addAction(self.whatsThisAct)
929 929
930 def __createStatusBar(self): 930 def __createStatusBar(self):
934 self.__statusBar = self.statusBar() 934 self.__statusBar = self.statusBar()
935 self.__statusBar.setSizeGripEnabled(True) 935 self.__statusBar.setSizeGripEnabled(True)
936 936
937 self.__sbSize = QLabel(self.__statusBar) 937 self.__sbSize = QLabel(self.__statusBar)
938 self.__statusBar.addPermanentWidget(self.__sbSize) 938 self.__statusBar.addPermanentWidget(self.__sbSize)
939 self.__sbSize.setWhatsThis(self.trUtf8( 939 self.__sbSize.setWhatsThis(self.tr(
940 """<p>This part of the status bar displays the icon size.</p>""" 940 """<p>This part of the status bar displays the icon size.</p>"""
941 )) 941 ))
942 self.__updateSize(*self.__editor.iconSize()) 942 self.__updateSize(*self.__editor.iconSize())
943 943
944 self.__sbPos = QLabel(self.__statusBar) 944 self.__sbPos = QLabel(self.__statusBar)
945 self.__statusBar.addPermanentWidget(self.__sbPos) 945 self.__statusBar.addPermanentWidget(self.__sbPos)
946 self.__sbPos.setWhatsThis(self.trUtf8( 946 self.__sbPos.setWhatsThis(self.tr(
947 """<p>This part of the status bar displays the cursor""" 947 """<p>This part of the status bar displays the cursor"""
948 """ position.</p>""" 948 """ position.</p>"""
949 )) 949 ))
950 self.__updatePosition(0, 0) 950 self.__updatePosition(0, 0)
951 951
1039 if self.__project and self.__project.isOpen(): 1039 if self.__project and self.__project.isOpen():
1040 self.__lastOpenPath = self.__project.getProjectPath() 1040 self.__lastOpenPath = self.__project.getProjectPath()
1041 1041
1042 fileName = E5FileDialog.getOpenFileNameAndFilter( 1042 fileName = E5FileDialog.getOpenFileNameAndFilter(
1043 self, 1043 self,
1044 self.trUtf8("Open icon file"), 1044 self.tr("Open icon file"),
1045 self.__lastOpenPath, 1045 self.__lastOpenPath,
1046 self.__inputFilter, 1046 self.__inputFilter,
1047 self.__defaultFilter)[0] 1047 self.__defaultFilter)[0]
1048 if fileName: 1048 if fileName:
1049 self.__loadIconFile(fileName) 1049 self.__loadIconFile(fileName)
1073 if not self.__lastSavePath and self.__lastOpenPath: 1073 if not self.__lastSavePath and self.__lastOpenPath:
1074 self.__lastSavePath = self.__lastOpenPath 1074 self.__lastSavePath = self.__lastOpenPath
1075 1075
1076 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 1076 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
1077 self, 1077 self,
1078 self.trUtf8("Save icon file"), 1078 self.tr("Save icon file"),
1079 self.__lastSavePath, 1079 self.__lastSavePath,
1080 self.__outputFilter, 1080 self.__outputFilter,
1081 self.__defaultFilter, 1081 self.__defaultFilter,
1082 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 1082 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
1083 if not fileName: 1083 if not fileName:
1089 if ex: 1089 if ex:
1090 fileName += ex 1090 fileName += ex
1091 if QFileInfo(fileName).exists(): 1091 if QFileInfo(fileName).exists():
1092 res = E5MessageBox.yesNo( 1092 res = E5MessageBox.yesNo(
1093 self, 1093 self,
1094 self.trUtf8("Save icon file"), 1094 self.tr("Save icon file"),
1095 self.trUtf8("<p>The file <b>{0}</b> already exists." 1095 self.tr("<p>The file <b>{0}</b> already exists."
1096 " Overwrite it?</p>").format(fileName), 1096 " Overwrite it?</p>").format(fileName),
1097 icon=E5MessageBox.Warning) 1097 icon=E5MessageBox.Warning)
1098 if not res: 1098 if not res:
1099 return False 1099 return False
1100 1100
1101 self.__lastSavePath = os.path.dirname(fileName) 1101 self.__lastSavePath = os.path.dirname(fileName)
1118 @param fileName name of the icon file to load (string). 1118 @param fileName name of the icon file to load (string).
1119 """ 1119 """
1120 file = QFile(fileName) 1120 file = QFile(fileName)
1121 if not file.exists(): 1121 if not file.exists():
1122 E5MessageBox.warning( 1122 E5MessageBox.warning(
1123 self, self.trUtf8("eric5 Icon Editor"), 1123 self, self.tr("eric5 Icon Editor"),
1124 self.trUtf8("The file '{0}' does not exist.") 1124 self.tr("The file '{0}' does not exist.")
1125 .format(fileName)) 1125 .format(fileName))
1126 return 1126 return
1127 1127
1128 if not file.open(QFile.ReadOnly): 1128 if not file.open(QFile.ReadOnly):
1129 E5MessageBox.warning( 1129 E5MessageBox.warning(
1130 self, self.trUtf8("eric5 Icon Editor"), 1130 self, self.tr("eric5 Icon Editor"),
1131 self.trUtf8("Cannot read file '{0}:\n{1}.") 1131 self.tr("Cannot read file '{0}:\n{1}.")
1132 .format(fileName, file.errorString())) 1132 .format(fileName, file.errorString()))
1133 return 1133 return
1134 file.close() 1134 file.close()
1135 1135
1136 img = QImage(fileName) 1136 img = QImage(fileName)
1145 @return flag indicating success (boolean) 1145 @return flag indicating success (boolean)
1146 """ 1146 """
1147 file = QFile(fileName) 1147 file = QFile(fileName)
1148 if not file.open(QFile.WriteOnly): 1148 if not file.open(QFile.WriteOnly):
1149 E5MessageBox.warning( 1149 E5MessageBox.warning(
1150 self, self.trUtf8("eric5 Icon Editor"), 1150 self, self.tr("eric5 Icon Editor"),
1151 self.trUtf8("Cannot write file '{0}:\n{1}.") 1151 self.tr("Cannot write file '{0}:\n{1}.")
1152 .format(fileName, file.errorString())) 1152 .format(fileName, file.errorString()))
1153 1153
1154 self.__checkActions() 1154 self.__checkActions()
1155 1155
1156 return False 1156 return False
1159 res = img.save(file) 1159 res = img.save(file)
1160 file.close() 1160 file.close()
1161 1161
1162 if not res: 1162 if not res:
1163 E5MessageBox.warning( 1163 E5MessageBox.warning(
1164 self, self.trUtf8("eric5 Icon Editor"), 1164 self, self.tr("eric5 Icon Editor"),
1165 self.trUtf8("Cannot write file '{0}:\n{1}.") 1165 self.tr("Cannot write file '{0}:\n{1}.")
1166 .format(fileName, file.errorString())) 1166 .format(fileName, file.errorString()))
1167 1167
1168 self.__checkActions() 1168 self.__checkActions()
1169 1169
1170 return False 1170 return False
1171 1171
1172 self.__editor.setDirty(False, setCleanState=True) 1172 self.__editor.setDirty(False, setCleanState=True)
1173 1173
1174 self.__setCurrentFile(fileName) 1174 self.__setCurrentFile(fileName)
1175 self.__statusBar.showMessage(self.trUtf8("Icon saved"), 2000) 1175 self.__statusBar.showMessage(self.tr("Icon saved"), 2000)
1176 1176
1177 self.__checkActions() 1177 self.__checkActions()
1178 1178
1179 return True 1179 return True
1180 1180
1185 @param fileName name of the file to register (string) 1185 @param fileName name of the file to register (string)
1186 """ 1186 """
1187 self.__fileName = fileName 1187 self.__fileName = fileName
1188 1188
1189 if not self.__fileName: 1189 if not self.__fileName:
1190 shownName = self.trUtf8("Untitled") 1190 shownName = self.tr("Untitled")
1191 else: 1191 else:
1192 shownName = self.__strippedName(self.__fileName) 1192 shownName = self.__strippedName(self.__fileName)
1193 1193
1194 self.setWindowTitle(self.trUtf8("{0}[*] - {1}") 1194 self.setWindowTitle(self.tr("{0}[*] - {1}")
1195 .format(shownName, self.trUtf8("Icon Editor"))) 1195 .format(shownName, self.tr("Icon Editor")))
1196 1196
1197 self.setWindowModified(self.__editor.isDirty()) 1197 self.setWindowModified(self.__editor.isDirty())
1198 1198
1199 def __strippedName(self, fullFileName): 1199 def __strippedName(self, fullFileName):
1200 """ 1200 """
1212 @return flag indicating, if it is ok to continue (boolean) 1212 @return flag indicating, if it is ok to continue (boolean)
1213 """ 1213 """
1214 if self.__editor.isDirty(): 1214 if self.__editor.isDirty():
1215 ret = E5MessageBox.okToClearData( 1215 ret = E5MessageBox.okToClearData(
1216 self, 1216 self,
1217 self.trUtf8("eric5 Icon Editor"), 1217 self.tr("eric5 Icon Editor"),
1218 self.trUtf8("""The icon image has unsaved changes."""), 1218 self.tr("""The icon image has unsaved changes."""),
1219 self.__saveIcon) 1219 self.__saveIcon)
1220 if not ret: 1220 if not ret:
1221 return False 1221 return False
1222 return True 1222 return True
1223 1223
1301 def __about(self): 1301 def __about(self):
1302 """ 1302 """
1303 Private slot to show a little About message. 1303 Private slot to show a little About message.
1304 """ 1304 """
1305 E5MessageBox.about( 1305 E5MessageBox.about(
1306 self, self.trUtf8("About eric5 Icon Editor"), 1306 self, self.tr("About eric5 Icon Editor"),
1307 self.trUtf8("The eric5 Icon Editor is a simple editor component" 1307 self.tr("The eric5 Icon Editor is a simple editor component"
1308 " to perform icon drawing tasks.")) 1308 " to perform icon drawing tasks."))
1309 1309
1310 def __aboutQt(self): 1310 def __aboutQt(self):
1311 """ 1311 """
1312 Private slot to handle the About Qt dialog. 1312 Private slot to handle the About Qt dialog.
1313 """ 1313 """

eric ide

mercurial