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