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 |
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 |
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 |
23 |
103 |
103 |
104 state = Preferences.getHexEditor("HexEditorState") |
104 state = Preferences.getHexEditor("HexEditorState") |
105 self.restoreState(state) |
105 self.restoreState(state) |
106 |
106 |
107 self.__editor.currentAddressChanged.connect(self.__showAddress) |
107 self.__editor.currentAddressChanged.connect(self.__showAddress) |
|
108 self.__editor.selectionAvailable.connect(self.__showSelectionInfo) |
108 self.__editor.currentSizeChanged.connect(self.__showSize) |
109 self.__editor.currentSizeChanged.connect(self.__showSize) |
109 self.__editor.dataChanged.connect(self.__modificationChanged) |
110 self.__editor.dataChanged.connect(self.__modificationChanged) |
110 self.__editor.overwriteModeChanged.connect(self.__showEditMode) |
111 self.__editor.overwriteModeChanged.connect(self.__showEditMode) |
111 self.__editor.readOnlyChanged.connect(self.__showReadOnlyMode) |
112 self.__editor.readOnlyChanged.connect(self.__showReadOnlyMode) |
112 self.__editor.readOnlyChanged.connect(self.__checkActions) |
113 self.__editor.readOnlyChanged.connect(self.__checkActions) |
730 Private method to initialize the status bar. |
731 Private method to initialize the status bar. |
731 """ |
732 """ |
732 self.__statusBar = self.statusBar() |
733 self.__statusBar = self.statusBar() |
733 self.__statusBar.setSizeGripEnabled(True) |
734 self.__statusBar.setSizeGripEnabled(True) |
734 |
735 |
|
736 self.__sbAddress = QLabel(self.__statusBar) |
|
737 self.__statusBar.addPermanentWidget(self.__sbAddress) |
|
738 self.__sbAddress.setWhatsThis(self.tr( |
|
739 """<p>This part of the status bar displays the cursor""" |
|
740 """ address.</p>""" |
|
741 )) |
|
742 self.__sbAddress.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) |
|
743 |
|
744 self.__sbSelection = QLabel(self.__statusBar) |
|
745 self.__statusBar.addPermanentWidget(self.__sbSelection) |
|
746 self.__sbSelection.setWhatsThis(self.tr( |
|
747 """<p>This part of the status bar displays some selection""" |
|
748 """ information.</p>""" |
|
749 )) |
|
750 self.__sbSelection.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) |
|
751 |
|
752 self.__sbSize = QLabel(self.__statusBar) |
|
753 self.__statusBar.addPermanentWidget(self.__sbSize) |
|
754 self.__sbSize.setWhatsThis(self.tr( |
|
755 """<p>This part of the status bar displays the size of the""" |
|
756 """ binary data.</p>""" |
|
757 )) |
|
758 self.__sbSize.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) |
|
759 |
735 self.__sbEditMode = QLabel(self.__statusBar) |
760 self.__sbEditMode = QLabel(self.__statusBar) |
736 self.__statusBar.addPermanentWidget(self.__sbEditMode) |
761 self.__statusBar.addPermanentWidget(self.__sbEditMode) |
737 self.__sbEditMode.setWhatsThis(self.tr( |
762 self.__sbEditMode.setWhatsThis(self.tr( |
738 """<p>This part of the status bar displays the edit mode.</p>""" |
763 """<p>This part of the status bar displays the edit mode.</p>""" |
739 )) |
764 )) |
|
765 self.__sbEditMode.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) |
740 |
766 |
741 self.__sbReadOnly = QLabel(self.__statusBar) |
767 self.__sbReadOnly = QLabel(self.__statusBar) |
742 self.__statusBar.addPermanentWidget(self.__sbReadOnly) |
768 self.__statusBar.addPermanentWidget(self.__sbReadOnly) |
743 self.__sbReadOnly.setWhatsThis(self.tr( |
769 self.__sbReadOnly.setWhatsThis(self.tr( |
744 """<p>This part of the status bar displays the read""" |
770 """<p>This part of the status bar displays the read""" |
745 """ only mode.</p>""" |
771 """ only mode.</p>""" |
746 )) |
772 )) |
|
773 self.__sbReadOnly.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) |
747 |
774 |
748 self.__sbAddress = QLabel(self.__statusBar) |
|
749 self.__statusBar.addPermanentWidget(self.__sbAddress) |
|
750 self.__sbAddress.setWhatsThis(self.tr( |
|
751 """<p>This part of the status bar displays the cursor""" |
|
752 """ address.</p>""" |
|
753 )) |
|
754 |
|
755 self.__showEditMode(self.__editor.overwriteMode()) |
775 self.__showEditMode(self.__editor.overwriteMode()) |
756 self.__showReadOnlyMode(self.__editor.isReadOnly()) |
776 self.__showReadOnlyMode(self.__editor.isReadOnly()) |
757 |
|
758 self.__sbSize = QLabel(self.__statusBar) |
|
759 self.__statusBar.addPermanentWidget(self.__sbSize) |
|
760 self.__sbSize.setWhatsThis(self.tr( |
|
761 """<p>This part of the status bar displays the size of the""" |
|
762 """ binary data.</p>""" |
|
763 )) |
|
764 |
777 |
765 @pyqtSlot(int) |
778 @pyqtSlot(int) |
766 def __showAddress(self, address): |
779 def __showAddress(self, address): |
767 """ |
780 """ |
768 Private slot to show the address of the cursor position. |
781 Private slot to show the address of the cursor position. |
769 |
782 |
770 @param address address of the cursor |
783 @param address address of the cursor |
771 @type int |
784 @type int |
772 """ |
785 """ |
773 self.__sbAddress.setText(self.tr("Address: {0:#{1}x}").format( |
786 self.__sbAddress.setText(self.tr("Address: 0x{0:0{1}x}").format( |
774 address, self.__editor.addressWidth())) |
787 address, self.__editor.addressWidth())) |
|
788 |
|
789 @pyqtSlot(bool) |
|
790 def __showSelectionInfo(self, avail): |
|
791 """ |
|
792 Private slot to show selection information. |
|
793 |
|
794 @param avail flag indicating the availability of a selection. |
|
795 @type bool |
|
796 """ |
|
797 if avail: |
|
798 start = self.__editor.getSelectionBegin() |
|
799 end = self.__editor.getSelectionEnd() |
|
800 slen = self.__editor.getSelectionLength() |
|
801 self.__sbSelection.setText( |
|
802 self.tr("Selection: 0x{0:0{2}x} - 0x{1:0{2}x} ({3:n} Bytes)", |
|
803 "0: start, 1: end, 2: address width," |
|
804 " 3: selection length") |
|
805 .format(start, end, self.__editor.addressWidth(), slen) |
|
806 ) |
|
807 else: |
|
808 self.__sbSelection.setText( |
|
809 self.tr("Selection: -", "no selection available")) |
775 |
810 |
776 @pyqtSlot(bool) |
811 @pyqtSlot(bool) |
777 def __showReadOnlyMode(self, on): |
812 def __showReadOnlyMode(self, on): |
778 """ |
813 """ |
779 Private slot to show the read only mode. |
814 Private slot to show the read only mode. |