HexEdit/HexEditMainWindow.py

changeset 4686
5f8a5c568230
parent 4673
6fa2418f010c
child 4687
f1d921533cc5
equal deleted inserted replaced
4684:ff9bce0e0424 4686:5f8a5c568230
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import os 12 import os
13 13
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, \ 14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, \
15 QCoreApplication 15 QCoreApplication, QLocale
16 from PyQt5.QtGui import QKeySequence 16 from PyQt5.QtGui import QKeySequence
17 from PyQt5.QtWidgets import QWhatsThis, QLabel, QWidget, QVBoxLayout, \ 17 from PyQt5.QtWidgets import QWhatsThis, QLabel, QWidget, QVBoxLayout, \
18 QDialog, QAction, QFrame 18 QDialog, QAction, QFrame
19 19
20 from E5Gui.E5Action import E5Action 20 from E5Gui.E5Action import E5Action
21 from E5Gui.E5MainWindow import E5MainWindow 21 from E5Gui.E5MainWindow import E5MainWindow
22 from E5Gui import E5FileDialog, E5MessageBox 22 from E5Gui import E5FileDialog, E5MessageBox
23 from E5Gui.E5ClickableLabel import E5ClickableLabel 23 from E5Gui.E5ClickableLabel import E5ClickableLabel
24
25 from Globals import strGroup
24 26
25 from .HexEditWidget import HexEditWidget 27 from .HexEditWidget import HexEditWidget
26 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget 28 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget
27 from .HexEditGotoWidget import HexEditGotoWidget 29 from .HexEditGotoWidget import HexEditGotoWidget
28 30
646 648
647 def __initMenus(self): 649 def __initMenus(self):
648 """ 650 """
649 Private method to create the menus. 651 Private method to create the menus.
650 """ 652 """
653 # TODO: add "Open recent menu"
651 mb = self.menuBar() 654 mb = self.menuBar()
652 655
653 menu = mb.addMenu(self.tr('&File')) 656 menu = mb.addMenu(self.tr('&File'))
654 menu.setTearOffEnabled(True) 657 menu.setTearOffEnabled(True)
655 menu.addAction(self.newWindowAct) 658 menu.addAction(self.newWindowAct)
806 Private slot to show the address of the cursor position. 809 Private slot to show the address of the cursor position.
807 810
808 @param address address of the cursor 811 @param address address of the cursor
809 @type int 812 @type int
810 """ 813 """
811 self.__sbAddress.setText(self.tr("Address: 0x{0:0{1}x}").format( 814 txt = "{0:0{1}x}".format(address, self.__editor.addressWidth())
812 address, self.__editor.addressWidth())) 815 txt = strGroup(txt, ":", 4)
816 self.__sbAddress.setText(self.tr("Address: {0}").format(txt))
813 817
814 @pyqtSlot(bool) 818 @pyqtSlot(bool)
815 def __showSelectionInfo(self, avail): 819 def __showSelectionInfo(self, avail):
816 """ 820 """
817 Private slot to show selection information. 821 Private slot to show selection information.
818 822
819 @param avail flag indicating the availability of a selection. 823 @param avail flag indicating the availability of a selection.
820 @type bool 824 @type bool
821 """ 825 """
822 if avail: 826 if avail:
823 start = self.__editor.getSelectionBegin() 827 addrWidth = self.__editor.addressWidth()
824 end = self.__editor.getSelectionEnd() 828 start = "{0:0{1}x}".format(self.__editor.getSelectionBegin(),
829 addrWidth)
830 start = strGroup(start, ":", 4)
831 end = "{0:0{1}x}".format(self.__editor.getSelectionEnd(),
832 addrWidth)
833 end = strGroup(end, ":", 4)
825 slen = self.__editor.getSelectionLength() 834 slen = self.__editor.getSelectionLength()
826 self.__sbSelection.setText( 835 self.__sbSelection.setText(
827 self.tr("Selection: 0x{0:0{2}x} - 0x{1:0{2}x} ({3:n} Bytes)", 836 self.tr("Selection: {0} - {1} ({2} Bytes)",
828 "0: start, 1: end, 2: address width," 837 "0: start, 1: end, 2: selection length")
829 " 3: selection length") 838 .format(start, end, QLocale().toString(slen))
830 .format(start, end, self.__editor.addressWidth(), slen)
831 ) 839 )
832 else: 840 else:
833 self.__sbSelection.setText( 841 self.__sbSelection.setText(
834 self.tr("Selection: -", "no selection available")) 842 self.tr("Selection: -", "no selection available"))
835 843
876 Private slot to show the binary data size. 884 Private slot to show the binary data size.
877 885
878 @param size size of the binary data 886 @param size size of the binary data
879 @type int 887 @type int
880 """ 888 """
881 self.__sbSize.setText(self.tr("Size: {0:n}").format(size)) 889 self.__sbSize.setText(
890 self.tr("Size: {0}").format(QLocale().toString(size)))
882 891
883 def closeEvent(self, evt): 892 def closeEvent(self, evt):
884 """ 893 """
885 Protected event handler for the close event. 894 Protected event handler for the close event.
886 895

eric ide

mercurial