src/eric7/HexEdit/HexEditMainWindow.py

Sun, 18 Dec 2022 19:33:46 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 Dec 2022 19:33:46 +0100
branch
eric7
changeset 9624
b47dfa7a137d
parent 9576
be9f8e7e42e0
child 9653
e67609152c5e
permissions
-rw-r--r--

Refactored the Utilities and Globals modules in order to enhance the maintainability.

4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8875
diff changeset
3 # Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the hex editor main window.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
10 import contextlib
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
12 import pathlib
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
14 from PyQt6.QtCore import QCoreApplication, QLocale, QSize, pyqtSignal, pyqtSlot
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
15 from PyQt6.QtGui import QAction, QKeySequence
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
16 from PyQt6.QtWidgets import (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
17 QDialog,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
18 QFrame,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
19 QLabel,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
20 QMenu,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
21 QVBoxLayout,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
22 QWhatsThis,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
23 QWidget,
7254
f00d825fbdb3 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
24 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
26 from eric7 import Preferences
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
27 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
28 from eric7.EricGui.EricAction import EricAction
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
29 from eric7.EricWidgets import EricFileDialog, EricMessageBox
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
30 from eric7.EricWidgets.EricClickableLabel import EricClickableLabel
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
31 from eric7.EricWidgets.EricMainWindow import EricMainWindow
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
32 from eric7.Globals import recentNameHexFiles, strGroup
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
33 from eric7.SystemUtilities import FileSystemUtilities
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
34 from eric7.UI import Config
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
36 from .HexEditGotoWidget import HexEditGotoWidget
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
37 from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
38 from .HexEditWidget import HexEditWidget
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
41 class HexEditMainWindow(EricMainWindow):
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 Class implementing the web browser main window.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
44
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @signal editorClosed() emitted after the window was requested to close down
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 editorClosed = pyqtSignal()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 windows = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
52 maxMenuFilePathLen = 75
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 def __init__(self, fileName="", parent=None, fromEric=False, project=None):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param fileName name of a file to load on startup (string)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param parent parent widget of this window (QWidget)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
60 @param fromEric flag indicating whether it was called from within
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
61 eric (boolean)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
62 @param project reference to the project object (Project)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
64 super().__init__(parent)
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
65 self.setObjectName("eric7_hex_editor")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
67 self.__srHistory = {
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
68 "search": [],
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
69 # list of recent searches (tuple of format type index and
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
70 # search term)
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
71 "replace": [],
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
72 # list of recent replaces (tuple of format type index and
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
73 # replace term
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
74 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
76 self.__fromEric = fromEric
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
77 self.setWindowIcon(EricPixmapCache.getIcon("hexEditor"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
79 if not self.__fromEric:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
81
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__editor = HexEditWidget()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83 self.__searchWidget = HexEditSearchReplaceWidget(self.__editor, self, False)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
84 self.__replaceWidget = HexEditSearchReplaceWidget(self.__editor, self, True)
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
85 self.__gotoWidget = HexEditGotoWidget(self.__editor)
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
86 cw = QWidget()
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
87 layout = QVBoxLayout(cw)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
88 layout.setContentsMargins(1, 1, 1, 1)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
89 layout.setSpacing(1)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
90 layout.addWidget(self.__editor)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
91 layout.addWidget(self.__searchWidget)
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
92 layout.addWidget(self.__gotoWidget)
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
93 cw.setLayout(layout)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
94 layout.addWidget(self.__replaceWidget)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
95 self.__searchWidget.hide()
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
96 self.__replaceWidget.hide()
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
97 self.__gotoWidget.hide()
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
98 self.setCentralWidget(cw)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 g = Preferences.getGeometry("HexEditorGeometry")
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if g.isEmpty():
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 s = QSize(600, 500)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.resize(s)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 else:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.restoreGeometry(g)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
106
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__initActions()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__initMenus()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__initToolbars()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__createStatusBar()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.__class__.windows.append(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113
4655
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
114 state = Preferences.getHexEditor("HexEditorState")
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
115 self.restoreState(state)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
116
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.__editor.currentAddressChanged.connect(self.__showAddress)
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
118 self.__editor.selectionAvailable.connect(self.__showSelectionInfo)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__editor.currentSizeChanged.connect(self.__showSize)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__editor.dataChanged.connect(self.__modificationChanged)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.__editor.overwriteModeChanged.connect(self.__showEditMode)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.__editor.readOnlyChanged.connect(self.__showReadOnlyMode)
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
123 self.__editor.readOnlyChanged.connect(self.__checkActions)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
125 self.preferencesChanged()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126 self.__editor.setOverwriteMode(Preferences.getHexEditor("OpenInOverwriteMode"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
127
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__project = project
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__lastOpenPath = ""
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__lastSavePath = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
132 self.__recent = []
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
133 self.__loadRecent()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
134
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.__setCurrentFile("")
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if fileName:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.__loadHexFile(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
138
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
140
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 def __initActions(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 Private method to define the user interface actions.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 # list of all actions
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.__actions = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
147
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__initFileActions()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__initEditActions()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.__initHelpActions()
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
151 if not self.__fromEric:
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
152 self.__initConfigActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
153
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 def __initFileActions(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 Private method to define the file related user interface actions.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
158 self.newWindowAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
159 self.tr("New Window"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
160 EricPixmapCache.getIcon("newWindow"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161 self.tr("New &Window"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
165 "hexEditor_file_new_window",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
166 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
167 self.newWindowAct.setStatusTip(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
168 self.tr("Open a binary file for editing in a new hex editor window")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
170 self.newWindowAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172 """<b>New Window</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173 """<p>This opens a binary file for editing in a new hex editor"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
174 """ window.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
175 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
176 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.newWindowAct.triggered.connect(self.__openHexFileNewWindow)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.__actions.append(self.newWindowAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
180 # correct texts will be set later
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
181 self.openAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
182 self.tr("Open"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
183 EricPixmapCache.getIcon("open"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
184 self.tr("&Open..."),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 QKeySequence(self.tr("Ctrl+O", "File|Open")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
187 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188 "hexEditor_file_open",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
189 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.openAct.triggered.connect(self.__openHexFile)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.__actions.append(self.openAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
193 # correct texts will be set later
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
194 self.openReadOnlyAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 "", "", 0, 0, self, "hexEditor_file_open_read_only"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.openReadOnlyAct.triggered.connect(self.__openHexFileReadOnly)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.__actions.append(self.openReadOnlyAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
200 self.saveAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201 self.tr("Save"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
202 EricPixmapCache.getIcon("fileSave"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
203 self.tr("&Save"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 QKeySequence(self.tr("Ctrl+S", "File|Save")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
205 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
206 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
207 "hexEditor_file_save",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
208 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
209 self.saveAct.setStatusTip(self.tr("Save the current binary file"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
210 self.saveAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
211 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
212 """<b>Save File</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
213 """<p>Save the contents of the hex editor window.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
214 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
215 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.saveAct.triggered.connect(self.__saveHexFile)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.__actions.append(self.saveAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
218
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
219 self.saveAsAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
220 self.tr("Save As"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
221 EricPixmapCache.getIcon("fileSaveAs"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222 self.tr("Save &As..."),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 "hexEditor_file_save_as",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
227 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 self.saveAsAct.setStatusTip(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
229 self.tr("Save the current binary data to a new file")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
230 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
231 self.saveAsAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
232 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
233 """<b>Save As...</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
234 """<p>Saves the current binary data to a new file.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
235 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
236 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.saveAsAct.triggered.connect(self.__saveHexFileAs)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.__actions.append(self.saveAsAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
239
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
240 self.saveReadableAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
241 self.tr("Save As Readable"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
242 self.tr("Save As &Readable..."),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
243 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
244 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
245 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246 "hexEditor_file_save_readable",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
247 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.saveReadableAct.setStatusTip(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
249 self.tr("Save the current binary data to a new file in a readable format")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
250 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
251 self.saveReadableAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
252 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
253 """<b>Save As Readable...</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
254 """<p>Saves the current binary data to a new file in a readable"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255 """ format.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
256 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
257 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 self.saveReadableAct.triggered.connect(self.__saveHexFileReadable)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 self.__actions.append(self.saveReadableAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
260
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
261 self.closeAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
262 self.tr("Close"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
263 EricPixmapCache.getIcon("close"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264 self.tr("&Close"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 QKeySequence(self.tr("Ctrl+W", "File|Close")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
266 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
267 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
268 "hexEditor_file_close",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
269 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
270 self.closeAct.setStatusTip(self.tr("Close the current hex editor window"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
271 self.closeAct.setWhatsThis(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
272 self.tr("""<b>Close</b><p>Closes the current hex editor window.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
273 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 self.closeAct.triggered.connect(self.close)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 self.__actions.append(self.closeAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
276
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
277 self.closeAllAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
278 self.tr("Close All"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
279 self.tr("Close &All"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
280 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
281 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
282 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
283 "hexEditor_file_close_all",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
284 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
285 self.closeAllAct.setStatusTip(self.tr("Close all hex editor windows"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
286 self.closeAllAct.setWhatsThis(
9573
9960d19d66b5 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
287 self.tr("""<b>Close All</b><p>Closes all hex editor windows.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
288 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.closeAllAct.triggered.connect(self.__closeAll)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.__actions.append(self.closeAllAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
291
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
292 self.closeOthersAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
293 self.tr("Close Others"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294 self.tr("Close Others"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
295 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
296 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
297 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
298 "hexEditor_file_close_others",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
299 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
300 self.closeOthersAct.setStatusTip(self.tr("Close all other hex editor windows"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
301 self.closeOthersAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
302 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
303 """<b>Close Others</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
304 """<p>Closes all other hex editor windows.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
305 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
306 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 self.closeOthersAct.triggered.connect(self.__closeOthers)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.__actions.append(self.closeOthersAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
309
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
310 self.exitAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
311 self.tr("Quit"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
312 EricPixmapCache.getIcon("exit"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
313 self.tr("&Quit"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
315 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
316 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
317 "hexEditor_file_quit",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
318 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
319 self.exitAct.setStatusTip(self.tr("Quit the hex editor"))
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
320 self.exitAct.setWhatsThis(self.tr("""<b>Quit</b><p>Quit the hex editor.</p>"""))
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
321 if not self.__fromEric:
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 self.exitAct.triggered.connect(self.__closeAll)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 self.__actions.append(self.exitAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
324
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 def __initEditActions(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 Private method to create the Edit actions.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
329 self.undoAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
330 self.tr("Undo"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
331 EricPixmapCache.getIcon("editUndo"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
332 self.tr("&Undo"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
335 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
336 "hexEditor_edit_undo",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
337 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
338 self.undoAct.setStatusTip(self.tr("Undo the last change"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339 self.undoAct.setWhatsThis(
9573
9960d19d66b5 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
340 self.tr("""<b>Undo</b><p>Undo the last change done.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
341 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.undoAct.triggered.connect(self.__editor.undo)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 self.__actions.append(self.undoAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
344
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
345 self.redoAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
346 self.tr("Redo"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
347 EricPixmapCache.getIcon("editRedo"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
348 self.tr("&Redo"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
350 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
351 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
352 "hexEditor_edit_redo",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
353 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
354 self.redoAct.setStatusTip(self.tr("Redo the last change"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
355 self.redoAct.setWhatsThis(
9573
9960d19d66b5 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
356 self.tr("""<b>Redo</b><p>Redo the last change done.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.redoAct.triggered.connect(self.__editor.redo)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 self.__actions.append(self.redoAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
360
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
361 self.revertAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
362 self.tr("Revert to last saved state"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
363 self.tr("Re&vert to last saved state"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 QKeySequence(self.tr("Ctrl+Y", "Edit|Revert")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
366 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
367 "hexEditor_edit_revert",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
368 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
369 self.revertAct.setStatusTip(self.tr("Revert to last saved state"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
370 self.revertAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
371 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
372 """<b>Revert to last saved state</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
373 """<p>Undo all changes up to the last saved state of the"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
374 """ editor.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
375 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
376 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 self.revertAct.triggered.connect(self.__editor.revertToUnmodified)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 self.__actions.append(self.revertAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
380 self.cutAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
381 self.tr("Cut"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
382 EricPixmapCache.getIcon("editCut"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
383 self.tr("Cu&t"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 QKeySequence(self.tr("Shift+Del", "Edit|Cut")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
386 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
387 "hexEditor_edit_cut",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
388 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
389 self.cutAct.setStatusTip(self.tr("Cut the selection"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
390 self.cutAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
391 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392 """<b>Cut</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
393 """<p>Cut the selected binary area to the clipboard.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
394 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
395 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 self.cutAct.triggered.connect(self.__editor.cut)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 self.__actions.append(self.cutAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
398
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
399 self.copyAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400 self.tr("Copy"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
401 EricPixmapCache.getIcon("editCopy"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
402 self.tr("&Copy"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
405 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
406 "hexEditor_edit_copy",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
407 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
408 self.copyAct.setStatusTip(self.tr("Copy the selection"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
409 self.copyAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
410 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
411 """<b>Copy</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
412 """<p>Copy the selected binary area to the clipboard.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
413 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
414 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 self.copyAct.triggered.connect(self.__editor.copy)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 self.__actions.append(self.copyAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
417
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
418 self.pasteAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
419 self.tr("Paste"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
420 EricPixmapCache.getIcon("editPaste"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
421 self.tr("&Paste"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
424 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
425 "hexEditor_edit_paste",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
426 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
427 self.pasteAct.setStatusTip(self.tr("Paste the clipboard contents"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
428 self.pasteAct.setWhatsThis(
9573
9960d19d66b5 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
429 self.tr("""<b>Paste</b><p>Paste the clipboard contents.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
430 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 self.pasteAct.triggered.connect(self.__editor.paste)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 self.__actions.append(self.pasteAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
433
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
434 self.selectAllAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
435 self.tr("Select All"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
436 EricPixmapCache.getIcon("editSelectAll"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
437 self.tr("&Select All"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 QKeySequence(self.tr("Ctrl+A", "Edit|Select All")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
440 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
441 "hexEditor_edit_select_all",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
442 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443 self.selectAllAct.setStatusTip(self.tr("Select the complete binary data"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
444 self.selectAllAct.setWhatsThis(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
445 self.tr("""<b>Select All</b><p>Selects the complete binary data.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
446 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 self.selectAllAct.triggered.connect(self.__editor.selectAll)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 self.__actions.append(self.selectAllAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
449
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
450 self.deselectAllAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
451 self.tr("Deselect all"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
452 self.tr("&Deselect all"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 QKeySequence(self.tr("Alt+Ctrl+A", "Edit|Deselect all")),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
455 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
456 "hexEditor_edit_deselect_all",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
457 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
458 self.deselectAllAct.setStatusTip(self.tr("Deselect all binary data"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
459 self.deselectAllAct.setWhatsThis(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
460 self.tr("""<b>Deselect All</b><p>Deselect all all binary data.</p>""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
461 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 self.deselectAllAct.triggered.connect(self.__editor.deselectAll)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 self.__actions.append(self.deselectAllAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
464
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
465 self.saveSelectionReadableAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
466 self.tr("Save Selection Readable"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
467 self.tr("Save Selection Readable..."),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
468 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
469 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
470 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
471 "hexEditor_edit_selection_save_readable",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
472 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 self.saveSelectionReadableAct.setStatusTip(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
474 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
475 "Save the binary data of the current selection to a file"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
476 " in a readable format"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
477 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
478 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
479 self.saveSelectionReadableAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
480 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
481 """<b>Save Selection Readable...</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
482 """<p>Saves the binary data of the current selection to a file"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
483 """ in a readable format.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
484 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
485 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
486 self.saveSelectionReadableAct.triggered.connect(self.__saveSelectionReadable)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 self.__actions.append(self.saveSelectionReadableAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
488
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
489 self.readonlyAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
490 self.tr("Set Read Only"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
491 self.tr("Set Read Only"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
492 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
493 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
494 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
495 "hexEditor_edit_readonly",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
496 True,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
497 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498 self.readonlyAct.setStatusTip(self.tr("Change the edit mode to read only"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
499 self.readonlyAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
500 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
501 """<b>Set Read Only</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
502 """<p>This changes the edit mode to read only (i.e. to view"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
503 """ mode).</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
504 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
505 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 self.readonlyAct.setChecked(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 self.readonlyAct.toggled[bool].connect(self.__editor.setReadOnly)
4655
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
508 self.__editor.readOnlyChanged.connect(self.readonlyAct.setChecked)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 self.__actions.append(self.readonlyAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
510
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
511 self.searchAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
512 self.tr("Search"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
513 EricPixmapCache.getIcon("find"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
514 self.tr("&Search..."),
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
515 QKeySequence(self.tr("Ctrl+F", "Search|Search")),
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
516 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
517 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
518 "hexEditor_edit_search",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
519 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
520 self.searchAct.setStatusTip(self.tr("Search for data"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
521 self.searchAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
522 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
523 """<b>Search</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
524 """<p>Search for some data. A dialog is shown to enter the"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
525 """ data to search for in various formats.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
526 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
527 )
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
528 self.searchAct.triggered.connect(self.__search)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
529 self.__actions.append(self.searchAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
530
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
531 self.searchNextAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
532 self.tr("Search next"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
533 EricPixmapCache.getIcon("findNext"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
534 self.tr("Search &next"),
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
535 QKeySequence(self.tr("F3", "Search|Search next")),
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
536 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
537 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
538 "hexEditor_edit_search_next",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
539 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
540 self.searchNextAct.setStatusTip(self.tr("Search next occurrence"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
541 self.searchNextAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
542 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
543 """<b>Search next</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
544 """<p>Search the next occurrence of some data. The previously"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
545 """ entered search data are reused.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
546 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
547 )
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
548 self.searchNextAct.triggered.connect(self.__searchWidget.findPrevNext)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
549 self.__actions.append(self.searchNextAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
550
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
551 self.searchPrevAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
552 self.tr("Search previous"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
553 EricPixmapCache.getIcon("findPrev"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
554 self.tr("Search &previous"),
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
555 QKeySequence(self.tr("Shift+F3", "Search|Search previous")),
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
556 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
557 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
558 "hexEditor_edit_search_previous",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
559 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
560 self.searchPrevAct.setStatusTip(self.tr("Search previous occurrence"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
561 self.searchPrevAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
562 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
563 """<b>Search previous</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
564 """<p>Search the previous occurrence of some data. The"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
565 """ previously entered search data are reused.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
566 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
567 )
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
568 self.searchPrevAct.triggered.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
569 lambda: self.__searchWidget.findPrevNext(True)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
570 )
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
571 self.__actions.append(self.searchPrevAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
572
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
573 self.replaceAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
574 self.tr("Replace"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
575 self.tr("&Replace..."),
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
576 QKeySequence(self.tr("Ctrl+R", "Search|Replace")),
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
577 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
578 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
579 "hexEditor_edit_search_replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
580 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
581 self.replaceAct.setStatusTip(self.tr("Replace data"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
582 self.replaceAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
583 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
584 """<b>Replace</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
585 """<p>Search for some data and replace it."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
586 """ A dialog is shown to enter the data to search for and the"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
587 """ replacement data in various formats.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
588 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
589 )
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
590 self.replaceAct.triggered.connect(self.__replace)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
591 self.__actions.append(self.replaceAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
592
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
593 self.gotoAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
594 self.tr("Goto Offset"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
595 EricPixmapCache.getIcon("goto"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
596 self.tr("&Goto Offset..."),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
597 QKeySequence(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
598 QCoreApplication.translate(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
599 "ViewManager", "Ctrl+G", "Search|Goto Offset"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
600 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
601 ),
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
602 0,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
603 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
604 "hexEditor_edit_goto",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
605 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
606 self.gotoAct.setStatusTip(self.tr("Goto Offset"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
607 self.gotoAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
608 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
609 """<b>Goto Offset</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
610 """<p>Go to a specific address. A dialog is shown to enter"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
611 """ the movement data.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
612 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
613 )
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
614 self.gotoAct.triggered.connect(self.__goto)
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
615 self.__actions.append(self.gotoAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
616
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 self.redoAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 self.__editor.canRedoChanged.connect(self.redoAct.setEnabled)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
619
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 self.undoAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 self.__editor.canUndoChanged.connect(self.undoAct.setEnabled)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
622
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 self.revertAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 self.__editor.dataChanged.connect(self.revertAct.setEnabled)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
625
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 self.cutAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self.copyAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 self.saveSelectionReadableAct.setEnabled(False)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 self.__editor.selectionAvailable.connect(self.__checkActions)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.__editor.selectionAvailable.connect(self.copyAct.setEnabled)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 self.__editor.selectionAvailable.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
632 self.saveSelectionReadableAct.setEnabled
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
633 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
634
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 def __initHelpActions(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 Private method to create the Help actions.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
639 self.aboutAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
640 self.tr("About"), self.tr("&About"), 0, 0, self, "hexEditor_help_about"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
641 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
642 self.aboutAct.setStatusTip(self.tr("Display information about this software"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
643 self.aboutAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
644 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
645 """<b>About</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
646 """<p>Display some information about this software.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
647 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
648 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 self.aboutAct.triggered.connect(self.__about)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 self.__actions.append(self.aboutAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
651
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
652 self.aboutQtAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
653 self.tr("About Qt"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
654 self.tr("About &Qt"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
655 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
656 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
657 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
658 "hexEditor_help_about_qt",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
659 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 self.aboutQtAct.setStatusTip(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
661 self.tr("Display information about the Qt toolkit")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
662 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
663 self.aboutQtAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
664 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
665 """<b>About Qt</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
666 """<p>Display some information about the Qt toolkit.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
667 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
668 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 self.aboutQtAct.triggered.connect(self.__aboutQt)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 self.__actions.append(self.aboutQtAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
671
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
672 self.whatsThisAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
673 self.tr("What's This?"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
674 EricPixmapCache.getIcon("whatsThis"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
675 self.tr("&What's This?"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
677 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
678 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
679 "hexEditor_help_whats_this",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
680 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
681 self.whatsThisAct.setStatusTip(self.tr("Context sensitive help"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
682 self.whatsThisAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
683 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
684 """<b>Display context sensitive help</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
685 """<p>In What's This? mode, the mouse cursor shows an arrow"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
686 """ with a question mark, and you can click on the interface"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
687 """ elements to get a short description of what they do and"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
688 """ how to use them. In dialogs, this feature can be accessed"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
689 """ using the context help button in the titlebar.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
690 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
691 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 self.whatsThisAct.triggered.connect(self.__whatsThis)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 self.__actions.append(self.whatsThisAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
694
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
695 def __initConfigActions(self):
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
696 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
697 Private method to create the Settings actions.
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
698 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
699 self.prefAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
700 self.tr("Preferences"),
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
701 EricPixmapCache.getIcon("configure"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
702 self.tr("&Preferences..."),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
703 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
704 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
705 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
706 "hexEditor_settings_preferences",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
707 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
708 self.prefAct.setStatusTip(self.tr("Set the prefered configuration"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
709 self.prefAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
710 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
711 """<b>Preferences</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
712 """<p>Set the configuration items of the application"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
713 """ with your prefered values.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
714 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
715 )
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
716 self.prefAct.triggered.connect(self.__showPreferences)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
717 self.prefAct.setMenuRole(QAction.MenuRole.PreferencesRole)
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
718 self.__actions.append(self.prefAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
719
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
720 def __setReadOnlyActionTexts(self):
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
721 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
722 Private method to switch the 'Open Read Only' action between
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
723 'read only' and 'read write'.
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
724 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
725 if Preferences.getHexEditor("OpenReadOnly"):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
726 self.openAct.setStatusTip(self.tr("Open a binary file for viewing"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
727 self.openAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
728 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
729 """<b>Open File</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
730 """<p>This opens a binary file for viewing (i.e. in read"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
731 """ only mode). It pops up a file selection dialog.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
732 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
733 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
734
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
735 self.openReadOnlyAct.setText(self.tr("Open for Editing..."))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
736 self.openReadOnlyAct.setIconText(self.tr("Open for Editing"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
737 self.openReadOnlyAct.setStatusTip(self.tr("Open a binary file for editing"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
738 self.openReadOnlyAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
739 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
740 """<b>Open for Editing</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
741 """<p>This opens a binary file for editing."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
742 """ It pops up a file selection dialog.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
743 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
744 )
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
745 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
746 self.openAct.setStatusTip(self.tr("Open a binary file for editing"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
747 self.openAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
748 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
749 """<b>Open File</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
750 """<p>This opens a binary file for editing."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
751 """ It pops up a file selection dialog.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
752 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
753 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
754
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
755 self.openReadOnlyAct.setText(self.tr("Open Read Only..."))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
756 self.openReadOnlyAct.setIconText(self.tr("Open Read Only"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
757 self.openReadOnlyAct.setStatusTip(self.tr("Open a binary file for viewing"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
758 self.openReadOnlyAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
759 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
760 """<b>Open Read Only</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
761 """<p>This opens a binary file for viewing (i.e. in read"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
762 """ only mode). It pops up a file selection dialog.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
763 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
764 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
765
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 def __initMenus(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 Private method to create the menus.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 mb = self.menuBar()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
771
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
772 menu = mb.addMenu(self.tr("&File"))
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 menu.setTearOffEnabled(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
774 self.__recentMenu = QMenu(self.tr("Open &Recent Files"), menu)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 menu.addAction(self.newWindowAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 menu.addAction(self.openAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 menu.addAction(self.openReadOnlyAct)
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
778 self.__menuRecentAct = menu.addMenu(self.__recentMenu)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 menu.addAction(self.saveAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 menu.addAction(self.saveAsAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 menu.addAction(self.saveReadableAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 menu.addAction(self.closeAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 menu.addAction(self.closeOthersAct)
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
786 if self.__fromEric:
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 menu.addAction(self.closeAllAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 else:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 menu.addAction(self.exitAct)
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
791 menu.aboutToShow.connect(self.__showFileMenu)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
792 self.__recentMenu.aboutToShow.connect(self.__showRecentMenu)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
793 self.__recentMenu.triggered.connect(self.__openRecentHexFile)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
794
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 menu = mb.addMenu(self.tr("&Edit"))
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 menu.setTearOffEnabled(True)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 menu.addAction(self.undoAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 menu.addAction(self.redoAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 menu.addAction(self.revertAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 menu.addAction(self.cutAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 menu.addAction(self.copyAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 menu.addAction(self.pasteAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 menu.addAction(self.selectAllAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 menu.addAction(self.deselectAllAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 menu.addAction(self.saveSelectionReadableAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 menu.addSeparator()
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
809 menu.addAction(self.searchAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
810 menu.addAction(self.searchNextAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
811 menu.addAction(self.searchPrevAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
812 menu.addAction(self.replaceAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
813 menu.addSeparator()
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
814 menu.addAction(self.gotoAct)
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
815 menu.addSeparator()
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 menu.addAction(self.readonlyAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
817
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
818 if not self.__fromEric:
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
819 menu = mb.addMenu(self.tr("Se&ttings"))
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
820 menu.setTearOffEnabled(True)
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
821 menu.addAction(self.prefAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
822
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 mb.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
824
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 menu = mb.addMenu(self.tr("&Help"))
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 menu.addAction(self.aboutAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 menu.addAction(self.aboutQtAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 menu.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 menu.addAction(self.whatsThisAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
830
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 def __initToolbars(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 Private method to create the toolbars.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 filetb = self.addToolBar(self.tr("File"))
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 filetb.setObjectName("FileToolBar")
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
837 filetb.setIconSize(Config.ToolBarIconSize)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 filetb.addAction(self.newWindowAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 filetb.addAction(self.openAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 filetb.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 filetb.addAction(self.saveAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 filetb.addAction(self.saveAsAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 filetb.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 filetb.addAction(self.closeAct)
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
845 if not self.__fromEric:
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 filetb.addAction(self.exitAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
847
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 edittb = self.addToolBar(self.tr("Edit"))
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 edittb.setObjectName("EditToolBar")
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
850 edittb.setIconSize(Config.ToolBarIconSize)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 edittb.addAction(self.undoAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 edittb.addAction(self.redoAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 edittb.addSeparator()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 edittb.addAction(self.cutAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 edittb.addAction(self.copyAct)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 edittb.addAction(self.pasteAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
857
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
858 searchtb = self.addToolBar(self.tr("Find"))
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
859 searchtb.setObjectName("SearchToolBar")
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
860 searchtb.setIconSize(Config.ToolBarIconSize)
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
861 searchtb.addAction(self.searchAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
862 searchtb.addAction(self.searchNextAct)
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
863 searchtb.addAction(self.searchPrevAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
864
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
865 if not self.__fromEric:
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
866 settingstb = self.addToolBar(self.tr("Settings"))
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
867 settingstb.setObjectName("SettingsToolBar")
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
868 settingstb.setIconSize(Config.ToolBarIconSize)
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
869 settingstb.addAction(self.prefAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
870
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 helptb = self.addToolBar(self.tr("Help"))
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 helptb.setObjectName("HelpToolBar")
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
873 helptb.setIconSize(Config.ToolBarIconSize)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 helptb.addAction(self.whatsThisAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
875
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 def __createStatusBar(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 Private method to initialize the status bar.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 self.__statusBar = self.statusBar()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.__statusBar.setSizeGripEnabled(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
882
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
883 self.__sbAddress = QLabel(self.__statusBar)
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
884 self.__statusBar.addPermanentWidget(self.__sbAddress)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
885 self.__sbAddress.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
886 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
887 """<p>This part of the status bar displays the cursor"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
888 """ address.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
889 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
890 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
891 self.__sbAddress.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
892
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
893 self.__sbSelection = QLabel(self.__statusBar)
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
894 self.__statusBar.addPermanentWidget(self.__sbSelection)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
895 self.__sbSelection.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
896 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
897 """<p>This part of the status bar displays some selection"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
898 """ information.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
899 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
900 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
901 self.__sbSelection.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
902
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
903 self.__sbSize = QLabel(self.__statusBar)
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
904 self.__statusBar.addPermanentWidget(self.__sbSize)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
905 self.__sbSize.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
906 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
907 """<p>This part of the status bar displays the size of the"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
908 """ binary data.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
909 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
910 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
911 self.__sbSize.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
912
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
913 self.__sbEditMode = EricClickableLabel(self.__statusBar)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 self.__statusBar.addPermanentWidget(self.__sbEditMode)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
915 self.__sbEditMode.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
916 self.tr("""<p>This part of the status bar displays the edit mode.</p>""")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
917 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
918 self.__sbEditMode.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
4673
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
919 self.__sbEditMode.clicked.connect(self.__toggleEditMode)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
920
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
921 self.__sbReadOnly = EricClickableLabel(self.__statusBar)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 self.__statusBar.addPermanentWidget(self.__sbReadOnly)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
923 self.__sbReadOnly.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
924 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
925 """<p>This part of the status bar displays the read"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
926 """ only mode.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
927 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
928 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
929 self.__sbReadOnly.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain)
4673
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
930 self.__sbReadOnly.clicked.connect(self.__toggleReadOnlyMode)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 self.__showEditMode(self.__editor.overwriteMode())
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 self.__showReadOnlyMode(self.__editor.isReadOnly())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
934
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 @pyqtSlot(int)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 def __showAddress(self, address):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 Private slot to show the address of the cursor position.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
939
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 @param address address of the cursor
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 @type int
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 """
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
943 txt = "{0:0{1}x}".format(address, self.__editor.addressWidth())
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
944 txt = strGroup(txt, ":", 4)
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
945 self.__sbAddress.setText(self.tr("Address: {0}").format(txt))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
946
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 @pyqtSlot(bool)
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
948 def __showSelectionInfo(self, avail):
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
949 """
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
950 Private slot to show selection information.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
951
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
952 @param avail flag indicating the availability of a selection.
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
953 @type bool
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
954 """
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
955 if avail:
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
956 addrWidth = self.__editor.addressWidth()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
957 start = "{0:0{1}x}".format(self.__editor.getSelectionBegin(), addrWidth)
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
958 start = strGroup(start, ":", 4)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
959 end = "{0:0{1}x}".format(self.__editor.getSelectionEnd(), addrWidth)
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4673
diff changeset
960 end = strGroup(end, ":", 4)
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
961 slen = self.__editor.getSelectionLength()
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
962 self.__sbSelection.setText(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
963 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
964 "Selection: {0} - {1} ({2} Bytes)",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
965 "0: start, 1: end, 2: selection length",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
966 ).format(start, end, QLocale().toString(slen))
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
967 )
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
968 else:
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
969 self.__sbSelection.setText(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
970 self.tr("Selection: -", "no selection available")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
971 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
972
4669
d37bfc9ca3b9 Added selection information to the statusbar of the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4666
diff changeset
973 @pyqtSlot(bool)
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 def __showReadOnlyMode(self, on):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 Private slot to show the read only mode.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
977
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 @param on flag indicating the read only state
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 @type bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 self.__sbReadOnly.setText(self.tr("ro") if on else self.tr("rw"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
982
4673
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
983 @pyqtSlot()
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
984 def __toggleReadOnlyMode(self):
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
985 """
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
986 Private slot to toggle the read only mode upon a click on the status
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
987 bar label.
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
988 """
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
989 self.__editor.setReadOnly(not self.__editor.isReadOnly())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
990
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 @pyqtSlot(bool)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 def __showEditMode(self, overwrite):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 Private slot to show the edit mode.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
995
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 @param overwrite flag indicating overwrite mode
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 @type bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 self.__sbEditMode.setText(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1000 self.tr("Overwrite") if overwrite else self.tr("Insert")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1001 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1002
4673
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1003 @pyqtSlot()
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1004 def __toggleEditMode(self):
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1005 """
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1006 Private slot to toggle the edit mode upon a click on the status bar
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1007 label.
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1008 """
6fa2418f010c Finalized the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4670
diff changeset
1009 self.__editor.setOverwriteMode(not self.__editor.overwriteMode())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1010
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 @pyqtSlot(int)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 def __showSize(self, size):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 Private slot to show the binary data size.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1015
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 @param size size of the binary data
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 @type int
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1019 self.__sbSize.setText(self.tr("Size: {0}").format(QLocale().toString(size)))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1020
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 def closeEvent(self, evt):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 Protected event handler for the close event.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1024
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 @param evt reference to the close event
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 <br />This event is simply accepted after the history has been
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 saved and all window references have been deleted.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 @type QCloseEvent
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 if self.__maybeSave():
4655
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
1031 state = self.saveState()
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
1032 Preferences.setHexEditor("HexEditorState", state)
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
1033
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 Preferences.setGeometry("HexEditorGeometry", self.saveGeometry())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1035
8240
93b8a353c4bf Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8222
diff changeset
1036 with contextlib.suppress(ValueError):
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1037 if self.__fromEric or len(self.__class__.windows) > 1:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1038 del self.__class__.windows[self.__class__.windows.index(self)]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1039
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1040 if not self.__fromEric:
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 Preferences.syncPreferences()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1042
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1043 self.__saveRecent()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1044
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 evt.accept()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 self.editorClosed.emit()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 else:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 evt.ignore()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1049
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 def __openHexFileNewWindow(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 Private slot called to open a binary file in new hex editor window.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 """
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1054 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1055 not self.__lastOpenPath
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1056 and self.__project is not None
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1057 and self.__project.isOpen()
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1058 ):
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1059 self.__lastOpenPath = self.__project.getProjectPath()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1060
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1061 fileName = EricFileDialog.getOpenFileName(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1063 self.tr("Open binary file in new window"),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1064 self.__lastOpenPath,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1065 self.tr("All Files (*)"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1066 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1067 if fileName:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1068 he = HexEditMainWindow(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1069 fileName=fileName,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1070 parent=self.parent(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1071 fromEric=self.__fromEric,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1072 project=self.__project,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1073 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1074 he.setRecentPaths("", self.__lastSavePath)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075 he.show()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1076
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1077 def __maybeSave(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1078 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079 Private method to ask the user to save the file, if it was modified.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1080
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 @return flag indicating, if it is ok to continue
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 @rtype bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 if self.__editor.isModified():
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1085 ret = EricMessageBox.okToClearData(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 self,
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
1087 self.tr("eric Hex Editor"),
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1088 self.tr("""The loaded file has unsaved changes."""),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1089 self.__saveHexFile,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1090 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091 if not ret:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092 return False
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1094
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1095 def __loadHexFile(self, fileName):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1096 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1097 Private method to load a binary file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1098
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1099 @param fileName name of the binary file to load
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1100 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1101 """
9162
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1102 if not os.path.exists(fileName):
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1103 EricMessageBox.warning(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1104 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1105 self.tr("eric Hex Editor"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1106 self.tr("The file '{0}' does not exist.").format(fileName),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1107 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1109
9162
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1110 try:
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1111 with open(fileName, "rb") as f:
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1112 data = f.read()
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1113 except OSError as err:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1114 EricMessageBox.warning(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1115 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1116 self.tr("eric Hex Editor"),
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1117 self.tr("<p>Cannot read file <b>{0}</b>.</p><p>Reason: {1}</p>").format(
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1118 fileName, str(err)
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1119 ),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1120 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1121 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1122
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1123 self.__lastOpenPath = os.path.dirname(fileName)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1124 self.__editor.setData(data)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1125 self.__setCurrentFile(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1126
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1127 self.__editor.setReadOnly(Preferences.getHexEditor("OpenReadOnly"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1128
4687
f1d921533cc5 Little improvements to the hex editor goto widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4686
diff changeset
1129 self.__gotoWidget.reset()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1130
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1131 def __openHexFile(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1132 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1133 Private slot to open a binary file.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1134 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1135 if self.__maybeSave():
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1136 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1137 not self.__lastOpenPath
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1138 and self.__project is not None
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1139 and self.__project.isOpen()
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1140 ):
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1141 self.__lastOpenPath = self.__project.getProjectPath()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1142
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1143 fileName = EricFileDialog.getOpenFileName(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1144 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1145 self.tr("Open binary file"),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1146 self.__lastOpenPath,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1147 self.tr("All Files (*)"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1148 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1149 if fileName:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1150 self.__loadHexFile(fileName)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1151 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1152
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1153 def __openHexFileReadOnly(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1154 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1155 Private slot to open a binary file in read only mode.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1156 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1157 self.__openHexFile()
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1158 self.__editor.setReadOnly(not Preferences.getHexEditor("OpenReadOnly"))
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1159 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1160
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1161 def __saveHexFile(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1162 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1163 Private method to save a binary file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1164
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1165 @return flag indicating success
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1166 @rtype bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1167 """
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1168 ok = (
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1169 self.__saveHexDataFile(self.__fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1170 if self.__fileName
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1171 else self.__saveHexFileAs()
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1172 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1173
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1174 if ok:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1175 self.__editor.undoStack().setClean()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1176
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1177 return ok
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1178
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1179 def __saveHexFileAs(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1180 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1181 Private method to save the data to a new file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1182
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1183 @return flag indicating success
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1184 @rtype bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1185 """
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1186 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1187 not self.__lastSavePath
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1188 and self.__project is not None
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1189 and self.__project.isOpen()
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1190 ):
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1191 self.__lastSavePath = self.__project.getProjectPath()
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1192 if not self.__lastSavePath and self.__lastOpenPath:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1193 self.__lastSavePath = self.__lastOpenPath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1194
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1195 fileName = EricFileDialog.getSaveFileName(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1196 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1197 self.tr("Save binary file"),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1198 self.__lastSavePath,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1199 self.tr("All Files (*)"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1200 EricFileDialog.DontConfirmOverwrite,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1201 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1202 if not fileName:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1203 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1204
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1205 if pathlib.Path(fileName).exists():
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1206 res = EricMessageBox.yesNo(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1207 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1208 self.tr("Save binary file"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1209 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1210 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1211 ).format(fileName),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1212 icon=EricMessageBox.Warning,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1213 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1214 if not res:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1215 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1216
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1217 self.__lastSavePath = os.path.dirname(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1218
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1219 return self.__saveHexDataFile(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1220
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1221 def __saveHexDataFile(self, fileName):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1222 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1223 Private method to save the binary data to a file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1224
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1225 @param fileName name of the file to write to
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1226 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1227 @return flag indicating success
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1228 @rtype bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1229 """
9162
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1230 try:
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1231 with open(fileName, "wb") as f:
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1232 f.write(self.__editor.data())
8b75b1668583 Changed some use of QFile() to a more pythonic solution and fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9153
diff changeset
1233 except OSError as err:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1234 EricMessageBox.warning(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1235 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1236 self.tr("eric Hex Editor"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1237 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1238 "<p>Cannot write file <b>{0}</b>.</p><p>Reason: {1}</p>"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1239 ).format(fileName, str(err)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1240 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1241 self.__checkActions()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1242 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1243
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1244 self.__editor.setModified(False, setCleanState=True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1245
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1246 self.__setCurrentFile(fileName)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1247 self.__statusBar.showMessage(self.tr("File saved"), 2000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1248
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1249 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1250
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1251 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1252
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1253 def __saveHexFileReadable(self, selectionOnly=False):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1254 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1255 Private method to save the binary data in readable format.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1256
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1257 @param selectionOnly flag indicating to save the selection only
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1258 @type bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1259 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1260 savePath = self.__lastSavePath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1261 if not savePath and self.__project is not None and self.__project.isOpen():
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
1262 savePath = self.__project.getProjectPath()
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1263 if not savePath and self.__lastOpenPath:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1264 savePath = self.__lastOpenPath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1265
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1266 fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1267 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1268 self.tr("Save to readable file"),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1269 savePath,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1270 self.tr("Text Files (*.txt);;All Files (*)"),
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1271 self.tr("Text Files (*.txt)"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1272 EricFileDialog.DontConfirmOverwrite,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1273 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1274 if not fileName:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1275 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1276
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1277 fpath = pathlib.Path(fileName)
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1278 if not fpath.suffix:
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1279 ex = selectedFilter.split("(*")[1].split(")")[0]
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1280 if ex:
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1281 fpath = fpath.with_suffix(ex)
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1282 if fpath.exists():
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1283 res = EricMessageBox.yesNo(
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1284 self,
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1285 self.tr("Save to readable file"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1286 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1287 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1288 ).format(fpath),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1289 icon=EricMessageBox.Warning,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1290 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1291 if not res:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1292 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1293
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1294 readableData = (
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1295 self.__editor.selectionToReadableString()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1296 if selectionOnly
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1297 else self.__editor.toReadableString()
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1298 )
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1299 try:
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1300 with fpath.open("w", encoding="latin1") as f:
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1301 f.write(readableData)
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1302 except OSError as err:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1303 EricMessageBox.warning(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1304 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1305 self.tr("eric Hex Editor"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1306 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
1307 "<p>Cannot write file <b>{0}</b>.</p><p>Reason: {1}</p>"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1308 ).format(fpath, str(err)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1309 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1310 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1311
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1312 self.__statusBar.showMessage(self.tr("File saved"), 2000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1313
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1314 def __saveSelectionReadable(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1315 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1316 Private method to save the data of the current selection in readable
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1317 format.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1318 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1319 self.__saveHexFileReadable(selectionOnly=True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1320
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1321 def __closeAll(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1322 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1323 Private slot to close all windows.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1324 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1325 self.__closeOthers()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1326 self.close()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1327
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1328 def __closeOthers(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1329 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1330 Private slot to close all other windows.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1331 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1332 for win in self.__class__.windows[:]:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1333 if win != self:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1334 win.close()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1335
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1336 def __setCurrentFile(self, fileName):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1337 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1338 Private method to register the file name of the current file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1339
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1340 @param fileName name of the file to register
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1341 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1342 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1343 self.__fileName = fileName
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1344 # insert filename into list of recently opened files
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1345 self.__addToRecentList(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1346
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1347 shownName = (
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1348 self.tr("Untitled")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1349 if not self.__fileName
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1350 else self.__strippedName(self.__fileName)
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1351 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1352
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1353 self.setWindowTitle(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1354 self.tr("{0}[*] - {1}").format(shownName, self.tr("Hex Editor"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1355 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1356
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1357 self.setWindowModified(self.__editor.isModified())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1358
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1359 def __strippedName(self, fullFileName):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1360 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1361 Private method to return the filename part of the given path.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1362
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1363 @param fullFileName full pathname of the given file
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1364 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1365 @return filename part
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1366 @rtype str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1367 """
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1368 return pathlib.Path(fullFileName).name
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1369
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1370 def setRecentPaths(self, openPath, savePath):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1371 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1372 Public method to set the last open and save paths.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1373
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1374 @param openPath least recently used open path
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1375 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1376 @param savePath least recently used save path
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1377 @type str
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1378 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1379 if openPath:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1380 self.__lastOpenPath = openPath
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1381 if savePath:
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1382 self.__lastSavePath = savePath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1383
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1384 @pyqtSlot()
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1385 def __checkActions(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1386 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1387 Private slot to check some actions for their enable/disable status.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1388 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1389 self.saveAct.setEnabled(self.__editor.isModified())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1390
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1391 self.cutAct.setEnabled(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1392 not self.__editor.isReadOnly() and self.__editor.hasSelection()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1393 )
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1394 self.pasteAct.setEnabled(not self.__editor.isReadOnly())
4655
f2f0abd5bc94 Fixed a few bugs in the hex editor and added capability to save/restore the main window state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4652
diff changeset
1395 self.replaceAct.setEnabled(not self.__editor.isReadOnly())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1396
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1397 @pyqtSlot(bool)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1398 def __modificationChanged(self, m):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1399 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1400 Private slot to handle the dataChanged signal.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1401
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1402 @param m modification status
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1403 @type bool
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1404 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1405 self.setWindowModified(m)
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1406 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1407
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1408 def __about(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1409 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1410 Private slot to show a little About message.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1411 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1412 EricMessageBox.about(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1413 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1414 self.tr("About eric Hex Editor"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1415 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1416 "The eric Hex Editor is a simple editor component"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1417 " to edit binary files."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1418 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1419 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1420
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1421 def __aboutQt(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1422 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1423 Private slot to handle the About Qt dialog.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1424 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
1425 EricMessageBox.aboutQt(self, "eric Hex Editor")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1426
4650
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1427 def __whatsThis(self):
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1428 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1429 Private slot called in to enter Whats This mode.
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1430 """
b1ca3bcde70b First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1431 QWhatsThis.enterWhatsThisMode()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1432
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1433 def __search(self):
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1434 """
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1435 Private method to handle the search action.
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1436 """
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1437 self.__replaceWidget.hide()
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1438 self.__gotoWidget.hide()
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1439 txt = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1440 self.__editor.selectionToHexString() if self.__editor.hasSelection() else ""
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1441 )
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1442 self.__searchWidget.show(txt)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1443
4652
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1444 def __replace(self):
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1445 """
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1446 Private method to handle the replace action.
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1447 """
a88a2ba7a48a Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4651
diff changeset
1448 self.__searchWidget.hide()
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1449 self.__gotoWidget.hide()
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1450 txt = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1451 self.__editor.selectionToHexString() if self.__editor.hasSelection() else ""
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
1452 )
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1453 self.__replaceWidget.show(txt)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1454
4670
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1455 def __goto(self):
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1456 """
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1457 Private method to handle the goto action.
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1458 """
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1459 self.__searchWidget.hide()
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1460 self.__replaceWidget.hide()
d401ba329d24 Added 'Goto' functionality to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4669
diff changeset
1461 self.__gotoWidget.show()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1462
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1463 def preferencesChanged(self):
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1464 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1465 Public method to (re-)read the various settings.
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1466 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1467 self.__editor.setAddressWidth(Preferences.getHexEditor("AddressAreaWidth"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1468 self.__editor.setAddressArea(Preferences.getHexEditor("ShowAddressArea"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1469 self.__editor.setAsciiArea(Preferences.getHexEditor("ShowAsciiArea"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1470 self.__editor.setHighlighting(Preferences.getHexEditor("HighlightChanges"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1471 self.__editor.setFont(Preferences.getHexEditor("Font"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1472
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1473 self.__setReadOnlyActionTexts()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1474
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1475 def __showPreferences(self):
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1476 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1477 Private slot to set the preferences.
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1478 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
1479 from eric7.Preferences.ConfigurationDialog import (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1480 ConfigurationDialog,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1481 ConfigurationMode,
8265
0090cfa83159 Converted enum names to use all uppercase letters (except for E5PathPickerModes to keep plug-ins using this compatible with previous eric releases).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8259
diff changeset
1482 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1483
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1484 dlg = ConfigurationDialog(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1485 None,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1486 "Configuration",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1487 True,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1488 fromEric=True,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1489 displayMode=ConfigurationMode.HEXEDITORMODE,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1490 )
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1491 dlg.preferencesChanged.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1492 self.__preferencesChangedByLocalPreferencesDialog
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1493 )
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1494 dlg.show()
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1495 dlg.showConfigurationPageByName("hexEditorPage")
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
1496 dlg.exec()
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1497 QCoreApplication.processEvents()
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
1498 if dlg.result() == QDialog.DialogCode.Accepted:
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1499 dlg.setPreferences()
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1500 Preferences.syncPreferences()
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1501 self.__preferencesChangedByLocalPreferencesDialog()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1502
4658
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1503 def __preferencesChangedByLocalPreferencesDialog(self):
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1504 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1505 Private slot to handle preferences changes by our local dialog.
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1506 """
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1507 for hexEditor in HexEditMainWindow.windows:
d760763dcc4a Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4655
diff changeset
1508 hexEditor.preferencesChanged()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1509
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1510 def getSRHistory(self, key):
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1511 """
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1512 Public method to get the search or replace history list.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1513
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1514 @param key name of list to return
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1515 @type str (must be 'search' or 'replace')
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1516 @return the requested history list
4666
bc52ef526e11 Generated the source docu for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4665
diff changeset
1517 @rtype list of tuples of (int, str)
4659
2863d05e83c6 Improved the search/replace history handling of the hex editor and added input validators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4658
diff changeset
1518 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1519 if key in ["search", "replace"]:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
1520 return self.__srHistory[key]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1521
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
1522 return []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1523
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1524 @pyqtSlot()
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1525 def __showFileMenu(self):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1526 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1527 Private slot to modify the file menu before being shown.
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1528 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1529 self.__menuRecentAct.setEnabled(len(self.__recent) > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1530
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1531 @pyqtSlot()
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1532 def __showRecentMenu(self):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1533 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1534 Private slot to set up the recent files menu.
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1535 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1536 self.__loadRecent()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1537
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1538 self.__recentMenu.clear()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1539
8220
006ee31b4835 Applied some more code simplifications suggested by the new Simplify checker (Y113: use enumerate()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
1540 for idx, rs in enumerate(self.__recent, start=1):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1541 formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}"
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1542 act = self.__recentMenu.addAction(
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1543 formatStr.format(
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
1544 idx,
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
1545 FileSystemUtilities.compactPath(
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
1546 rs, HexEditMainWindow.maxMenuFilePathLen
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
1547 ),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1548 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1549 )
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1550 act.setData(rs)
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1551 act.setEnabled(pathlib.Path(rs).exists())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1552
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1553 self.__recentMenu.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1554 self.__recentMenu.addAction(self.tr("&Clear"), self.__clearRecent)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1555
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1556 @pyqtSlot(QAction)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1557 def __openRecentHexFile(self, act):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1558 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1559 Private method to open a file from the list of recently opened files.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1560
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1561 @param act reference to the action that triggered (QAction)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1562 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1563 fileName = act.data()
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1564 if fileName and self.__maybeSave():
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1565 self.__loadHexFile(fileName)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1566 self.__editor.setReadOnly(Preferences.getHexEditor("OpenReadOnly"))
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1567 self.__checkActions()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1568
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1569 @pyqtSlot()
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1570 def __clearRecent(self):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1571 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1572 Private method to clear the list of recently opened files.
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1573 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1574 self.__recent = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1575
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1576 def __loadRecent(self):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1577 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1578 Private method to load the list of recently opened files.
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1579 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1580 self.__recent = []
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1581 Preferences.Prefs.rsettings.sync()
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1582 rs = Preferences.Prefs.rsettings.value(recentNameHexFiles)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1583 if rs is not None:
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1584 for f in Preferences.toList(rs):
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
1585 if pathlib.Path(f).exists():
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1586 self.__recent.append(f)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1587
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1588 def __saveRecent(self):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1589 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1590 Private method to save the list of recently opened files.
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1591 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1592 Preferences.Prefs.rsettings.setValue(recentNameHexFiles, self.__recent)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1593 Preferences.Prefs.rsettings.sync()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1594
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1595 def __addToRecentList(self, fileName):
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1596 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1597 Private method to add a file name to the list of recently opened files.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1598
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1599 @param fileName name of the file to be added
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1600 """
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1601 if fileName:
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1602 for recent in self.__recent[:]:
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
1603 if FileSystemUtilities.samepath(fileName, recent):
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1604 self.__recent.remove(recent)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1605 self.__recent.insert(0, fileName)
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1606 maxRecent = Preferences.getHexEditor("RecentNumber")
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1607 if len(self.__recent) > maxRecent:
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1608 self.__recent = self.__recent[:maxRecent]
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4687
diff changeset
1609 self.__saveRecent()

eric ide

mercurial