eric6/HexEdit/HexEditMainWindow.py

changeset 8222
5994b80b8760
parent 8220
006ee31b4835
child 8240
93b8a353c4bf
equal deleted inserted replaced
8221:0572a215bd2f 8222:5994b80b8760
938 938
939 def __openHexFileNewWindow(self): 939 def __openHexFileNewWindow(self):
940 """ 940 """
941 Private slot called to open a binary file in new hex editor window. 941 Private slot called to open a binary file in new hex editor window.
942 """ 942 """
943 if not self.__lastOpenPath: 943 if (
944 if self.__project and self.__project.isOpen(): 944 not self.__lastOpenPath and
945 self.__lastOpenPath = self.__project.getProjectPath() 945 self.__project is not None and
946 self.__project.isOpen()
947 ):
948 self.__lastOpenPath = self.__project.getProjectPath()
946 949
947 fileName = E5FileDialog.getOpenFileName( 950 fileName = E5FileDialog.getOpenFileName(
948 self, 951 self,
949 self.tr("Open binary file in new window"), 952 self.tr("Open binary file in new window"),
950 self.__lastOpenPath, 953 self.__lastOpenPath,
1010 def __openHexFile(self): 1013 def __openHexFile(self):
1011 """ 1014 """
1012 Private slot to open a binary file. 1015 Private slot to open a binary file.
1013 """ 1016 """
1014 if self.__maybeSave(): 1017 if self.__maybeSave():
1015 if not self.__lastOpenPath: 1018 if (
1016 if self.__project and self.__project.isOpen(): 1019 not self.__lastOpenPath and
1017 self.__lastOpenPath = self.__project.getProjectPath() 1020 self.__project is not None and
1021 self.__project.isOpen()
1022 ):
1023 self.__lastOpenPath = self.__project.getProjectPath()
1018 1024
1019 fileName = E5FileDialog.getOpenFileName( 1025 fileName = E5FileDialog.getOpenFileName(
1020 self, 1026 self,
1021 self.tr("Open binary file"), 1027 self.tr("Open binary file"),
1022 self.__lastOpenPath, 1028 self.__lastOpenPath,
1055 Private method to save the data to a new file. 1061 Private method to save the data to a new file.
1056 1062
1057 @return flag indicating success 1063 @return flag indicating success
1058 @rtype bool 1064 @rtype bool
1059 """ 1065 """
1060 if not self.__lastSavePath: 1066 if (
1061 if self.__project and self.__project.isOpen(): 1067 not self.__lastSavePath and
1062 self.__lastSavePath = self.__project.getProjectPath() 1068 self.__project is not None and
1069 self.__project.isOpen()
1070 ):
1071 self.__lastSavePath = self.__project.getProjectPath()
1063 if not self.__lastSavePath and self.__lastOpenPath: 1072 if not self.__lastSavePath and self.__lastOpenPath:
1064 self.__lastSavePath = self.__lastOpenPath 1073 self.__lastSavePath = self.__lastOpenPath
1065 1074
1066 fileName = E5FileDialog.getSaveFileName( 1075 fileName = E5FileDialog.getSaveFileName(
1067 self, 1076 self,
1134 1143
1135 @param selectionOnly flag indicating to save the selection only 1144 @param selectionOnly flag indicating to save the selection only
1136 @type bool 1145 @type bool
1137 """ 1146 """
1138 savePath = self.__lastSavePath 1147 savePath = self.__lastSavePath
1139 if not savePath: 1148 if (
1140 if self.__project and self.__project.isOpen(): 1149 not savePath and
1141 savePath = self.__project.getProjectPath() 1150 self.__project is not None and
1151 self.__project.isOpen()
1152 ):
1153 savePath = self.__project.getProjectPath()
1142 if not savePath and self.__lastOpenPath: 1154 if not savePath and self.__lastOpenPath:
1143 savePath = self.__lastOpenPath 1155 savePath = self.__lastOpenPath
1144 1156
1145 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 1157 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
1146 self, 1158 self,
1416 self.__loadRecent() 1428 self.__loadRecent()
1417 1429
1418 self.__recentMenu.clear() 1430 self.__recentMenu.clear()
1419 1431
1420 for idx, rs in enumerate(self.__recent, start=1): 1432 for idx, rs in enumerate(self.__recent, start=1):
1421 if idx < 10: 1433 formatStr = '&{0:d}. {1}' if idx < 10 else '{0:d}. {1}'
1422 formatStr = '&{0:d}. {1}'
1423 else:
1424 formatStr = '{0:d}. {1}'
1425 act = self.__recentMenu.addAction( 1434 act = self.__recentMenu.addAction(
1426 formatStr.format( 1435 formatStr.format(
1427 idx, 1436 idx,
1428 Utilities.compactPath( 1437 Utilities.compactPath(
1429 rs, HexEditMainWindow.maxMenuFilePathLen))) 1438 rs, HexEditMainWindow.maxMenuFilePathLen)))

eric ide

mercurial