45 """ |
45 """ |
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 @param fromEric flag indicating whether it was called from within |
51 eric6 (boolean) |
51 eric (boolean) |
52 @keyparam initShortcutsOnly flag indicating to just initialize the |
52 @param 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 @param project reference to the project object (Project) |
55 """ |
55 """ |
56 super(IconEditorWindow, self).__init__(parent) |
56 super(IconEditorWindow, self).__init__(parent) |
57 self.setObjectName("eric6_icon_editor") |
57 self.setObjectName("eric6_icon_editor") |
58 |
58 |
59 self.fromEric = fromEric |
59 self.fromEric = fromEric |
1144 @param fileName name of the icon file to load (string). |
1144 @param fileName name of the icon file to load (string). |
1145 """ |
1145 """ |
1146 file = QFile(fileName) |
1146 file = QFile(fileName) |
1147 if not file.exists(): |
1147 if not file.exists(): |
1148 E5MessageBox.warning( |
1148 E5MessageBox.warning( |
1149 self, self.tr("eric6 Icon Editor"), |
1149 self, self.tr("eric Icon Editor"), |
1150 self.tr("The file '{0}' does not exist.") |
1150 self.tr("The file '{0}' does not exist.") |
1151 .format(fileName)) |
1151 .format(fileName)) |
1152 return |
1152 return |
1153 |
1153 |
1154 if not file.open(QFile.ReadOnly): |
1154 if not file.open(QFile.ReadOnly): |
1155 E5MessageBox.warning( |
1155 E5MessageBox.warning( |
1156 self, self.tr("eric6 Icon Editor"), |
1156 self, self.tr("eric Icon Editor"), |
1157 self.tr("Cannot read file '{0}:\n{1}.") |
1157 self.tr("Cannot read file '{0}:\n{1}.") |
1158 .format(fileName, file.errorString())) |
1158 .format(fileName, file.errorString())) |
1159 return |
1159 return |
1160 file.close() |
1160 file.close() |
1161 |
1161 |
1171 @return flag indicating success (boolean) |
1171 @return flag indicating success (boolean) |
1172 """ |
1172 """ |
1173 file = QFile(fileName) |
1173 file = QFile(fileName) |
1174 if not file.open(QFile.WriteOnly): |
1174 if not file.open(QFile.WriteOnly): |
1175 E5MessageBox.warning( |
1175 E5MessageBox.warning( |
1176 self, self.tr("eric6 Icon Editor"), |
1176 self, self.tr("eric Icon Editor"), |
1177 self.tr("Cannot write file '{0}:\n{1}.") |
1177 self.tr("Cannot write file '{0}:\n{1}.") |
1178 .format(fileName, file.errorString())) |
1178 .format(fileName, file.errorString())) |
1179 |
1179 |
1180 self.__checkActions() |
1180 self.__checkActions() |
1181 |
1181 |
1185 res = img.save(file) |
1185 res = img.save(file) |
1186 file.close() |
1186 file.close() |
1187 |
1187 |
1188 if not res: |
1188 if not res: |
1189 E5MessageBox.warning( |
1189 E5MessageBox.warning( |
1190 self, self.tr("eric6 Icon Editor"), |
1190 self, self.tr("eric Icon Editor"), |
1191 self.tr("Cannot write file '{0}:\n{1}.") |
1191 self.tr("Cannot write file '{0}:\n{1}.") |
1192 .format(fileName, file.errorString())) |
1192 .format(fileName, file.errorString())) |
1193 |
1193 |
1194 self.__checkActions() |
1194 self.__checkActions() |
1195 |
1195 |
1238 @return flag indicating, if it is ok to continue (boolean) |
1238 @return flag indicating, if it is ok to continue (boolean) |
1239 """ |
1239 """ |
1240 if self.__editor.isDirty(): |
1240 if self.__editor.isDirty(): |
1241 ret = E5MessageBox.okToClearData( |
1241 ret = E5MessageBox.okToClearData( |
1242 self, |
1242 self, |
1243 self.tr("eric6 Icon Editor"), |
1243 self.tr("eric Icon Editor"), |
1244 self.tr("""The icon image has unsaved changes."""), |
1244 self.tr("""The icon image has unsaved changes."""), |
1245 self.__saveIcon) |
1245 self.__saveIcon) |
1246 if not ret: |
1246 if not ret: |
1247 return False |
1247 return False |
1248 return True |
1248 return True |
1327 def __about(self): |
1327 def __about(self): |
1328 """ |
1328 """ |
1329 Private slot to show a little About message. |
1329 Private slot to show a little About message. |
1330 """ |
1330 """ |
1331 E5MessageBox.about( |
1331 E5MessageBox.about( |
1332 self, self.tr("About eric6 Icon Editor"), |
1332 self, self.tr("About eric Icon Editor"), |
1333 self.tr("The eric6 Icon Editor is a simple editor component" |
1333 self.tr("The eric Icon Editor is a simple editor component" |
1334 " to perform icon drawing tasks.")) |
1334 " to perform icon drawing tasks.")) |
1335 |
1335 |
1336 def __aboutQt(self): |
1336 def __aboutQt(self): |
1337 """ |
1337 """ |
1338 Private slot to handle the About Qt dialog. |
1338 Private slot to handle the About Qt dialog. |
1339 """ |
1339 """ |
1340 E5MessageBox.aboutQt(self, "eric6 Icon Editor") |
1340 E5MessageBox.aboutQt(self, "eric Icon Editor") |
1341 |
1341 |
1342 def __whatsThis(self): |
1342 def __whatsThis(self): |
1343 """ |
1343 """ |
1344 Private slot called in to enter Whats This mode. |
1344 Private slot called in to enter Whats This mode. |
1345 """ |
1345 """ |