src/eric7/HexEdit/HexEditMainWindow.py

branch
eric7
changeset 9576
be9f8e7e42e0
parent 9573
9960d19d66b5
child 9624
b47dfa7a137d
equal deleted inserted replaced
9575:635b6c5a36e1 9576:be9f8e7e42e0
243 0, 243 0,
244 self, 244 self,
245 "hexEditor_file_save_readable", 245 "hexEditor_file_save_readable",
246 ) 246 )
247 self.saveReadableAct.setStatusTip( 247 self.saveReadableAct.setStatusTip(
248 self.tr( 248 self.tr("Save the current binary data to a new file in a readable format")
249 "Save the current binary data to a new file in a readable" " format"
250 )
251 ) 249 )
252 self.saveReadableAct.setWhatsThis( 250 self.saveReadableAct.setWhatsThis(
253 self.tr( 251 self.tr(
254 """<b>Save As Readable...</b>""" 252 """<b>Save As Readable...</b>"""
255 """<p>Saves the current binary data to a new file in a readable""" 253 """<p>Saves the current binary data to a new file in a readable"""
268 self, 266 self,
269 "hexEditor_file_close", 267 "hexEditor_file_close",
270 ) 268 )
271 self.closeAct.setStatusTip(self.tr("Close the current hex editor window")) 269 self.closeAct.setStatusTip(self.tr("Close the current hex editor window"))
272 self.closeAct.setWhatsThis( 270 self.closeAct.setWhatsThis(
273 self.tr( 271 self.tr("""<b>Close</b><p>Closes the current hex editor window.</p>""")
274 """<b>Close</b><p>Closes the current hex editor window.</p>"""
275 )
276 ) 272 )
277 self.closeAct.triggered.connect(self.close) 273 self.closeAct.triggered.connect(self.close)
278 self.__actions.append(self.closeAct) 274 self.__actions.append(self.closeAct)
279 275
280 self.closeAllAct = EricAction( 276 self.closeAllAct = EricAction(
318 0, 314 0,
319 self, 315 self,
320 "hexEditor_file_quit", 316 "hexEditor_file_quit",
321 ) 317 )
322 self.exitAct.setStatusTip(self.tr("Quit the hex editor")) 318 self.exitAct.setStatusTip(self.tr("Quit the hex editor"))
323 self.exitAct.setWhatsThis( 319 self.exitAct.setWhatsThis(self.tr("""<b>Quit</b><p>Quit the hex editor.</p>"""))
324 self.tr("""<b>Quit</b><p>Quit the hex editor.</p>""")
325 )
326 if not self.__fromEric: 320 if not self.__fromEric:
327 self.exitAct.triggered.connect(self.__closeAll) 321 self.exitAct.triggered.connect(self.__closeAll)
328 self.__actions.append(self.exitAct) 322 self.__actions.append(self.exitAct)
329 323
330 def __initEditActions(self): 324 def __initEditActions(self):
445 self, 439 self,
446 "hexEditor_edit_select_all", 440 "hexEditor_edit_select_all",
447 ) 441 )
448 self.selectAllAct.setStatusTip(self.tr("Select the complete binary data")) 442 self.selectAllAct.setStatusTip(self.tr("Select the complete binary data"))
449 self.selectAllAct.setWhatsThis( 443 self.selectAllAct.setWhatsThis(
450 self.tr( 444 self.tr("""<b>Select All</b><p>Selects the complete binary data.</p>""")
451 """<b>Select All</b><p>Selects the complete binary data.</p>"""
452 )
453 ) 445 )
454 self.selectAllAct.triggered.connect(self.__editor.selectAll) 446 self.selectAllAct.triggered.connect(self.__editor.selectAll)
455 self.__actions.append(self.selectAllAct) 447 self.__actions.append(self.selectAllAct)
456 448
457 self.deselectAllAct = EricAction( 449 self.deselectAllAct = EricAction(
462 self, 454 self,
463 "hexEditor_edit_deselect_all", 455 "hexEditor_edit_deselect_all",
464 ) 456 )
465 self.deselectAllAct.setStatusTip(self.tr("Deselect all binary data")) 457 self.deselectAllAct.setStatusTip(self.tr("Deselect all binary data"))
466 self.deselectAllAct.setWhatsThis( 458 self.deselectAllAct.setWhatsThis(
467 self.tr( 459 self.tr("""<b>Deselect All</b><p>Deselect all all binary data.</p>""")
468 """<b>Deselect All</b><p>Deselect all all binary data.</p>"""
469 )
470 ) 460 )
471 self.deselectAllAct.triggered.connect(self.__editor.deselectAll) 461 self.deselectAllAct.triggered.connect(self.__editor.deselectAll)
472 self.__actions.append(self.deselectAllAct) 462 self.__actions.append(self.deselectAllAct)
473 463
474 self.saveSelectionReadableAct = EricAction( 464 self.saveSelectionReadableAct = EricAction(
1121 data = f.read() 1111 data = f.read()
1122 except OSError as err: 1112 except OSError as err:
1123 EricMessageBox.warning( 1113 EricMessageBox.warning(
1124 self, 1114 self,
1125 self.tr("eric Hex Editor"), 1115 self.tr("eric Hex Editor"),
1126 self.tr( 1116 self.tr("<p>Cannot read file <b>{0}</b>.</p><p>Reason: {1}</p>").format(
1127 "<p>Cannot read file <b>{0}</b>.</p>" "<p>Reason: {1}</p>" 1117 fileName, str(err)
1128 ).format(fileName, str(err)), 1118 ),
1129 ) 1119 )
1130 return 1120 return
1131 1121
1132 self.__lastOpenPath = os.path.dirname(fileName) 1122 self.__lastOpenPath = os.path.dirname(fileName)
1133 self.__editor.setData(data) 1123 self.__editor.setData(data)
1214 if pathlib.Path(fileName).exists(): 1204 if pathlib.Path(fileName).exists():
1215 res = EricMessageBox.yesNo( 1205 res = EricMessageBox.yesNo(
1216 self, 1206 self,
1217 self.tr("Save binary file"), 1207 self.tr("Save binary file"),
1218 self.tr( 1208 self.tr(
1219 "<p>The file <b>{0}</b> already exists." " Overwrite it?</p>" 1209 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>"
1220 ).format(fileName), 1210 ).format(fileName),
1221 icon=EricMessageBox.Warning, 1211 icon=EricMessageBox.Warning,
1222 ) 1212 )
1223 if not res: 1213 if not res:
1224 return False 1214 return False
1242 except OSError as err: 1232 except OSError as err:
1243 EricMessageBox.warning( 1233 EricMessageBox.warning(
1244 self, 1234 self,
1245 self.tr("eric Hex Editor"), 1235 self.tr("eric Hex Editor"),
1246 self.tr( 1236 self.tr(
1247 "<p>Cannot write file <b>{0}</b>.</p>" "<p>Reason: {1}</p>" 1237 "<p>Cannot write file <b>{0}</b>.</p><p>Reason: {1}</p>"
1248 ).format(fileName, str(err)), 1238 ).format(fileName, str(err)),
1249 ) 1239 )
1250 self.__checkActions() 1240 self.__checkActions()
1251 return False 1241 return False
1252 1242
1291 if fpath.exists(): 1281 if fpath.exists():
1292 res = EricMessageBox.yesNo( 1282 res = EricMessageBox.yesNo(
1293 self, 1283 self,
1294 self.tr("Save to readable file"), 1284 self.tr("Save to readable file"),
1295 self.tr( 1285 self.tr(
1296 "<p>The file <b>{0}</b> already exists." " Overwrite it?</p>" 1286 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>"
1297 ).format(fpath), 1287 ).format(fpath),
1298 icon=EricMessageBox.Warning, 1288 icon=EricMessageBox.Warning,
1299 ) 1289 )
1300 if not res: 1290 if not res:
1301 return 1291 return
1311 except OSError as err: 1301 except OSError as err:
1312 EricMessageBox.warning( 1302 EricMessageBox.warning(
1313 self, 1303 self,
1314 self.tr("eric Hex Editor"), 1304 self.tr("eric Hex Editor"),
1315 self.tr( 1305 self.tr(
1316 "<p>Cannot write file <b>{0}</b>.</p>" "<p>Reason: {1}</p>" 1306 "<p>Cannot write file <b>{0}</b>.</p><p>Reason: {1}</p>"
1317 ).format(fpath, str(err)), 1307 ).format(fpath, str(err)),
1318 ) 1308 )
1319 return 1309 return
1320 1310
1321 self.__statusBar.showMessage(self.tr("File saved"), 2000) 1311 self.__statusBar.showMessage(self.tr("File saved"), 2000)

eric ide

mercurial