46 Constructor |
46 Constructor |
47 |
47 |
48 @param fileName name of a file to load on startup (string) |
48 @param fileName name of a file to load on startup (string) |
49 @param parent parent widget of this window (QWidget) |
49 @param parent parent widget of this window (QWidget) |
50 @keyparam fromEric flag indicating whether it was called from within |
50 @keyparam fromEric flag indicating whether it was called from within |
51 eric5 (boolean) |
51 eric6 (boolean) |
52 @keyparam initShortcutsOnly flag indicating to just initialize the |
52 @keyparam initShortcutsOnly flag indicating to just initialize the |
53 keyboard shortcuts (boolean) |
53 keyboard shortcuts (boolean) |
54 @keyparam project reference to the project object (Project) |
54 @keyparam project reference to the project object (Project) |
55 """ |
55 """ |
56 super(IconEditorWindow, self).__init__(parent) |
56 super(IconEditorWindow, self).__init__(parent) |
57 self.setObjectName("eric5_icon_editor") |
57 self.setObjectName("eric6_icon_editor") |
58 |
58 |
59 self.fromEric = fromEric |
59 self.fromEric = fromEric |
60 self.initShortcutsOnly = initShortcutsOnly |
60 self.initShortcutsOnly = initShortcutsOnly |
61 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png")) |
61 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png")) |
62 |
62 |
1119 @param fileName name of the icon file to load (string). |
1119 @param fileName name of the icon file to load (string). |
1120 """ |
1120 """ |
1121 file = QFile(fileName) |
1121 file = QFile(fileName) |
1122 if not file.exists(): |
1122 if not file.exists(): |
1123 E5MessageBox.warning( |
1123 E5MessageBox.warning( |
1124 self, self.tr("eric5 Icon Editor"), |
1124 self, self.tr("eric6 Icon Editor"), |
1125 self.tr("The file '{0}' does not exist.") |
1125 self.tr("The file '{0}' does not exist.") |
1126 .format(fileName)) |
1126 .format(fileName)) |
1127 return |
1127 return |
1128 |
1128 |
1129 if not file.open(QFile.ReadOnly): |
1129 if not file.open(QFile.ReadOnly): |
1130 E5MessageBox.warning( |
1130 E5MessageBox.warning( |
1131 self, self.tr("eric5 Icon Editor"), |
1131 self, self.tr("eric6 Icon Editor"), |
1132 self.tr("Cannot read file '{0}:\n{1}.") |
1132 self.tr("Cannot read file '{0}:\n{1}.") |
1133 .format(fileName, file.errorString())) |
1133 .format(fileName, file.errorString())) |
1134 return |
1134 return |
1135 file.close() |
1135 file.close() |
1136 |
1136 |
1146 @return flag indicating success (boolean) |
1146 @return flag indicating success (boolean) |
1147 """ |
1147 """ |
1148 file = QFile(fileName) |
1148 file = QFile(fileName) |
1149 if not file.open(QFile.WriteOnly): |
1149 if not file.open(QFile.WriteOnly): |
1150 E5MessageBox.warning( |
1150 E5MessageBox.warning( |
1151 self, self.tr("eric5 Icon Editor"), |
1151 self, self.tr("eric6 Icon Editor"), |
1152 self.tr("Cannot write file '{0}:\n{1}.") |
1152 self.tr("Cannot write file '{0}:\n{1}.") |
1153 .format(fileName, file.errorString())) |
1153 .format(fileName, file.errorString())) |
1154 |
1154 |
1155 self.__checkActions() |
1155 self.__checkActions() |
1156 |
1156 |
1160 res = img.save(file) |
1160 res = img.save(file) |
1161 file.close() |
1161 file.close() |
1162 |
1162 |
1163 if not res: |
1163 if not res: |
1164 E5MessageBox.warning( |
1164 E5MessageBox.warning( |
1165 self, self.tr("eric5 Icon Editor"), |
1165 self, self.tr("eric6 Icon Editor"), |
1166 self.tr("Cannot write file '{0}:\n{1}.") |
1166 self.tr("Cannot write file '{0}:\n{1}.") |
1167 .format(fileName, file.errorString())) |
1167 .format(fileName, file.errorString())) |
1168 |
1168 |
1169 self.__checkActions() |
1169 self.__checkActions() |
1170 |
1170 |
1213 @return flag indicating, if it is ok to continue (boolean) |
1213 @return flag indicating, if it is ok to continue (boolean) |
1214 """ |
1214 """ |
1215 if self.__editor.isDirty(): |
1215 if self.__editor.isDirty(): |
1216 ret = E5MessageBox.okToClearData( |
1216 ret = E5MessageBox.okToClearData( |
1217 self, |
1217 self, |
1218 self.tr("eric5 Icon Editor"), |
1218 self.tr("eric6 Icon Editor"), |
1219 self.tr("""The icon image has unsaved changes."""), |
1219 self.tr("""The icon image has unsaved changes."""), |
1220 self.__saveIcon) |
1220 self.__saveIcon) |
1221 if not ret: |
1221 if not ret: |
1222 return False |
1222 return False |
1223 return True |
1223 return True |
1302 def __about(self): |
1302 def __about(self): |
1303 """ |
1303 """ |
1304 Private slot to show a little About message. |
1304 Private slot to show a little About message. |
1305 """ |
1305 """ |
1306 E5MessageBox.about( |
1306 E5MessageBox.about( |
1307 self, self.tr("About eric5 Icon Editor"), |
1307 self, self.tr("About eric6 Icon Editor"), |
1308 self.tr("The eric5 Icon Editor is a simple editor component" |
1308 self.tr("The eric6 Icon Editor is a simple editor component" |
1309 " to perform icon drawing tasks.")) |
1309 " to perform icon drawing tasks.")) |
1310 |
1310 |
1311 def __aboutQt(self): |
1311 def __aboutQt(self): |
1312 """ |
1312 """ |
1313 Private slot to handle the About Qt dialog. |
1313 Private slot to handle the About Qt dialog. |
1314 """ |
1314 """ |
1315 E5MessageBox.aboutQt(self, "eric5 Icon Editor") |
1315 E5MessageBox.aboutQt(self, "eric6 Icon Editor") |
1316 |
1316 |
1317 def __whatsThis(self): |
1317 def __whatsThis(self): |
1318 """ |
1318 """ |
1319 Private slot called in to enter Whats This mode. |
1319 Private slot called in to enter Whats This mode. |
1320 """ |
1320 """ |