25 """ |
25 """ |
26 Class implementing the web browser main window. |
26 Class implementing the web browser main window. |
27 |
27 |
28 @signal editorClosed() emitted after the window was requested to close down |
28 @signal editorClosed() emitted after the window was requested to close down |
29 """ |
29 """ |
|
30 editorClosed = pyqtSignal() |
|
31 |
30 windows = [] |
32 windows = [] |
31 |
33 |
32 def __init__(self, fileName = "", parent = None, fromEric = False, |
34 def __init__(self, fileName = "", parent = None, fromEric = False, |
33 initShortcutsOnly = False): |
35 initShortcutsOnly = False): |
34 """ |
36 """ |
35 Constructor |
37 Constructor |
36 |
38 |
37 @param fileName name of a file to load on startup (string) |
39 @param fileName name of a file to load on startup (string) |
38 @param parent parent widget of this window (QWidget) |
40 @param parent parent widget of this window (QWidget) |
39 @keyparam fromEric flag indicating whether it was called from within eric5 (boolean) |
41 @keyparam fromEric flag indicating whether it was called from within |
|
42 eric5 (boolean) |
40 @keyparam initShortcutsOnly flag indicating to just initialize the keyboard |
43 @keyparam initShortcutsOnly flag indicating to just initialize the keyboard |
41 shortcuts (boolean) |
44 shortcuts (boolean) |
42 """ |
45 """ |
43 QMainWindow.__init__(self, parent) |
46 QMainWindow.__init__(self, parent) |
44 self.setObjectName("eric5_icon_editor") |
47 self.setObjectName("eric5_icon_editor") |
78 self.__class__.windows.append(self) |
81 self.__class__.windows.append(self) |
79 |
82 |
80 state = Preferences.getIconEditor("IconEditorState") |
83 state = Preferences.getIconEditor("IconEditorState") |
81 self.restoreState(state) |
84 self.restoreState(state) |
82 |
85 |
83 self.connect(self.__editor, SIGNAL("imageChanged(bool)"), |
86 self.__editor.imageChanged.connect(self.__modificationChanged) |
84 self.__modificationChanged) |
87 self.__editor.positionChanged.connect(self.__updatePosition) |
85 self.connect(self.__editor, SIGNAL("positionChanged(int, int)"), |
88 self.__editor.sizeChanged.connect(self.__updateSize) |
86 self.__updatePosition) |
89 self.__editor.previewChanged.connect(self.__palette.previewChanged) |
87 self.connect(self.__editor, SIGNAL("sizeChanged(int, int)"), |
90 self.__editor.colorChanged.connect(self.__palette.colorChanged) |
88 self.__updateSize) |
91 self.__palette.colorSelected.connect(self.__editor.setPenColor) |
89 self.connect(self.__editor, SIGNAL("previewChanged(const QPixmap&)"), |
|
90 self.__palette.previewChanged) |
|
91 self.connect(self.__editor, SIGNAL("colorChanged(const QColor&)"), |
|
92 self.__palette.colorChanged) |
|
93 self.connect(self.__palette, SIGNAL("colorSelected(QColor)"), |
|
94 self.__editor.setPenColor) |
|
95 |
92 |
96 self.__setCurrentFile("") |
93 self.__setCurrentFile("") |
97 if fileName: |
94 if fileName: |
98 self.__loadIconFile(fileName) |
95 self.__loadIconFile(fileName) |
99 |
96 |
405 )) |
402 )) |
406 self.grayscaleAct.triggered[()].connect(self.__editor.grayScale) |
403 self.grayscaleAct.triggered[()].connect(self.__editor.grayScale) |
407 self.__actions.append(self.grayscaleAct) |
404 self.__actions.append(self.grayscaleAct) |
408 |
405 |
409 self.redoAct.setEnabled(False) |
406 self.redoAct.setEnabled(False) |
410 self.connect(self.__editor, SIGNAL("canRedoChanged(bool)"), |
407 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled) |
411 self.redoAct, SLOT("setEnabled(bool)")) |
|
412 |
408 |
413 self.undoAct.setEnabled(False) |
409 self.undoAct.setEnabled(False) |
414 self.connect(self.__editor, SIGNAL("canUndoChanged(bool)"), |
410 self.__editor.canUndoChanged.connect(self.undoAct.setEnabled) |
415 self.undoAct, SLOT("setEnabled(bool)")) |
|
416 |
411 |
417 self.cutAct.setEnabled(False) |
412 self.cutAct.setEnabled(False) |
418 self.copyAct.setEnabled(False) |
413 self.copyAct.setEnabled(False) |
419 self.connect(self.__editor, SIGNAL("selectionAvailable(bool)"), |
414 self.__editor.selectionAvailable.connect(self.cutAct.setEnabled) |
420 self.cutAct, SLOT("setEnabled(bool)")) |
415 self.__editor.selectionAvailable.connect(self.copyAct.setEnabled) |
421 self.connect(self.__editor, SIGNAL("selectionAvailable(bool)"), |
|
422 self.copyAct, SLOT("setEnabled(bool)")) |
|
423 |
416 |
424 self.pasteAct.setEnabled(self.__editor.canPaste()) |
417 self.pasteAct.setEnabled(self.__editor.canPaste()) |
425 self.pasteNewAct.setEnabled(self.__editor.canPaste()) |
418 self.pasteNewAct.setEnabled(self.__editor.canPaste()) |
426 self.connect(self.__editor, SIGNAL("clipboardImageAvailable(bool)"), |
419 self.__editor.clipboardImageAvailable.connect( |
427 self.pasteAct, SLOT("setEnabled(bool)")) |
420 self.pasteAct.setEnabled) |
428 self.connect(self.__editor, SIGNAL("clipboardImageAvailable(bool)"), |
421 self.__editor.clipboardImageAvailable.connect( |
429 self.pasteNewAct, SLOT("setEnabled(bool)")) |
422 self.pasteNewAct.setEnabled) |
430 |
423 |
431 def __initViewActions(self): |
424 def __initViewActions(self): |
432 """ |
425 """ |
433 Private method to create the View actions. |
426 Private method to create the View actions. |
434 """ |
427 """ |
495 self.showGridAct.setStatusTip(self.trUtf8('Toggle the display of the grid')) |
488 self.showGridAct.setStatusTip(self.trUtf8('Toggle the display of the grid')) |
496 self.showGridAct.setWhatsThis(self.trUtf8( |
489 self.showGridAct.setWhatsThis(self.trUtf8( |
497 """<b>Show Grid</b>""" |
490 """<b>Show Grid</b>""" |
498 """<p>Toggle the display of the grid.</p>""" |
491 """<p>Toggle the display of the grid.</p>""" |
499 )) |
492 )) |
500 self.connect(self.showGridAct, SIGNAL('triggered(bool)'), |
493 self.showGridAct.triggered[bool].connect(self.__editor.setGridEnabled) |
501 self.__editor.setGridEnabled) |
|
502 self.__actions.append(self.showGridAct) |
494 self.__actions.append(self.showGridAct) |
503 self.showGridAct.setCheckable(True) |
495 self.showGridAct.setCheckable(True) |
504 self.showGridAct.setChecked(self.__editor.isGridEnabled()) |
496 self.showGridAct.setChecked(self.__editor.isGridEnabled()) |
505 |
497 |
506 def __initToolsActions(self): |
498 def __initToolsActions(self): |
507 """ |
499 """ |
508 Private method to create the View actions. |
500 Private method to create the View actions. |
509 """ |
501 """ |
510 self.esm = QSignalMapper(self) |
502 self.esm = QSignalMapper(self) |
511 self.connect(self.esm, SIGNAL('mapped(int)'), self.__editor.setTool) |
503 self.esm.mapped[int].connect(self.__editor.setTool) |
512 |
504 |
513 self.drawingActGrp = createActionGroup(self) |
505 self.drawingActGrp = createActionGroup(self) |
514 self.drawingActGrp.setExclusive(True) |
506 self.drawingActGrp.setExclusive(True) |
515 |
507 |
516 self.drawPencilAct = E5Action(self.trUtf8('Freehand'), |
508 self.drawPencilAct = E5Action(self.trUtf8('Freehand'), |