IconEditor/IconEditorWindow.py

changeset 539
87f9bce38a44
parent 520
b0f523c3b037
child 545
1538031b5175
equal deleted inserted replaced
538:7f1a56e80124 539:87f9bce38a44
9 9
10 from PyQt4.QtCore import * 10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import * 11 from PyQt4.QtGui import *
12 12
13 from E5Gui.E5Action import E5Action, createActionGroup 13 from E5Gui.E5Action import E5Action, createActionGroup
14 from E5Gui import E5FileDialog 14 from E5Gui import E5FileDialog, E5MessageBox
15 15
16 from .IconEditorGrid import IconEditorGrid 16 from .IconEditorGrid import IconEditorGrid
17 from .IconZoomDialog import IconZoomDialog 17 from .IconZoomDialog import IconZoomDialog
18 from .IconEditorPalette import IconEditorPalette 18 from .IconEditorPalette import IconEditorPalette
19 19
999 if not ext: 999 if not ext:
1000 ex = selectedFilter.split("(*")[1].split(")")[0] 1000 ex = selectedFilter.split("(*")[1].split(")")[0]
1001 if ex: 1001 if ex:
1002 fileName += ex 1002 fileName += ex
1003 if QFileInfo(fileName).exists(): 1003 if QFileInfo(fileName).exists():
1004 res = QMessageBox.warning(self, 1004 res = E5MessageBox.warning(self,
1005 self.trUtf8("Save icon file"), 1005 self.trUtf8("Save icon file"),
1006 self.trUtf8("<p>The file <b>{0}</b> already exists.</p>") 1006 self.trUtf8("<p>The file <b>{0}</b> already exists.</p>")
1007 .format(fileName), 1007 .format(fileName),
1008 QMessageBox.StandardButtons(\ 1008 QMessageBox.StandardButtons(\
1009 QMessageBox.Abort | \ 1009 QMessageBox.Abort | \
1028 1028
1029 @param fileName name of the icon file to load (string). 1029 @param fileName name of the icon file to load (string).
1030 """ 1030 """
1031 file= QFile(fileName) 1031 file= QFile(fileName)
1032 if not file.exists(): 1032 if not file.exists():
1033 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), 1033 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1034 self.trUtf8("The file '{0}' does not exist.")\ 1034 self.trUtf8("The file '{0}' does not exist.")\
1035 .format(fileName)) 1035 .format(fileName))
1036 return 1036 return
1037 1037
1038 if not file.open(QFile.ReadOnly): 1038 if not file.open(QFile.ReadOnly):
1039 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), 1039 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1040 self.trUtf8("Cannot read file '{0}:\n{1}.")\ 1040 self.trUtf8("Cannot read file '{0}:\n{1}.")\
1041 .format(fileName, file.errorString())) 1041 .format(fileName, file.errorString()))
1042 return 1042 return
1043 file.close() 1043 file.close()
1044 1044
1053 @param fileName name of the file to save to (string) 1053 @param fileName name of the file to save to (string)
1054 @return flag indicating success (boolean) 1054 @return flag indicating success (boolean)
1055 """ 1055 """
1056 file = QFile(fileName) 1056 file = QFile(fileName)
1057 if not file.open(QFile.WriteOnly): 1057 if not file.open(QFile.WriteOnly):
1058 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), 1058 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1059 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 1059 self.trUtf8("Cannot write file '{0}:\n{1}.")\
1060 .format(fileName, file.errorString())) 1060 .format(fileName, file.errorString()))
1061 1061
1062 self.__checkActions() 1062 self.__checkActions()
1063 1063
1066 img = self.__editor.iconImage() 1066 img = self.__editor.iconImage()
1067 res = img.save(file) 1067 res = img.save(file)
1068 file.close() 1068 file.close()
1069 1069
1070 if not res: 1070 if not res:
1071 QMessageBox.warning(self, self.trUtf8("eric5 Icon Editor"), 1071 E5MessageBox.warning(self, self.trUtf8("eric5 Icon Editor"),
1072 self.trUtf8("Cannot write file '{0}:\n{1}.")\ 1072 self.trUtf8("Cannot write file '{0}:\n{1}.")\
1073 .format(fileName, file.errorString())) 1073 .format(fileName, file.errorString()))
1074 1074
1075 self.__checkActions() 1075 self.__checkActions()
1076 1076
1117 Private method to ask the user to save the file, if it was modified. 1117 Private method to ask the user to save the file, if it was modified.
1118 1118
1119 @return flag indicating, if it is ok to continue (boolean) 1119 @return flag indicating, if it is ok to continue (boolean)
1120 """ 1120 """
1121 if self.__editor.isDirty(): 1121 if self.__editor.isDirty():
1122 ret = QMessageBox.warning(self, 1122 ret = E5MessageBox.warning(self,
1123 self.trUtf8("eric5 Icon Editor"), 1123 self.trUtf8("eric5 Icon Editor"),
1124 self.trUtf8("""The icon image has been modified.\n""" 1124 self.trUtf8("""The icon image has been modified.\n"""
1125 """Do you want to save your changes?"""), 1125 """Do you want to save your changes?"""),
1126 QMessageBox.StandardButtons(\ 1126 QMessageBox.StandardButtons(\
1127 QMessageBox.Cancel | \ 1127 QMessageBox.Cancel | \

eric ide

mercurial