9 |
9 |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, QFile, \ |
14 from PyQt4.QtCore import pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, \ |
15 QEvent |
15 QFile, QEvent |
16 from PyQt4.QtGui import QScrollArea, QPalette, QImage, QImageReader, QImageWriter, \ |
16 from PyQt4.QtGui import QScrollArea, QPalette, QImage, QImageReader, \ |
17 QKeySequence, QLabel, QDockWidget, QWhatsThis |
17 QImageWriter, QKeySequence, QLabel, QDockWidget, QWhatsThis |
18 |
18 |
19 from E5Gui.E5Action import E5Action, createActionGroup |
19 from E5Gui.E5Action import E5Action, createActionGroup |
20 from E5Gui import E5FileDialog, E5MessageBox |
20 from E5Gui import E5FileDialog, E5MessageBox |
21 from E5Gui.E5MainWindow import E5MainWindow |
21 from E5Gui.E5MainWindow import E5MainWindow |
22 from E5Gui.E5ZoomWidget import E5ZoomWidget |
22 from E5Gui.E5ZoomWidget import E5ZoomWidget |
46 |
46 |
47 @param fileName name of a file to load on startup (string) |
47 @param fileName name of a file to load on startup (string) |
48 @param parent parent widget of this window (QWidget) |
48 @param parent parent widget of this window (QWidget) |
49 @keyparam fromEric flag indicating whether it was called from within |
49 @keyparam fromEric flag indicating whether it was called from within |
50 eric5 (boolean) |
50 eric5 (boolean) |
51 @keyparam initShortcutsOnly flag indicating to just initialize the keyboard |
51 @keyparam initShortcutsOnly flag indicating to just initialize the |
52 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) |
57 self.setAttribute(Qt.WA_DeleteOnClose) |
62 |
62 |
63 if self.initShortcutsOnly: |
63 if self.initShortcutsOnly: |
64 self.__initActions() |
64 self.__initActions() |
65 else: |
65 else: |
66 if not self.fromEric: |
66 if not self.fromEric: |
67 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) |
67 self.setStyle(Preferences.getUI("Style"), |
|
68 Preferences.getUI("StyleSheet")) |
68 self.__editor = IconEditorGrid() |
69 self.__editor = IconEditorGrid() |
69 self.__scrollArea = QScrollArea() |
70 self.__scrollArea = QScrollArea() |
70 self.__scrollArea.setWidget(self.__editor) |
71 self.__scrollArea.setWidget(self.__editor) |
71 self.__scrollArea.viewport().setBackgroundRole(QPalette.Dark) |
72 self.__scrollArea.viewport().setBackgroundRole(QPalette.Dark) |
72 self.__scrollArea.viewport().setAutoFillBackground(True) |
73 self.__scrollArea.viewport().setAutoFillBackground(True) |
99 self.__editor.positionChanged.connect(self.__updatePosition) |
100 self.__editor.positionChanged.connect(self.__updatePosition) |
100 self.__editor.sizeChanged.connect(self.__updateSize) |
101 self.__editor.sizeChanged.connect(self.__updateSize) |
101 self.__editor.previewChanged.connect(self.__palette.previewChanged) |
102 self.__editor.previewChanged.connect(self.__palette.previewChanged) |
102 self.__editor.colorChanged.connect(self.__palette.colorChanged) |
103 self.__editor.colorChanged.connect(self.__palette.colorChanged) |
103 self.__palette.colorSelected.connect(self.__editor.setPenColor) |
104 self.__palette.colorSelected.connect(self.__editor.setPenColor) |
104 self.__palette.compositingChanged.connect(self.__editor.setCompositingMode) |
105 self.__palette.compositingChanged.connect( |
|
106 self.__editor.setCompositingMode) |
105 |
107 |
106 self.__setCurrentFile("") |
108 self.__setCurrentFile("") |
107 if fileName: |
109 if fileName: |
108 self.__loadIconFile(fileName) |
110 self.__loadIconFile(fileName) |
109 |
111 |
131 'pgm': self.trUtf8("Portable Graymap File (*.pgm)"), |
133 'pgm': self.trUtf8("Portable Graymap File (*.pgm)"), |
132 'png': self.trUtf8("Portable Network Graphics File (*.png)"), |
134 'png': self.trUtf8("Portable Network Graphics File (*.png)"), |
133 'ppm': self.trUtf8("Portable Pixmap File (*.ppm)"), |
135 'ppm': self.trUtf8("Portable Pixmap File (*.ppm)"), |
134 'sgi': self.trUtf8("Silicon Graphics Image File (*.sgi)"), |
136 'sgi': self.trUtf8("Silicon Graphics Image File (*.sgi)"), |
135 'svg': self.trUtf8("Scalable Vector Graphics File (*.svg)"), |
137 'svg': self.trUtf8("Scalable Vector Graphics File (*.svg)"), |
136 'svgz': self.trUtf8("Compressed Scalable Vector Graphics File (*.svgz)"), |
138 'svgz': self.trUtf8("Compressed Scalable Vector Graphics File" |
|
139 " (*.svgz)"), |
137 'tga': self.trUtf8("Targa Graphic File (*.tga)"), |
140 'tga': self.trUtf8("Targa Graphic File (*.tga)"), |
138 'tif': self.trUtf8("TIFF File (*.tif)"), |
141 'tif': self.trUtf8("TIFF File (*.tif)"), |
139 'tiff': self.trUtf8("TIFF File (*.tiff)"), |
142 'tiff': self.trUtf8("TIFF File (*.tiff)"), |
140 'wbmp': self.trUtf8("WAP Bitmap File (*.wbmp)"), |
143 'wbmp': self.trUtf8("WAP Bitmap File (*.wbmp)"), |
141 'xbm': self.trUtf8("X11 Bitmap File (*.xbm)"), |
144 'xbm': self.trUtf8("X11 Bitmap File (*.xbm)"), |
197 |
200 |
198 self.newWindowAct = E5Action(self.trUtf8('New Window'), |
201 self.newWindowAct = E5Action(self.trUtf8('New Window'), |
199 UI.PixmapCache.getIcon("newWindow.png"), |
202 UI.PixmapCache.getIcon("newWindow.png"), |
200 self.trUtf8('New &Window'), |
203 self.trUtf8('New &Window'), |
201 0, 0, self, 'iconEditor_file_new_window') |
204 0, 0, self, 'iconEditor_file_new_window') |
202 self.newWindowAct.setStatusTip(self.trUtf8('Open a new icon editor window')) |
205 self.newWindowAct.setStatusTip(self.trUtf8( |
|
206 'Open a new icon editor window')) |
203 self.newWindowAct.setWhatsThis(self.trUtf8( |
207 self.newWindowAct.setWhatsThis(self.trUtf8( |
204 """<b>New Window</b>""" |
208 """<b>New Window</b>""" |
205 """<p>This opens a new icon editor window.</p>""" |
209 """<p>This opens a new icon editor window.</p>""" |
206 )) |
210 )) |
207 self.newWindowAct.triggered[()].connect(self.__newWindow) |
211 self.newWindowAct.triggered[()].connect(self.__newWindow) |
251 self.closeAct = E5Action(self.trUtf8('Close'), |
255 self.closeAct = E5Action(self.trUtf8('Close'), |
252 UI.PixmapCache.getIcon("close.png"), |
256 UI.PixmapCache.getIcon("close.png"), |
253 self.trUtf8('&Close'), |
257 self.trUtf8('&Close'), |
254 QKeySequence(self.trUtf8("Ctrl+W", "File|Close")), |
258 QKeySequence(self.trUtf8("Ctrl+W", "File|Close")), |
255 0, self, 'iconEditor_file_close') |
259 0, self, 'iconEditor_file_close') |
256 self.closeAct.setStatusTip(self.trUtf8('Close the current icon editor window')) |
260 self.closeAct.setStatusTip(self.trUtf8( |
|
261 'Close the current icon editor window')) |
257 self.closeAct.setWhatsThis(self.trUtf8( |
262 self.closeAct.setWhatsThis(self.trUtf8( |
258 """<b>Close</b>""" |
263 """<b>Close</b>""" |
259 """<p>Closes the current icon editor window.</p>""" |
264 """<p>Closes the current icon editor window.</p>""" |
260 )) |
265 )) |
261 self.closeAct.triggered[()].connect(self.close) |
266 self.closeAct.triggered[()].connect(self.close) |
262 self.__actions.append(self.closeAct) |
267 self.__actions.append(self.closeAct) |
263 |
268 |
264 self.closeAllAct = E5Action(self.trUtf8('Close All'), |
269 self.closeAllAct = E5Action(self.trUtf8('Close All'), |
265 self.trUtf8('Close &All'), |
270 self.trUtf8('Close &All'), |
266 0, 0, self, 'iconEditor_file_close_all') |
271 0, 0, self, 'iconEditor_file_close_all') |
267 self.closeAllAct.setStatusTip(self.trUtf8('Close all icon editor windows')) |
272 self.closeAllAct.setStatusTip(self.trUtf8( |
|
273 'Close all icon editor windows')) |
268 self.closeAllAct.setWhatsThis(self.trUtf8( |
274 self.closeAllAct.setWhatsThis(self.trUtf8( |
269 """<b>Close All</b>""" |
275 """<b>Close All</b>""" |
270 """<p>Closes all icon editor windows except the first one.</p>""" |
276 """<p>Closes all icon editor windows except the first one.</p>""" |
271 )) |
277 )) |
272 self.closeAllAct.triggered[()].connect(self.__closeAll) |
278 self.closeAllAct.triggered[()].connect(self.__closeAll) |
273 self.__actions.append(self.closeAllAct) |
279 self.__actions.append(self.closeAllAct) |
274 |
280 |
275 self.exitAct = E5Action(self.trUtf8('Quit'), |
281 self.exitAct = E5Action(self.trUtf8('Quit'), |
378 0, |
384 0, |
379 self, 'iconEditor_edit_clear') |
385 self, 'iconEditor_edit_clear') |
380 self.deleteAct.setStatusTip(self.trUtf8('Clear the icon image')) |
386 self.deleteAct.setStatusTip(self.trUtf8('Clear the icon image')) |
381 self.deleteAct.setWhatsThis(self.trUtf8( |
387 self.deleteAct.setWhatsThis(self.trUtf8( |
382 """<b>Clear</b>""" |
388 """<b>Clear</b>""" |
383 """<p>Clear the icon image and set it to be completely transparent.</p>""" |
389 """<p>Clear the icon image and set it to be completely""" |
|
390 """ transparent.</p>""" |
384 )) |
391 )) |
385 self.deleteAct.triggered[()].connect(self.__editor.editClear) |
392 self.deleteAct.triggered[()].connect(self.__editor.editClear) |
386 self.__actions.append(self.deleteAct) |
393 self.__actions.append(self.deleteAct) |
387 |
394 |
388 self.selectAllAct = E5Action(self.trUtf8('Select All'), |
395 self.selectAllAct = E5Action(self.trUtf8('Select All'), |
389 self.trUtf8('&Select All'), |
396 self.trUtf8('&Select All'), |
390 QKeySequence(self.trUtf8("Ctrl+A", "Edit|Select All")), |
397 QKeySequence(self.trUtf8("Ctrl+A", "Edit|Select All")), |
391 0, |
398 0, |
392 self, 'iconEditor_edit_select_all') |
399 self, 'iconEditor_edit_select_all') |
393 self.selectAllAct.setStatusTip(self.trUtf8('Select the complete icon image')) |
400 self.selectAllAct.setStatusTip(self.trUtf8( |
|
401 'Select the complete icon image')) |
394 self.selectAllAct.setWhatsThis(self.trUtf8( |
402 self.selectAllAct.setWhatsThis(self.trUtf8( |
395 """<b>Select All</b>""" |
403 """<b>Select All</b>""" |
396 """<p>Selects the complete icon image.</p>""" |
404 """<p>Selects the complete icon image.</p>""" |
397 )) |
405 )) |
398 self.selectAllAct.triggered[()].connect(self.__editor.editSelectAll) |
406 self.selectAllAct.triggered[()].connect(self.__editor.editSelectAll) |
414 self.grayscaleAct = E5Action(self.trUtf8('Grayscale'), |
422 self.grayscaleAct = E5Action(self.trUtf8('Grayscale'), |
415 UI.PixmapCache.getIcon("grayscale.png"), |
423 UI.PixmapCache.getIcon("grayscale.png"), |
416 self.trUtf8('&Grayscale'), |
424 self.trUtf8('&Grayscale'), |
417 0, 0, |
425 0, 0, |
418 self, 'iconEditor_edit_grayscale') |
426 self, 'iconEditor_edit_grayscale') |
419 self.grayscaleAct.setStatusTip(self.trUtf8('Change the icon to grayscale')) |
427 self.grayscaleAct.setStatusTip(self.trUtf8( |
|
428 'Change the icon to grayscale')) |
420 self.grayscaleAct.setWhatsThis(self.trUtf8( |
429 self.grayscaleAct.setWhatsThis(self.trUtf8( |
421 """<b>Grayscale</b>""" |
430 """<b>Grayscale</b>""" |
422 """<p>Changes the icon to grayscale.</p>""" |
431 """<p>Changes the icon to grayscale.</p>""" |
423 )) |
432 )) |
424 self.grayscaleAct.triggered[()].connect(self.__editor.grayScale) |
433 self.grayscaleAct.triggered[()].connect(self.__editor.grayScale) |
475 self.zoomResetAct = E5Action(self.trUtf8('Zoom reset'), |
484 self.zoomResetAct = E5Action(self.trUtf8('Zoom reset'), |
476 UI.PixmapCache.getIcon("zoomReset.png"), |
485 UI.PixmapCache.getIcon("zoomReset.png"), |
477 self.trUtf8('Zoom &reset'), |
486 self.trUtf8('Zoom &reset'), |
478 QKeySequence(self.trUtf8("Ctrl+0", "View|Zoom reset")), |
487 QKeySequence(self.trUtf8("Ctrl+0", "View|Zoom reset")), |
479 0, self, 'iconEditor_view_zoom_reset') |
488 0, self, 'iconEditor_view_zoom_reset') |
480 self.zoomResetAct.setStatusTip(self.trUtf8('Reset the zoom of the icon')) |
489 self.zoomResetAct.setStatusTip(self.trUtf8( |
|
490 'Reset the zoom of the icon')) |
481 self.zoomResetAct.setWhatsThis(self.trUtf8( |
491 self.zoomResetAct.setWhatsThis(self.trUtf8( |
482 """<b>Zoom reset</b>""" |
492 """<b>Zoom reset</b>""" |
483 """<p>Reset the zoom of the icon. """ |
493 """<p>Reset the zoom of the icon. """ |
484 """This sets the zoom factor to 100%.</p>""" |
494 """This sets the zoom factor to 100%.</p>""" |
485 )) |
495 )) |
489 self.showGridAct = E5Action(self.trUtf8('Show Grid'), |
499 self.showGridAct = E5Action(self.trUtf8('Show Grid'), |
490 UI.PixmapCache.getIcon("grid.png"), |
500 UI.PixmapCache.getIcon("grid.png"), |
491 self.trUtf8('Show &Grid'), |
501 self.trUtf8('Show &Grid'), |
492 0, 0, |
502 0, 0, |
493 self, 'iconEditor_view_show_grid') |
503 self, 'iconEditor_view_show_grid') |
494 self.showGridAct.setStatusTip(self.trUtf8('Toggle the display of the grid')) |
504 self.showGridAct.setStatusTip(self.trUtf8( |
|
505 'Toggle the display of the grid')) |
495 self.showGridAct.setWhatsThis(self.trUtf8( |
506 self.showGridAct.setWhatsThis(self.trUtf8( |
496 """<b>Show Grid</b>""" |
507 """<b>Show Grid</b>""" |
497 """<p>Toggle the display of the grid.</p>""" |
508 """<p>Toggle the display of the grid.</p>""" |
498 )) |
509 )) |
499 self.showGridAct.triggered[bool].connect(self.__editor.setGridEnabled) |
510 self.showGridAct.triggered[bool].connect(self.__editor.setGridEnabled) |
534 """<b>Color Picker</b>""" |
545 """<b>Color Picker</b>""" |
535 """<p>The color of the pixel clicked on will become """ |
546 """<p>The color of the pixel clicked on will become """ |
536 """the current draw color.</p>""" |
547 """the current draw color.</p>""" |
537 )) |
548 )) |
538 self.drawColorPickerAct.setCheckable(True) |
549 self.drawColorPickerAct.setCheckable(True) |
539 self.esm.setMapping(self.drawColorPickerAct, IconEditorGrid.ColorPicker) |
550 self.esm.setMapping(self.drawColorPickerAct, |
|
551 IconEditorGrid.ColorPicker) |
540 self.drawColorPickerAct.triggered[()].connect(self.esm.map) |
552 self.drawColorPickerAct.triggered[()].connect(self.esm.map) |
541 self.__actions.append(self.drawColorPickerAct) |
553 self.__actions.append(self.drawColorPickerAct) |
542 |
554 |
543 self.drawRectangleAct = E5Action(self.trUtf8('Rectangle'), |
555 self.drawRectangleAct = E5Action(self.trUtf8('Rectangle'), |
544 UI.PixmapCache.getIcon("drawRectangle.png"), |
556 UI.PixmapCache.getIcon("drawRectangle.png"), |
562 self.drawFilledRectangleAct.setWhatsThis(self.trUtf8( |
574 self.drawFilledRectangleAct.setWhatsThis(self.trUtf8( |
563 """<b>Filled Rectangle</b>""" |
575 """<b>Filled Rectangle</b>""" |
564 """<p>Draw a filled rectangle.</p>""" |
576 """<p>Draw a filled rectangle.</p>""" |
565 )) |
577 )) |
566 self.drawFilledRectangleAct.setCheckable(True) |
578 self.drawFilledRectangleAct.setCheckable(True) |
567 self.esm.setMapping(self.drawFilledRectangleAct, IconEditorGrid.FilledRectangle) |
579 self.esm.setMapping(self.drawFilledRectangleAct, |
|
580 IconEditorGrid.FilledRectangle) |
568 self.drawFilledRectangleAct.triggered[()].connect(self.esm.map) |
581 self.drawFilledRectangleAct.triggered[()].connect(self.esm.map) |
569 self.__actions.append(self.drawFilledRectangleAct) |
582 self.__actions.append(self.drawFilledRectangleAct) |
570 |
583 |
571 self.drawCircleAct = E5Action(self.trUtf8('Circle'), |
584 self.drawCircleAct = E5Action(self.trUtf8('Circle'), |
572 UI.PixmapCache.getIcon("drawCircle.png"), |
585 UI.PixmapCache.getIcon("drawCircle.png"), |
590 self.drawFilledCircleAct.setWhatsThis(self.trUtf8( |
603 self.drawFilledCircleAct.setWhatsThis(self.trUtf8( |
591 """<b>Filled Circle</b>""" |
604 """<b>Filled Circle</b>""" |
592 """<p>Draw a filled circle.</p>""" |
605 """<p>Draw a filled circle.</p>""" |
593 )) |
606 )) |
594 self.drawFilledCircleAct.setCheckable(True) |
607 self.drawFilledCircleAct.setCheckable(True) |
595 self.esm.setMapping(self.drawFilledCircleAct, IconEditorGrid.FilledCircle) |
608 self.esm.setMapping(self.drawFilledCircleAct, |
|
609 IconEditorGrid.FilledCircle) |
596 self.drawFilledCircleAct.triggered[()].connect(self.esm.map) |
610 self.drawFilledCircleAct.triggered[()].connect(self.esm.map) |
597 self.__actions.append(self.drawFilledCircleAct) |
611 self.__actions.append(self.drawFilledCircleAct) |
598 |
612 |
599 self.drawEllipseAct = E5Action(self.trUtf8('Ellipse'), |
613 self.drawEllipseAct = E5Action(self.trUtf8('Ellipse'), |
600 UI.PixmapCache.getIcon("drawEllipse.png"), |
614 UI.PixmapCache.getIcon("drawEllipse.png"), |
618 self.drawFilledEllipseAct.setWhatsThis(self.trUtf8( |
632 self.drawFilledEllipseAct.setWhatsThis(self.trUtf8( |
619 """<b>Filled Ellipse</b>""" |
633 """<b>Filled Ellipse</b>""" |
620 """<p>Draw a filled ellipse.</p>""" |
634 """<p>Draw a filled ellipse.</p>""" |
621 )) |
635 )) |
622 self.drawFilledEllipseAct.setCheckable(True) |
636 self.drawFilledEllipseAct.setCheckable(True) |
623 self.esm.setMapping(self.drawFilledEllipseAct, IconEditorGrid.FilledEllipse) |
637 self.esm.setMapping(self.drawFilledEllipseAct, |
|
638 IconEditorGrid.FilledEllipse) |
624 self.drawFilledEllipseAct.triggered[()].connect(self.esm.map) |
639 self.drawFilledEllipseAct.triggered[()].connect(self.esm.map) |
625 self.__actions.append(self.drawFilledEllipseAct) |
640 self.__actions.append(self.drawFilledEllipseAct) |
626 |
641 |
627 self.drawFloodFillAct = E5Action(self.trUtf8('Flood Fill'), |
642 self.drawFloodFillAct = E5Action(self.trUtf8('Flood Fill'), |
628 UI.PixmapCache.getIcon("drawFill.png"), |
643 UI.PixmapCache.getIcon("drawFill.png"), |
665 self.drawEraserAct.setCheckable(True) |
680 self.drawEraserAct.setCheckable(True) |
666 self.esm.setMapping(self.drawEraserAct, IconEditorGrid.Rubber) |
681 self.esm.setMapping(self.drawEraserAct, IconEditorGrid.Rubber) |
667 self.drawEraserAct.triggered[()].connect(self.esm.map) |
682 self.drawEraserAct.triggered[()].connect(self.esm.map) |
668 self.__actions.append(self.drawEraserAct) |
683 self.__actions.append(self.drawEraserAct) |
669 |
684 |
670 self.drawRectangleSelectionAct = E5Action(self.trUtf8('Rectangular Selection'), |
685 self.drawRectangleSelectionAct = E5Action( |
|
686 self.trUtf8('Rectangular Selection'), |
671 UI.PixmapCache.getIcon("selectRectangle.png"), |
687 UI.PixmapCache.getIcon("selectRectangle.png"), |
672 self.trUtf8('Rect&angular Selection'), |
688 self.trUtf8('Rect&angular Selection'), |
673 0, 0, |
689 0, 0, |
674 self.drawingActGrp, 'iconEditor_tools_selection_rectangle') |
690 self.drawingActGrp, 'iconEditor_tools_selection_rectangle') |
675 self.drawRectangleSelectionAct.setWhatsThis(self.trUtf8( |
691 self.drawRectangleSelectionAct.setWhatsThis(self.trUtf8( |
676 """<b>Rectangular Selection</b>""" |
692 """<b>Rectangular Selection</b>""" |
677 """<p>Select a rectangular section of the icon using the mouse.</p>""" |
693 """<p>Select a rectangular section of the icon using""" |
|
694 """ the mouse.</p>""" |
678 )) |
695 )) |
679 self.drawRectangleSelectionAct.setCheckable(True) |
696 self.drawRectangleSelectionAct.setCheckable(True) |
680 self.esm.setMapping(self.drawRectangleSelectionAct, |
697 self.esm.setMapping(self.drawRectangleSelectionAct, |
681 IconEditorGrid.RectangleSelection) |
698 IconEditorGrid.RectangleSelection) |
682 self.drawRectangleSelectionAct.triggered[()].connect(self.esm.map) |
699 self.drawRectangleSelectionAct.triggered[()].connect(self.esm.map) |
683 self.__actions.append(self.drawRectangleSelectionAct) |
700 self.__actions.append(self.drawRectangleSelectionAct) |
684 |
701 |
685 self.drawCircleSelectionAct = E5Action(self.trUtf8('Circular Selection'), |
702 self.drawCircleSelectionAct = E5Action( |
|
703 self.trUtf8('Circular Selection'), |
686 UI.PixmapCache.getIcon("selectCircle.png"), |
704 UI.PixmapCache.getIcon("selectCircle.png"), |
687 self.trUtf8('Rect&angular Selection'), |
705 self.trUtf8('Rect&angular Selection'), |
688 0, 0, |
706 0, 0, |
689 self.drawingActGrp, 'iconEditor_tools_selection_circle') |
707 self.drawingActGrp, 'iconEditor_tools_selection_circle') |
690 self.drawCircleSelectionAct.setWhatsThis(self.trUtf8( |
708 self.drawCircleSelectionAct.setWhatsThis(self.trUtf8( |
691 """<b>Circular Selection</b>""" |
709 """<b>Circular Selection</b>""" |
692 """<p>Select a circular section of the icon using the mouse.</p>""" |
710 """<p>Select a circular section of the icon using""" |
|
711 """ the mouse.</p>""" |
693 )) |
712 )) |
694 self.drawCircleSelectionAct.setCheckable(True) |
713 self.drawCircleSelectionAct.setCheckable(True) |
695 self.esm.setMapping(self.drawCircleSelectionAct, |
714 self.esm.setMapping(self.drawCircleSelectionAct, |
696 IconEditorGrid.CircleSelection) |
715 IconEditorGrid.CircleSelection) |
697 self.drawCircleSelectionAct.triggered[()].connect(self.esm.map) |
716 self.drawCircleSelectionAct.triggered[()].connect(self.esm.map) |
704 Private method to create the Help actions. |
723 Private method to create the Help actions. |
705 """ |
724 """ |
706 self.aboutAct = E5Action(self.trUtf8('About'), |
725 self.aboutAct = E5Action(self.trUtf8('About'), |
707 self.trUtf8('&About'), |
726 self.trUtf8('&About'), |
708 0, 0, self, 'iconEditor_help_about') |
727 0, 0, self, 'iconEditor_help_about') |
709 self.aboutAct.setStatusTip(self.trUtf8('Display information about this software')) |
728 self.aboutAct.setStatusTip(self.trUtf8( |
|
729 'Display information about this software')) |
710 self.aboutAct.setWhatsThis(self.trUtf8( |
730 self.aboutAct.setWhatsThis(self.trUtf8( |
711 """<b>About</b>""" |
731 """<b>About</b>""" |
712 """<p>Display some information about this software.</p>""")) |
732 """<p>Display some information about this software.</p>""")) |
713 self.aboutAct.triggered[()].connect(self.__about) |
733 self.aboutAct.triggered[()].connect(self.__about) |
714 self.__actions.append(self.aboutAct) |
734 self.__actions.append(self.aboutAct) |
730 self.trUtf8('&What\'s This?'), |
750 self.trUtf8('&What\'s This?'), |
731 QKeySequence(self.trUtf8("Shift+F1", "Help|What's This?'")), |
751 QKeySequence(self.trUtf8("Shift+F1", "Help|What's This?'")), |
732 0, self, 'iconEditor_help_whats_this') |
752 0, self, 'iconEditor_help_whats_this') |
733 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help')) |
753 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help')) |
734 self.whatsThisAct.setWhatsThis(self.trUtf8( |
754 self.whatsThisAct.setWhatsThis(self.trUtf8( |
735 """<b>Display context sensitive help</b>""" |
755 """<b>Display context sensitive help</b>""" |
736 """<p>In What's This? mode, the mouse cursor shows an arrow with a""" |
756 """<p>In What's This? mode, the mouse cursor shows an arrow""" |
737 """ question mark, and you can click on the interface elements to get""" |
757 """ with a question mark, and you can click on the interface""" |
738 """ a short description of what they do and how to use them. In""" |
758 """ elements to get a short description of what they do and""" |
739 """ dialogs, this feature can be accessed using the context help button""" |
759 """ how to use them. In dialogs, this feature can be accessed""" |
740 """ in the titlebar.</p>""" |
760 """ using the context help button in the titlebar.</p>""" |
741 )) |
761 )) |
742 self.whatsThisAct.triggered[()].connect(self.__whatsThis) |
762 self.whatsThisAct.triggered[()].connect(self.__whatsThis) |
743 self.__actions.append(self.whatsThisAct) |
763 self.__actions.append(self.whatsThisAct) |
744 |
764 |
745 def __initMenus(self): |
765 def __initMenus(self): |
886 self.__updateSize(*self.__editor.iconSize()) |
906 self.__updateSize(*self.__editor.iconSize()) |
887 |
907 |
888 self.__sbPos = QLabel(self.__statusBar) |
908 self.__sbPos = QLabel(self.__statusBar) |
889 self.__statusBar.addPermanentWidget(self.__sbPos) |
909 self.__statusBar.addPermanentWidget(self.__sbPos) |
890 self.__sbPos.setWhatsThis(self.trUtf8( |
910 self.__sbPos.setWhatsThis(self.trUtf8( |
891 """<p>This part of the status bar displays the cursor position.</p>""" |
911 """<p>This part of the status bar displays the cursor""" |
|
912 """ position.</p>""" |
892 )) |
913 )) |
893 self.__updatePosition(0, 0) |
914 self.__updatePosition(0, 0) |
894 |
915 |
895 self.__zoomWidget = E5ZoomWidget(UI.PixmapCache.getPixmap("zoomOut.png"), |
916 self.__zoomWidget = E5ZoomWidget( |
|
917 UI.PixmapCache.getPixmap("zoomOut.png"), |
896 UI.PixmapCache.getPixmap("zoomIn.png"), |
918 UI.PixmapCache.getPixmap("zoomIn.png"), |
897 UI.PixmapCache.getPixmap("zoomReset.png"), self) |
919 UI.PixmapCache.getPixmap("zoomReset.png"), self) |
898 self.__zoomWidget.setMinimum(IconEditorGrid.ZoomMinimum) |
920 self.__zoomWidget.setMinimum(IconEditorGrid.ZoomMinimum) |
899 self.__zoomWidget.setMaximum(IconEditorGrid.ZoomMaximum) |
921 self.__zoomWidget.setMaximum(IconEditorGrid.ZoomMaximum) |
900 self.__zoomWidget.setDefault(IconEditorGrid.ZoomDefault) |
922 self.__zoomWidget.setDefault(IconEditorGrid.ZoomDefault) |
992 self.__checkActions() |
1015 self.__checkActions() |
993 |
1016 |
994 def __saveIcon(self): |
1017 def __saveIcon(self): |
995 """ |
1018 """ |
996 Private slot to save the icon. |
1019 Private slot to save the icon. |
|
1020 |
|
1021 @return flag indicating success (boolean) |
997 """ |
1022 """ |
998 if not self.__fileName: |
1023 if not self.__fileName: |
999 return self.__saveIconAs() |
1024 return self.__saveIconAs() |
1000 else: |
1025 else: |
1001 return self.__saveIconFile(self.__fileName) |
1026 return self.__saveIconFile(self.__fileName) |
1002 |
1027 |
1003 def __saveIconAs(self): |
1028 def __saveIconAs(self): |
1004 """ |
1029 """ |
1005 Private slot to save the icon with a new name. |
1030 Private slot to save the icon with a new name. |
|
1031 |
|
1032 @return flag indicating success (boolean) |
1006 """ |
1033 """ |
1007 if not self.__lastSavePath: |
1034 if not self.__lastSavePath: |
1008 if self.__project and self.__project.isOpen(): |
1035 if self.__project and self.__project.isOpen(): |
1009 self.__lastSavePath = self.__project.getProjectPath() |
1036 self.__lastSavePath = self.__project.getProjectPath() |
1010 if not self.__lastSavePath and self.__lastOpenPath: |
1037 if not self.__lastSavePath and self.__lastOpenPath: |
1053 |
1080 |
1054 @param fileName name of the icon file to load (string). |
1081 @param fileName name of the icon file to load (string). |
1055 """ |
1082 """ |
1056 file = QFile(fileName) |
1083 file = QFile(fileName) |
1057 if not file.exists(): |
1084 if not file.exists(): |
1058 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), |
1085 E5MessageBox.warning( |
1059 self.trUtf8("The file '{0}' does not exist.")\ |
1086 self, self.trUtf8("eric5 Icon Editor"), |
1060 .format(fileName)) |
1087 self.trUtf8("The file '{0}' does not exist.") |
|
1088 .format(fileName)) |
1061 return |
1089 return |
1062 |
1090 |
1063 if not file.open(QFile.ReadOnly): |
1091 if not file.open(QFile.ReadOnly): |
1064 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), |
1092 E5MessageBox.warning( |
1065 self.trUtf8("Cannot read file '{0}:\n{1}.")\ |
1093 self, self.trUtf8("eric5 Icon Editor"), |
1066 .format(fileName, file.errorString())) |
1094 self.trUtf8("Cannot read file '{0}:\n{1}.") |
|
1095 .format(fileName, file.errorString())) |
1067 return |
1096 return |
1068 file.close() |
1097 file.close() |
1069 |
1098 |
1070 img = QImage(fileName) |
1099 img = QImage(fileName) |
1071 self.__editor.setIconImage(img, clearUndo=True) |
1100 self.__editor.setIconImage(img, clearUndo=True) |
1078 @param fileName name of the file to save to (string) |
1107 @param fileName name of the file to save to (string) |
1079 @return flag indicating success (boolean) |
1108 @return flag indicating success (boolean) |
1080 """ |
1109 """ |
1081 file = QFile(fileName) |
1110 file = QFile(fileName) |
1082 if not file.open(QFile.WriteOnly): |
1111 if not file.open(QFile.WriteOnly): |
1083 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), |
1112 E5MessageBox.warning( |
1084 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
1113 self, self.trUtf8("eric5 Icon Editor"), |
1085 .format(fileName, file.errorString())) |
1114 self.trUtf8("Cannot write file '{0}:\n{1}.") |
|
1115 .format(fileName, file.errorString())) |
1086 |
1116 |
1087 self.__checkActions() |
1117 self.__checkActions() |
1088 |
1118 |
1089 return False |
1119 return False |
1090 |
1120 |
1091 img = self.__editor.iconImage() |
1121 img = self.__editor.iconImage() |
1092 res = img.save(file) |
1122 res = img.save(file) |
1093 file.close() |
1123 file.close() |
1094 |
1124 |
1095 if not res: |
1125 if not res: |
1096 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), |
1126 E5MessageBox.warning( |
1097 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
1127 self, self.trUtf8("eric5 Icon Editor"), |
1098 .format(fileName, file.errorString())) |
1128 self.trUtf8("Cannot write file '{0}:\n{1}.") |
|
1129 .format(fileName, file.errorString())) |
1099 |
1130 |
1100 self.__checkActions() |
1131 self.__checkActions() |
1101 |
1132 |
1102 return False |
1133 return False |
1103 |
1134 |
1121 if not self.__fileName: |
1152 if not self.__fileName: |
1122 shownName = self.trUtf8("Untitled") |
1153 shownName = self.trUtf8("Untitled") |
1123 else: |
1154 else: |
1124 shownName = self.__strippedName(self.__fileName) |
1155 shownName = self.__strippedName(self.__fileName) |
1125 |
1156 |
1126 self.setWindowTitle(self.trUtf8("{0}[*] - {1}")\ |
1157 self.setWindowTitle(self.trUtf8("{0}[*] - {1}") |
1127 .format(shownName, self.trUtf8("Icon Editor"))) |
1158 .format(shownName, self.trUtf8("Icon Editor"))) |
1128 |
1159 |
1129 self.setWindowModified(self.__editor.isDirty()) |
1160 self.setWindowModified(self.__editor.isDirty()) |
1130 |
1161 |
1131 def __strippedName(self, fullFileName): |
1162 def __strippedName(self, fullFileName): |
1208 |
1239 |
1209 def __zoomIn(self): |
1240 def __zoomIn(self): |
1210 """ |
1241 """ |
1211 Private slot called to handle the zoom in action. |
1242 Private slot called to handle the zoom in action. |
1212 """ |
1243 """ |
1213 self.__editor.setZoomFactor(self.__editor.zoomFactor() + IconEditorGrid.ZoomStep) |
1244 self.__editor.setZoomFactor( |
|
1245 self.__editor.zoomFactor() + IconEditorGrid.ZoomStep) |
1214 self.__updateZoom() |
1246 self.__updateZoom() |
1215 |
1247 |
1216 def __zoomOut(self): |
1248 def __zoomOut(self): |
1217 """ |
1249 """ |
1218 Private slot called to handle the zoom out action. |
1250 Private slot called to handle the zoom out action. |
1219 """ |
1251 """ |
1220 self.__editor.setZoomFactor(self.__editor.zoomFactor() - IconEditorGrid.ZoomStep) |
1252 self.__editor.setZoomFactor( |
|
1253 self.__editor.zoomFactor() - IconEditorGrid.ZoomStep) |
1221 self.__updateZoom() |
1254 self.__updateZoom() |
1222 |
1255 |
1223 def __zoomReset(self): |
1256 def __zoomReset(self): |
1224 """ |
1257 """ |
1225 Private slot called to handle the zoom reset action. |
1258 Private slot called to handle the zoom reset action. |