Mon, 11 Jan 2016 19:46:19 +0100
Improved the search/replace history handling of the hex editor and added input validators.
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 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
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 | from __future__ import unicode_literals |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import os |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
14 | from PyQt5.QtCore import pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, \ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
15 | QCoreApplication |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | from PyQt5.QtGui import QKeySequence |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
17 | from PyQt5.QtWidgets import QWhatsThis, QLabel, QWidget, QVBoxLayout, \ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
18 | QDialog, QAction |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | from E5Gui.E5Action import E5Action |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | from E5Gui.E5MainWindow import E5MainWindow |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | from E5Gui import E5FileDialog, E5MessageBox |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | 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
|
25 | from .HexEditSearchReplaceWidget import HexEditSearchReplaceWidget |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | import UI.PixmapCache |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | import UI.Config |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | import Preferences |
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 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | class HexEditMainWindow(E5MainWindow): |
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 | 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
|
36 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @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
|
38 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | editorClosed = pyqtSignal() |
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 | windows = [] |
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 | 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
|
44 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | Constructor |
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 | @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
|
48 | @param parent parent widget of this window (QWidget) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @keyparam fromEric flag indicating whether it was called from within |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | eric6 (boolean) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @keyparam project reference to the project object (Project) |
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 | super(HexEditMainWindow, self).__init__(parent) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.setObjectName("eric6_hex_editor") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
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
|
56 | 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
|
57 | "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
|
58 | # 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
|
59 | # 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
|
60 | "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
|
61 | # 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
|
62 | # 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
|
63 | } |
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 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
65 | self.__fromEric = fromEric |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.setWindowIcon(UI.PixmapCache.getIcon("hexEditor.png")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
68 | if not self.__fromEric: |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.setStyle(Preferences.getUI("Style"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | Preferences.getUI("StyleSheet")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | self.__editor, self, True) |
4652
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
77 | cw = QWidget() |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
78 | layout = QVBoxLayout(cw) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
79 | 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
|
80 | layout.setSpacing(1) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
81 | layout.addWidget(self.__editor) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
82 | layout.addWidget(self.__searchWidget) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
83 | cw.setLayout(layout) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
84 | layout.addWidget(self.__replaceWidget) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
85 | self.__searchWidget.hide() |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
86 | self.__replaceWidget.hide() |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
87 | self.setCentralWidget(cw) |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | g = Preferences.getGeometry("HexEditorGeometry") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | if g.isEmpty(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | s = QSize(600, 500) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | self.resize(s) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | self.restoreGeometry(g) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | self.__initActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | self.__initMenus() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | self.__initToolbars() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | self.__createStatusBar() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | self.__class__.windows.append(self) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | |
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
|
103 | 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
|
104 | 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
|
105 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | self.__editor.currentAddressChanged.connect(self.__showAddress) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | self.__editor.currentSizeChanged.connect(self.__showSize) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | self.__editor.dataChanged.connect(self.__modificationChanged) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | self.__editor.overwriteModeChanged.connect(self.__showEditMode) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | 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
|
111 | 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
|
112 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
113 | self.preferencesChanged() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
114 | self.__editor.setOverwriteMode( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
115 | Preferences.getHexEditor("OpenInOverwriteMode")) |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.__project = project |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | self.__lastOpenPath = "" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.__lastSavePath = "" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | self.__setCurrentFile("") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | if fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | self.__loadHexFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | def __initActions(self): |
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 | 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
|
130 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | # list of all actions |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | self.__actions = [] |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | self.__initFileActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | self.__initEditActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | self.__initHelpActions() |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
137 | if not self.__fromEric: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
138 | self.__initConfigActions() |
4650
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 | def __initFileActions(self): |
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 | 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
|
143 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | self.newWindowAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.tr('New Window'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | UI.PixmapCache.getIcon("newWindow.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | self.tr('New &Window'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | 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
|
149 | self.newWindowAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | '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
|
151 | self.newWindowAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | """<b>New Window</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | """<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
|
154 | """ window.</p>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | self.newWindowAct.triggered.connect(self.__openHexFileNewWindow) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | self.__actions.append(self.newWindowAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
159 | # correct texts will be set later |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.openAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | self.tr('Open'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | UI.PixmapCache.getIcon("open.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | self.tr('&Open...'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | 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
|
165 | 0, self, 'hexEditor_file_open') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.openAct.triggered.connect(self.__openHexFile) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | self.__actions.append(self.openAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
169 | # correct texts will be set later |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | self.openReadOnlyAct = E5Action( |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
171 | "", "", |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | 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
|
173 | self.openReadOnlyAct.triggered.connect(self.__openHexFileReadOnly) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | self.__actions.append(self.openReadOnlyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | self.saveAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | self.tr('Save'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | UI.PixmapCache.getIcon("fileSave.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | self.tr('&Save'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | 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
|
181 | 0, self, 'hexEditor_file_save') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | 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
|
183 | self.saveAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """<b>Save File</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | """<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
|
186 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | self.saveAct.triggered.connect(self.__saveHexFile) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | self.__actions.append(self.saveAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | self.saveAsAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | self.tr('Save As'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | UI.PixmapCache.getIcon("fileSaveAs.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | self.tr('Save &As...'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | 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
|
195 | 0, self, 'hexEditor_file_save_as') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | self.saveAsAct.setStatusTip( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | 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
|
198 | self.saveAsAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | """<b>Save As...</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | """<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
|
201 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | self.saveAsAct.triggered.connect(self.__saveHexFileAs) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | self.__actions.append(self.saveAsAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.saveReadableAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | self.tr('Save As Readable'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | self.tr('Save As &Readable...'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | 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
|
209 | self.saveReadableAct.setStatusTip( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | 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
|
211 | ' format')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | self.saveReadableAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | """<b>Save As Readable...</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | """<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
|
215 | """ format.</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.saveReadableAct.triggered.connect(self.__saveHexFileReadable) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | self.__actions.append(self.saveReadableAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | self.closeAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | self.tr('Close'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | UI.PixmapCache.getIcon("close.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | self.tr('&Close'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | 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
|
225 | 0, self, 'hexEditor_file_close') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | self.closeAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | 'Close the current hex editor window')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | self.closeAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | """<b>Close</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | """<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
|
231 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.closeAct.triggered.connect(self.close) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | self.__actions.append(self.closeAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | self.closeAllAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | self.tr('Close All'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | self.tr('Close &All'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | 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
|
239 | self.closeAllAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | 'Close all hex editor windows')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | self.closeAllAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | """<b>Close All</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | """<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
|
244 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | self.closeAllAct.triggered.connect(self.__closeAll) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | self.__actions.append(self.closeAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | self.closeOthersAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | self.tr('Close Others'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | self.tr('Close Others'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | 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
|
252 | self.closeOthersAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | 'Close all hex other editor windows')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | self.closeOthersAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | """<b>Close Others</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | """<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
|
257 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | self.closeOthersAct.triggered.connect(self.__closeOthers) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | self.__actions.append(self.closeOthersAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | self.exitAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | self.tr('Quit'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | UI.PixmapCache.getIcon("exit.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | self.tr('&Quit'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | 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
|
266 | 0, self, 'hexEditor_file_quit') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | 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
|
268 | self.exitAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | """<b>Quit</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | """<p>Quit the hex editor.</p>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | )) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
272 | if not self.__fromEric: |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | self.exitAct.triggered.connect(self.__closeAll) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | self.__actions.append(self.exitAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | def __initEditActions(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | 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
|
279 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | self.undoAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | self.tr('Undo'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | UI.PixmapCache.getIcon("editUndo.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | self.tr('&Undo'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | 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
|
285 | 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
|
286 | self, 'hexEditor_edit_undo') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | 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
|
288 | self.undoAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | """<b>Undo</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | """<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
|
291 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | 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
|
293 | self.__actions.append(self.undoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | self.redoAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | self.tr('Redo'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | UI.PixmapCache.getIcon("editRedo.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | self.tr('&Redo'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | 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
|
300 | 0, self, 'hexEditor_edit_redo') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | 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
|
302 | self.redoAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | """<b>Redo</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | """<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
|
305 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | 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
|
307 | self.__actions.append(self.redoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | self.revertAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | 0, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | self, 'hexEditor_edit_revert') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | 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
|
316 | self.revertAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | """<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
|
318 | """<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
|
319 | """ editor.</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.revertAct.triggered.connect(self.__editor.revertToUnmodified) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | self.__actions.append(self.revertAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | self.cutAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | self.tr('Cut'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | UI.PixmapCache.getIcon("editCut.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | self.tr('Cu&t'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | 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
|
329 | 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
|
330 | self, 'hexEditor_edit_cut') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | 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
|
332 | self.cutAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | """<b>Cut</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | """<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
|
335 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | 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
|
337 | self.__actions.append(self.cutAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | self.copyAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | self.tr('Copy'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | UI.PixmapCache.getIcon("editCopy.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | self.tr('&Copy'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | 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
|
344 | 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
|
345 | self, 'hexEditor_edit_copy') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | 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
|
347 | self.copyAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | """<b>Copy</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | """<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
|
350 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | 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
|
352 | self.__actions.append(self.copyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | self.pasteAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | self.tr('Paste'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | UI.PixmapCache.getIcon("editPaste.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | self.tr('&Paste'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | 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
|
359 | 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
|
360 | self, 'hexEditor_edit_paste') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | 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
|
362 | self.pasteAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | """<b>Paste</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | """<p>Paste the clipboard contents.</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.pasteAct.triggered.connect(self.__editor.paste) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | self.__actions.append(self.pasteAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
368 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | self.selectAllAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | self.tr('Select All'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | UI.PixmapCache.getIcon("editSelectAll.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | self.tr('&Select All'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
373 | 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
|
374 | 0, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | self, 'hexEditor_edit_select_all') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | self.selectAllAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | 'Select the complete binary data')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | self.selectAllAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | """<b>Select All</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | """<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
|
381 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | 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
|
383 | self.__actions.append(self.selectAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | self.deselectAllAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | self.tr('Deselect all'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | self.tr('&Deselect all'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | 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
|
389 | 0, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | self, 'hexEditor_edit_deselect_all') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | 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
|
392 | self.deselectAllAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | """<b>Deselect All</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | """<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
|
395 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | 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
|
397 | self.__actions.append(self.deselectAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | self.saveSelectionReadableAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
400 | self.tr('Save Selection Readable'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | self.tr('Save Selection Readable...'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | 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
|
403 | self.saveSelectionReadableAct.setStatusTip( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
404 | 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
|
405 | ' in a readable format')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
406 | self.saveSelectionReadableAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
407 | """<b>Save Selection Readable...</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
408 | """<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
|
409 | """ in a readable format.</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.saveSelectionReadableAct.triggered.connect( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
412 | self.__saveSelectionReadable) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | self.__actions.append(self.saveSelectionReadableAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | self.readonlyAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
416 | self.tr('Set Read Only'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | self.tr('Set Read Only'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | 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
|
419 | self.readonlyAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | '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
|
421 | self.readonlyAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | """<b>Set Read Only</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
423 | """<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
|
424 | """ mode).</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.readonlyAct.setChecked(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
427 | 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
|
428 | 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
|
429 | self.__actions.append(self.readonlyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | |
4652
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
431 | self.searchAct = E5Action( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
432 | self.tr('Search'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
433 | UI.PixmapCache.getIcon("find.png"), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
434 | self.tr('&Search...'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
435 | 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
|
436 | 0, |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
437 | self, 'hexEditor_edit_search') |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
438 | self.searchAct.setStatusTip(self.tr('Search for a text')) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
439 | 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
|
440 | """<b>Search</b>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
441 | """<p>Search for some text in the current editor. A""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
442 | """ dialog is shown to enter the searchtext and options""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
443 | """ for the search.</p>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
444 | )) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
445 | 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
|
446 | 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
|
447 | |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
448 | self.searchNextAct = E5Action( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
449 | self.tr('Search next'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
450 | UI.PixmapCache.getIcon("findNext.png"), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
451 | self.tr('Search &next'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
452 | 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
|
453 | 0, |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
454 | 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
|
455 | self.searchNextAct.setStatusTip(self.tr( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
456 | 'Search next occurrence of text')) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
457 | 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
|
458 | """<b>Search next</b>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
459 | """<p>Search the next occurrence of some text in the current""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
460 | """ editor. The previously entered searchtext and options are""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
461 | """ reused.</p>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
462 | )) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
463 | 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
|
464 | 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
|
465 | |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
466 | self.searchPrevAct = E5Action( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
467 | self.tr('Search previous'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
468 | UI.PixmapCache.getIcon("findPrev.png"), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
469 | self.tr('Search &previous'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
470 | 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
|
471 | 0, |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
472 | 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
|
473 | self.searchPrevAct.setStatusTip(self.tr( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
474 | 'Search previous occurrence of text')) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
475 | 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
|
476 | """<b>Search previous</b>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
477 | """<p>Search the previous occurrence of some text in the current""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
478 | """ editor. The previously entered searchtext and options are""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
479 | """ reused.</p>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
480 | )) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
481 | self.searchPrevAct.triggered.connect( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
482 | 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
|
483 | 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
|
484 | |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
485 | self.replaceAct = E5Action( |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
486 | self.tr('Replace'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
487 | self.tr('&Replace...'), |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
488 | 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
|
489 | 0, |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
490 | self, 'hexEditor_edit_search_replace') |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
491 | self.replaceAct.setStatusTip(self.tr('Replace some text')) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
492 | 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
|
493 | """<b>Replace</b>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
494 | """<p>Search for some text in the current editor and replace it.""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
495 | """ A dialog is shown to enter the searchtext, the replacement""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
496 | """ text and options for the search and replace.</p>""" |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
497 | )) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
498 | 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
|
499 | 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
|
500 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
501 | self.redoAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | 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
|
503 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | self.undoAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | 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
|
506 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
507 | self.revertAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
508 | 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
|
509 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
510 | self.cutAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
511 | self.copyAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
512 | self.saveSelectionReadableAct.setEnabled(False) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | self.__editor.selectionAvailable.connect(self.__checkActions) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | 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
|
515 | self.__editor.selectionAvailable.connect( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
516 | self.saveSelectionReadableAct.setEnabled) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
517 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
518 | def __initHelpActions(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | 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
|
521 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
522 | self.aboutAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
523 | self.tr('About'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
524 | self.tr('&About'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
525 | 0, 0, self, 'hexEditor_help_about') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
526 | self.aboutAct.setStatusTip(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | 'Display information about this software')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
528 | self.aboutAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
529 | """<b>About</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
530 | """<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
|
531 | self.aboutAct.triggered.connect(self.__about) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | self.__actions.append(self.aboutAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
534 | self.aboutQtAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | self.tr('About Qt'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | self.tr('About &Qt'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
537 | 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
|
538 | self.aboutQtAct.setStatusTip( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | 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
|
540 | self.aboutQtAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
541 | """<b>About Qt</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
542 | """<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
|
543 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
544 | self.aboutQtAct.triggered.connect(self.__aboutQt) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
545 | self.__actions.append(self.aboutQtAct) |
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 | self.whatsThisAct = E5Action( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
548 | self.tr('What\'s This?'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
549 | UI.PixmapCache.getIcon("whatsThis.png"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
550 | self.tr('&What\'s This?'), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
551 | 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
|
552 | 0, self, 'hexEditor_help_whats_this') |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | 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
|
554 | self.whatsThisAct.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
555 | """<b>Display context sensitive help</b>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
556 | """<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
|
557 | """ 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
|
558 | """ 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
|
559 | """ 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
|
560 | """ 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
|
561 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
562 | self.whatsThisAct.triggered.connect(self.__whatsThis) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
563 | self.__actions.append(self.whatsThisAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
564 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
565 | def __initConfigActions(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
566 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
567 | 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
|
568 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
569 | self.prefAct = E5Action( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
570 | self.tr('Preferences'), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
571 | UI.PixmapCache.getIcon("configure.png"), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
572 | self.tr('&Preferences...'), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
573 | 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
|
574 | self.prefAct.setStatusTip(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
575 | 'Set the prefered configuration')) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
576 | self.prefAct.setWhatsThis(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
577 | """<b>Preferences</b>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
578 | """<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
|
579 | """ with your prefered values.</p>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
580 | )) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
581 | self.prefAct.triggered.connect(self.__showPreferences) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
582 | self.prefAct.setMenuRole(QAction.PreferencesRole) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
583 | self.__actions.append(self.prefAct) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
584 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
585 | def __setReadOnlyActionTexts(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
586 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
587 | 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
|
588 | 'read only' and 'read write'. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
589 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
590 | if Preferences.getHexEditor("OpenReadOnly"): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
591 | self.openAct.setStatusTip(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
592 | '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
|
593 | self.openAct.setWhatsThis(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
594 | """<b>Open File</b>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
595 | """<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
|
596 | """ 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
|
597 | )) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
598 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
599 | 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
|
600 | 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
|
601 | self.openReadOnlyAct.setStatusTip(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
602 | '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
|
603 | self.openReadOnlyAct.setWhatsThis(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
604 | """<b>Open for Editing</b>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
605 | """<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
|
606 | """ 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
|
607 | )) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
608 | else: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
609 | self.openAct.setStatusTip(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
610 | '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
|
611 | self.openAct.setWhatsThis(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
612 | """<b>Open File</b>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
613 | """<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
|
614 | """ 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
|
615 | )) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
616 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
617 | 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
|
618 | 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
|
619 | self.openReadOnlyAct.setStatusTip(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
620 | '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
|
621 | self.openReadOnlyAct.setWhatsThis(self.tr( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
622 | """<b>Open Read Only</b>""" |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
623 | """<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
|
624 | """ 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
|
625 | )) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
626 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
627 | def __initMenus(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
628 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
629 | Private method to create the menus. |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
630 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
631 | mb = self.menuBar() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
632 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
633 | menu = mb.addMenu(self.tr('&File')) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
634 | menu.setTearOffEnabled(True) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
635 | menu.addAction(self.newWindowAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | menu.addAction(self.openAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
637 | menu.addAction(self.openReadOnlyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
638 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
639 | menu.addAction(self.saveAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
640 | menu.addAction(self.saveAsAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
641 | menu.addAction(self.saveReadableAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
642 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
643 | menu.addAction(self.closeAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
644 | menu.addAction(self.closeOthersAct) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
645 | if self.__fromEric: |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
646 | menu.addAction(self.closeAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
647 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
648 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
649 | menu.addAction(self.exitAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
650 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
651 | menu = mb.addMenu(self.tr("&Edit")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
652 | menu.setTearOffEnabled(True) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
653 | menu.addAction(self.undoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
654 | menu.addAction(self.redoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
655 | menu.addAction(self.revertAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
656 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
657 | menu.addAction(self.cutAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
658 | menu.addAction(self.copyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
659 | menu.addAction(self.pasteAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
660 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
661 | menu.addAction(self.selectAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | menu.addAction(self.deselectAllAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
663 | menu.addAction(self.saveSelectionReadableAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
664 | menu.addSeparator() |
4652
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
665 | menu.addAction(self.searchAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
666 | menu.addAction(self.searchNextAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
667 | menu.addAction(self.searchPrevAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
668 | menu.addAction(self.replaceAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
669 | menu.addSeparator() |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | menu.addAction(self.readonlyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
672 | if not self.__fromEric: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
673 | 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
|
674 | menu.setTearOffEnabled(True) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
675 | menu.addAction(self.prefAct) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
676 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
677 | mb.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
678 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
679 | menu = mb.addMenu(self.tr("&Help")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | menu.addAction(self.aboutAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
681 | menu.addAction(self.aboutQtAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
682 | menu.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
683 | menu.addAction(self.whatsThisAct) |
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 | def __initToolbars(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
686 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
687 | Private method to create the toolbars. |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
688 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
689 | filetb = self.addToolBar(self.tr("File")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
690 | filetb.setObjectName("FileToolBar") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
691 | filetb.setIconSize(UI.Config.ToolBarIconSize) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
692 | filetb.addAction(self.newWindowAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
693 | filetb.addAction(self.openAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
694 | filetb.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
695 | filetb.addAction(self.saveAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
696 | filetb.addAction(self.saveAsAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
697 | filetb.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
698 | filetb.addAction(self.closeAct) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
699 | if not self.__fromEric: |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
700 | filetb.addAction(self.exitAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
701 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
702 | edittb = self.addToolBar(self.tr("Edit")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
703 | edittb.setObjectName("EditToolBar") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
704 | edittb.setIconSize(UI.Config.ToolBarIconSize) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
705 | edittb.addAction(self.undoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | edittb.addAction(self.redoAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
707 | edittb.addSeparator() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | edittb.addAction(self.cutAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
709 | edittb.addAction(self.copyAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
710 | edittb.addAction(self.pasteAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
711 | |
4652
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
712 | 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
|
713 | searchtb.setObjectName("SearchToolBar") |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
714 | 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
|
715 | searchtb.addAction(self.searchAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
716 | searchtb.addAction(self.searchNextAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
717 | searchtb.addAction(self.searchPrevAct) |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
718 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
719 | if not self.__fromEric: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
720 | 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
|
721 | settingstb.setObjectName("SettingsToolBar") |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
722 | settingstb.setIconSize(UI.Config.ToolBarIconSize) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
723 | settingstb.addAction(self.prefAct) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
724 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
725 | helptb = self.addToolBar(self.tr("Help")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
726 | helptb.setObjectName("HelpToolBar") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
727 | helptb.setIconSize(UI.Config.ToolBarIconSize) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
728 | helptb.addAction(self.whatsThisAct) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
729 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
730 | def __createStatusBar(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
731 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
732 | 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
|
733 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
734 | self.__statusBar = self.statusBar() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
735 | self.__statusBar.setSizeGripEnabled(True) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
736 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
737 | self.__sbEditMode = QLabel(self.__statusBar) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
738 | self.__statusBar.addPermanentWidget(self.__sbEditMode) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
739 | self.__sbEditMode.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
740 | """<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
|
741 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
742 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
743 | self.__sbReadOnly = QLabel(self.__statusBar) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
744 | self.__statusBar.addPermanentWidget(self.__sbReadOnly) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
745 | self.__sbReadOnly.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
746 | """<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
|
747 | """ only mode.</p>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
748 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
749 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
750 | self.__sbAddress = QLabel(self.__statusBar) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
751 | self.__statusBar.addPermanentWidget(self.__sbAddress) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
752 | self.__sbAddress.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
753 | """<p>This part of the status bar displays the cursor""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
754 | """ address.</p>""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
755 | )) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
756 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
757 | self.__showEditMode(self.__editor.overwriteMode()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
758 | self.__showReadOnlyMode(self.__editor.isReadOnly()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
759 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
760 | self.__sbSize = QLabel(self.__statusBar) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
761 | self.__statusBar.addPermanentWidget(self.__sbSize) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
762 | self.__sbSize.setWhatsThis(self.tr( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
763 | """<p>This part of the status bar displays the size of the""" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
764 | """ binary data.</p>""" |
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 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
767 | @pyqtSlot(int) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
768 | def __showAddress(self, address): |
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 | 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
|
771 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
772 | @param address address of the cursor |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
773 | @type int |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
774 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
775 | self.__sbAddress.setText(self.tr("Address: {0:#x}").format(address)) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
776 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
777 | @pyqtSlot(bool) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
778 | def __showReadOnlyMode(self, on): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
779 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
780 | 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
|
781 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
782 | @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
|
783 | @type bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
784 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
785 | 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
|
786 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
787 | @pyqtSlot(bool) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
788 | def __showEditMode(self, overwrite): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
789 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
790 | 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
|
791 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
792 | @param overwrite flag indicating overwrite mode |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
793 | @type bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
794 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
795 | self.__sbEditMode.setText( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
796 | 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
|
797 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
798 | @pyqtSlot(int) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
799 | def __showSize(self, size): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
800 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
801 | 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
|
802 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
803 | @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
|
804 | @type int |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
805 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
806 | self.__sbSize.setText(self.tr("Size: {0:n}").format(size)) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
807 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
808 | def closeEvent(self, evt): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
809 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
810 | 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
|
811 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
812 | @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
|
813 | <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
|
814 | 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
|
815 | @type QCloseEvent |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
816 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
821 | Preferences.setGeometry("HexEditorGeometry", self.saveGeometry()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
822 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
823 | try: |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
824 | 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
|
825 | del self.__class__.windows[ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
826 | self.__class__.windows.index(self)] |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
827 | except ValueError: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
828 | pass |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
829 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
830 | if not self.__fromEric: |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
831 | Preferences.syncPreferences() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
832 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
833 | evt.accept() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
834 | self.editorClosed.emit() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
835 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
836 | evt.ignore() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
837 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
838 | def __openHexFileNewWindow(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
839 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
840 | 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
|
841 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
842 | if not self.__lastOpenPath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
843 | if self.__project and self.__project.isOpen(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
844 | self.__lastOpenPath = self.__project.getProjectPath() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
845 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
846 | fileName = E5FileDialog.getOpenFileName( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
847 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
848 | 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
|
849 | self.__lastOpenPath, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
850 | self.tr("All Files (*)")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
851 | if fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
852 | he = HexEditMainWindow(fileName=fileName, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
853 | parent=self.parent(), |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
854 | fromEric=self.__fromEric, |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
855 | project=self.__project) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
856 | he.setRecentPaths("", self.__lastSavePath) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
857 | he.show() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
858 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
859 | def __maybeSave(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
860 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
861 | 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
|
862 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
863 | @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
|
864 | @rtype bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
865 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
866 | if self.__editor.isModified(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
867 | ret = E5MessageBox.okToClearData( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
868 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
869 | self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
870 | 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
|
871 | self.__saveHexFile) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
872 | if not ret: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
873 | return False |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
874 | return True |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
875 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
876 | def __loadHexFile(self, fileName): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
877 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
878 | Private method to load a binary file. |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
879 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
880 | @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
|
881 | @type str |
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 | file = QFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
884 | if not file.exists(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
885 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
886 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
887 | 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
|
888 | .format(fileName)) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
889 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
890 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
891 | if not file.open(QFile.ReadOnly): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
892 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
893 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
894 | 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
|
895 | .format(fileName, file.errorString())) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
896 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
897 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
898 | data = file.readAll() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
899 | file.close() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
900 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
901 | self.__lastOpenPath = os.path.dirname(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
902 | self.__editor.setData(data) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
903 | self.__setCurrentFile(fileName) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
904 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
905 | self.__editor.setReadOnly(Preferences.getHexEditor("OpenReadOnly")) |
4650
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
906 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
907 | def __openHexFile(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
908 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
909 | 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
|
910 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
911 | if self.__maybeSave(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
912 | if not self.__lastOpenPath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
913 | if self.__project and self.__project.isOpen(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
914 | self.__lastOpenPath = self.__project.getProjectPath() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
915 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
916 | fileName = E5FileDialog.getOpenFileName( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
917 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
918 | self.tr("Open binary file"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
919 | self.__lastOpenPath, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
920 | self.tr("All Files (*)")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
921 | if fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
922 | self.__loadHexFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
923 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
924 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
925 | def __openHexFileReadOnly(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
926 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
927 | 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
|
928 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
929 | self.__openHexFile() |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
930 | 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
|
931 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
932 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
933 | def __saveHexFile(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
934 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
935 | 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
|
936 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
937 | @return flag indicating success |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
938 | @rtype bool |
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 | if not self.__fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
941 | ok = self.__saveHexFileAs() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
942 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
943 | ok = self.__saveHexDataFile(self.__fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
944 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
945 | if ok: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
946 | self.__editor.undoStack().setClean() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
947 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
948 | return ok |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
949 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
950 | def __saveHexFileAs(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
951 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
952 | 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
|
953 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
954 | @return flag indicating success |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
955 | @rtype bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
956 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
957 | if not self.__lastSavePath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
958 | if self.__project and self.__project.isOpen(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
959 | self.__lastSavePath = self.__project.getProjectPath() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
960 | 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
|
961 | self.__lastSavePath = self.__lastOpenPath |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
962 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
963 | fileName = E5FileDialog.getSaveFileName( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
964 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
965 | self.tr("Save binary file"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
966 | self.__lastSavePath, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
967 | self.tr("All Files (*)"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
968 | E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
969 | if not fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
970 | return False |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
971 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
972 | if QFileInfo(fileName).exists(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
973 | res = E5MessageBox.yesNo( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
974 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
975 | self.tr("Save binary file"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
976 | 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
|
977 | " Overwrite it?</p>").format(fileName), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
978 | icon=E5MessageBox.Warning) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
979 | if not res: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
980 | return False |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
981 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
982 | self.__lastSavePath = os.path.dirname(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
983 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
984 | return self.__saveHexDataFile(fileName) |
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 | def __saveHexDataFile(self, fileName): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
987 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
988 | 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
|
989 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
990 | @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
|
991 | @type str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
992 | @return flag indicating success |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
993 | @rtype bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
994 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
995 | file = QFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
996 | if not file.open(QFile.WriteOnly): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
997 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
998 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
999 | 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
|
1000 | .format(fileName, file.errorString())) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1001 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1002 | self.__checkActions() |
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 | return False |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1005 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1006 | 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
|
1007 | file.close() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1008 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1009 | if not res: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1010 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1011 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1012 | 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
|
1013 | .format(fileName, file.errorString())) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1014 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1015 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1016 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1017 | return False |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1018 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1019 | self.__editor.setModified(False, setCleanState=True) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1020 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1021 | self.__setCurrentFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1022 | 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
|
1023 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1024 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1025 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1026 | return True |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1027 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1028 | def __saveHexFileReadable(self, selectionOnly=False): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1029 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1030 | 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
|
1031 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1032 | @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
|
1033 | @type bool |
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 | savePath = self.__lastSavePath |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1036 | if not savePath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1037 | if self.__project and self.__project.isOpen(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1038 | savePath = self.__project.getProjectPath() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1039 | if not savePath and self.__lastOpenPath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1040 | savePath = self.__lastOpenPath |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1041 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1042 | fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1043 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1044 | self.tr("Save to readable file"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1045 | savePath, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1046 | 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
|
1047 | self.tr("Text Files (*.txt)"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1048 | E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1049 | if not fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1050 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1051 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1052 | ext = QFileInfo(fileName).suffix() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1053 | if not ext: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1054 | ex = selectedFilter.split("(*")[1].split(")")[0] |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1055 | if ex: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1056 | fileName += ex |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1057 | if QFileInfo(fileName).exists(): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1058 | res = E5MessageBox.yesNo( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1059 | self, |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1060 | self.tr("Save to readable file"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1061 | 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
|
1062 | " Overwrite it?</p>").format(fileName), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1063 | icon=E5MessageBox.Warning) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1064 | if not res: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1065 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1066 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1067 | file = QFile(fileName) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1068 | if not file.open(QFile.WriteOnly): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1069 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1070 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1071 | 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
|
1072 | .format(fileName, file.errorString())) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1073 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1074 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1075 | if selectionOnly: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1076 | readableData = self.__editor.selectionToReadableString() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1077 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1078 | readableData = self.__editor.toReadableString() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1079 | 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
|
1080 | file.close() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1081 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1082 | if not res: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1083 | E5MessageBox.warning( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1084 | self, self.tr("eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1085 | 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
|
1086 | .format(fileName, file.errorString())) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1087 | return |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1088 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1089 | 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
|
1090 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1091 | def __saveSelectionReadable(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1092 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1093 | 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
|
1094 | format. |
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 | self.__saveHexFileReadable(selectionOnly=True) |
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 __closeAll(self): |
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 slot to close all windows. |
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 | self.__closeOthers() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1103 | self.close() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1104 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1105 | def __closeOthers(self): |
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 | 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
|
1108 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1109 | for win in self.__class__.windows[:]: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1110 | if win != self: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1111 | win.close() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1112 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1113 | def __setCurrentFile(self, fileName): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1114 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1115 | 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
|
1116 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1117 | @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
|
1118 | @type str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1119 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1120 | self.__fileName = fileName |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1121 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1122 | if not self.__fileName: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1123 | shownName = self.tr("Untitled") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1124 | else: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1125 | shownName = self.__strippedName(self.__fileName) |
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.setWindowTitle(self.tr("{0}[*] - {1}") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1128 | .format(shownName, self.tr("Hex Editor"))) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1129 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1130 | self.setWindowModified(self.__editor.isModified()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1131 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1132 | def __strippedName(self, fullFileName): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1133 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1134 | 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
|
1135 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1136 | @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
|
1137 | @type str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1138 | @return filename part |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1139 | @rtype str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1140 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1141 | return QFileInfo(fullFileName).fileName() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1142 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1143 | def setRecentPaths(self, openPath, savePath): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1144 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1145 | 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
|
1146 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1147 | @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
|
1148 | @type str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1149 | @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
|
1150 | @type str |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1151 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1152 | if openPath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1153 | self.__lastOpenPath = openPath |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1154 | if savePath: |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1155 | self.__lastSavePath = savePath |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1156 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1157 | @pyqtSlot() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1158 | def __checkActions(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1159 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1160 | 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
|
1161 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1162 | self.saveAct.setEnabled(self.__editor.isModified()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1163 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1164 | 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
|
1165 | self.__editor.hasSelection()) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1166 | 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
|
1167 | 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
|
1168 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1169 | @pyqtSlot(bool) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1170 | def __modificationChanged(self, m): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1171 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1172 | 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
|
1173 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1174 | @param m modification status |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1175 | @type bool |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1176 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1177 | self.setWindowModified(m) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1178 | self.__checkActions() |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1179 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1180 | def __about(self): |
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 | 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
|
1183 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1184 | E5MessageBox.about( |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1185 | self, self.tr("About eric6 Hex Editor"), |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1186 | self.tr("The eric6 Hex Editor is a simple editor component" |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1187 | " to edit binary files.")) |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1188 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1189 | def __aboutQt(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1190 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1191 | 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
|
1192 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1193 | E5MessageBox.aboutQt(self, "eric6 Hex Editor") |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1194 | |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1195 | def __whatsThis(self): |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1196 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1197 | 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
|
1198 | """ |
b1ca3bcde70b
First commit for the new hex editor tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1199 | QWhatsThis.enterWhatsThisMode() |
4652
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1200 | |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1201 | def __search(self): |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1202 | """ |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1203 | 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
|
1204 | """ |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1205 | self.__replaceWidget.hide() |
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
|
1206 | if self.__editor.hasSelection(): |
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
|
1207 | txt = self.__editor.selectionToHexString() |
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
|
1208 | else: |
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
|
1209 | txt = "" |
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
|
1210 | 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
|
1211 | |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1212 | def __replace(self): |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1213 | """ |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1214 | 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
|
1215 | """ |
a88a2ba7a48a
Added search and replace capability to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4651
diff
changeset
|
1216 | self.__searchWidget.hide() |
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
|
1217 | if self.__editor.hasSelection(): |
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
|
1218 | txt = self.__editor.selectionToHexString() |
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
|
1219 | else: |
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
|
1220 | txt = "" |
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
|
1221 | self.__replaceWidget.show(txt) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1222 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1223 | def preferencesChanged(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1224 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1225 | 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
|
1226 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1227 | self.__editor.setAddressWidth( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1228 | Preferences.getHexEditor("AddressAreaWidth")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1229 | self.__editor.setAddressArea( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1230 | Preferences.getHexEditor("ShowAddressArea")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1231 | self.__editor.setAsciiArea( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1232 | Preferences.getHexEditor("ShowAsciiArea")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1233 | self.__editor.setHighlighting( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1234 | Preferences.getHexEditor("HighlightChanges")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1235 | self.__editor.setHighlightColors( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1236 | Preferences.getHexEditor("HighlightingForeGround"), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1237 | Preferences.getHexEditor("HighlightingBackGround")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1238 | self.__editor.setSelectionColors( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1239 | Preferences.getHexEditor("SelectionForeGround"), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1240 | Preferences.getHexEditor("SelectionBackGround")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1241 | self.__editor.setAddressAreaColors( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1242 | Preferences.getHexEditor("AddressAreaForeGround"), |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1243 | Preferences.getHexEditor("AddressAreaBackGround")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1244 | self.__editor.setFont( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1245 | Preferences.getHexEditor("Font")) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1246 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1247 | self.__setReadOnlyActionTexts() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1248 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1249 | def __showPreferences(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1250 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1251 | 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
|
1252 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1253 | from Preferences.ConfigurationDialog import ConfigurationDialog |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1254 | dlg = ConfigurationDialog( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1255 | None, 'Configuration', True, fromEric=True, |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1256 | displayMode=ConfigurationDialog.HexEditorMode) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1257 | dlg.preferencesChanged.connect( |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1258 | self.__preferencesChangedByLocalPreferencesDialog) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1259 | dlg.show() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1260 | dlg.showConfigurationPageByName("hexEditorPage") |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1261 | dlg.exec_() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1262 | QCoreApplication.processEvents() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1263 | if dlg.result() == QDialog.Accepted: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1264 | dlg.setPreferences() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1265 | Preferences.syncPreferences() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1266 | self.__preferencesChangedByLocalPreferencesDialog() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1267 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1268 | def __preferencesChangedByLocalPreferencesDialog(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1269 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1270 | 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
|
1271 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1272 | for hexEditor in HexEditMainWindow.windows: |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4655
diff
changeset
|
1273 | 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
|
1274 | |
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
|
1275 | 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
|
1276 | """ |
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
|
1277 | 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
|
1278 | |
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
|
1279 | @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
|
1280 | @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
|
1281 | @return the requested 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
|
1282 | @type list of tuples of (int, str) |
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
|
1283 | """ |
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
|
1284 | assert key in ['search', '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
|
1285 | |
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
|
1286 | return self.__srHistory[key] |