IconEditor/IconEditorWindow.py

changeset 15
f6ccc31d6e72
parent 13
1af94a91f439
child 42
23b45a742e17
equal deleted inserted replaced
14:092aa8fafa4e 15:f6ccc31d6e72
19 import UI.PixmapCache 19 import UI.PixmapCache
20 import UI.Config 20 import UI.Config
21 21
22 import Preferences 22 import Preferences
23 23
24 from eric4config import getConfig 24 from eric5config import getConfig
25 25
26 class IconEditorWindow(QMainWindow): 26 class IconEditorWindow(QMainWindow):
27 """ 27 """
28 Class implementing the web browser main window. 28 Class implementing the web browser main window.
29 29
36 """ 36 """
37 Constructor 37 Constructor
38 38
39 @param fileName name of a file to load on startup (string) 39 @param fileName name of a file to load on startup (string)
40 @param parent parent widget of this window (QWidget) 40 @param parent parent widget of this window (QWidget)
41 @keyparam fromEric flag indicating whether it was called from within eric4 (boolean) 41 @keyparam fromEric flag indicating whether it was called from within eric5 (boolean)
42 @keyparam initShortcutsOnly flag indicating to just initialize the keyboard 42 @keyparam initShortcutsOnly flag indicating to just initialize the keyboard
43 shortcuts (boolean) 43 shortcuts (boolean)
44 """ 44 """
45 QMainWindow.__init__(self, parent) 45 QMainWindow.__init__(self, parent)
46 self.setObjectName("eric4_icon_editor") 46 self.setObjectName("eric5_icon_editor")
47 self.setAttribute(Qt.WA_DeleteOnClose) 47 self.setAttribute(Qt.WA_DeleteOnClose)
48 48
49 self.fromEric = fromEric 49 self.fromEric = fromEric
50 self.initShortcutsOnly = initShortcutsOnly 50 self.initShortcutsOnly = initShortcutsOnly
51 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png")) 51 self.setWindowIcon(UI.PixmapCache.getIcon("iconEditor.png"))
1051 1051
1052 @param fileName name of the icon file to load (string). 1052 @param fileName name of the icon file to load (string).
1053 """ 1053 """
1054 file= QFile(fileName) 1054 file= QFile(fileName)
1055 if not file.exists(): 1055 if not file.exists():
1056 QMessageBox.warning(self, self.trUtf8("eric4 Icon Editor"), 1056 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1057 self.trUtf8("The file '{0}' does not exist.")\ 1057 self.trUtf8("The file '{0}' does not exist.")\
1058 .format(fileName)) 1058 .format(fileName))
1059 return 1059 return
1060 1060
1061 if not file.open(QFile.ReadOnly): 1061 if not file.open(QFile.ReadOnly):
1062 QMessageBox.warning(self, self.trUtf8("eric4 Icon Editor"), 1062 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1063 self.trUtf8("Cannot read file '{0}:\n{1}.")\ 1063 self.trUtf8("Cannot read file '{0}:\n{1}.")\
1064 .format(fileName, file.errorString())) 1064 .format(fileName, file.errorString()))
1065 return 1065 return
1066 file.close() 1066 file.close()
1067 1067
1076 @param fileName name of the file to save to (string) 1076 @param fileName name of the file to save to (string)
1077 @return flag indicating success (boolean) 1077 @return flag indicating success (boolean)
1078 """ 1078 """
1079 file = QFile(fileName) 1079 file = QFile(fileName)
1080 if not file.open(QFile.WriteOnly): 1080 if not file.open(QFile.WriteOnly):
1081 QMessageBox.warning(self, self.trUtf8("eric4 Icon Editor"), 1081 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1082 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 1082 self.trUtf8("Cannot write file '{0}:\n{1}.")\
1083 .format(fileName, file.errorString())) 1083 .format(fileName, file.errorString()))
1084 1084
1085 self.__checkActions() 1085 self.__checkActions()
1086 1086
1089 img = self.__editor.iconImage() 1089 img = self.__editor.iconImage()
1090 res = img.save(file) 1090 res = img.save(file)
1091 file.close() 1091 file.close()
1092 1092
1093 if not res: 1093 if not res:
1094 QMessageBox.warning(self, self.trUtf8("eric4 Icon Editor"), 1094 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1095 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 1095 self.trUtf8("Cannot write file '{0}:\n{1}.")\
1096 .format(fileName, file.errorString())) 1096 .format(fileName, file.errorString()))
1097 1097
1098 self.__checkActions() 1098 self.__checkActions()
1099 1099
1141 1141
1142 @return flag indicating, if it is ok to continue (boolean) 1142 @return flag indicating, if it is ok to continue (boolean)
1143 """ 1143 """
1144 if self.__editor.isDirty(): 1144 if self.__editor.isDirty():
1145 ret = QMessageBox.warning(self, 1145 ret = QMessageBox.warning(self,
1146 self.trUtf8("eric4 Icon Editor"), 1146 self.trUtf8("eric5 Icon Editor"),
1147 self.trUtf8("""The icon image has been modified.\n""" 1147 self.trUtf8("""The icon image has been modified.\n"""
1148 """Do you want to save your changes?"""), 1148 """Do you want to save your changes?"""),
1149 QMessageBox.StandardButtons(\ 1149 QMessageBox.StandardButtons(\
1150 QMessageBox.Cancel | \ 1150 QMessageBox.Cancel | \
1151 QMessageBox.No | \ 1151 QMessageBox.No | \
1230 1230
1231 def __about(self): 1231 def __about(self):
1232 """ 1232 """
1233 Private slot to show a little About message. 1233 Private slot to show a little About message.
1234 """ 1234 """
1235 QMessageBox.about(self, self.trUtf8("About eric4 Icon Editor"), 1235 QMessageBox.about(self, self.trUtf8("About eric5 Icon Editor"),
1236 self.trUtf8("The eric4 Icon Editor is a simple editor component" 1236 self.trUtf8("The eric5 Icon Editor is a simple editor component"
1237 " to perform icon drawing tasks.")) 1237 " to perform icon drawing tasks."))
1238 1238
1239 def __aboutQt(self): 1239 def __aboutQt(self):
1240 """ 1240 """
1241 Private slot to handle the About Qt dialog. 1241 Private slot to handle the About Qt dialog.
1242 """ 1242 """
1243 QMessageBox.aboutQt(self, "eric4 Icon Editor") 1243 QMessageBox.aboutQt(self, "eric5 Icon Editor")
1244 1244
1245 def __whatsThis(self): 1245 def __whatsThis(self):
1246 """ 1246 """
1247 Private slot called in to enter Whats This mode. 1247 Private slot called in to enter Whats This mode.
1248 """ 1248 """

eric ide

mercurial