Tue, 12 Nov 2024 18:01:04 +0100
Added a configuration entry on the Qt page to enter the path of the 'lrelease' program for that cases, where it cannot be detected automatically (e.g. due to different name).
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10428
diff
changeset
|
3 | # Copyright (c) 2016 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | Module implementing the Hex Editor configuration page. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
12 | from PyQt6.QtWidgets import QFontDialog |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
14 | from eric7 import Preferences |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | from .ConfigurationPageBase import ConfigurationPageBase |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from .Ui_HexEditorPage import Ui_HexEditorPage |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | class HexEditorPage(ConfigurationPageBase, Ui_HexEditorPage): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | Class implementing the Hex Editor configuration page. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | def __init__(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Constructor |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
29 | super().__init__() |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.setupUi(self) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.setObjectName("HexEditorPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | # set initial values |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | self.readOnlyCheckBox.setChecked(Preferences.getHexEditor("OpenReadOnly")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | self.overwriteCheckBox.setChecked( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | Preferences.getHexEditor("OpenInOverwriteMode") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | self.addressAreaCheckBox.setChecked(Preferences.getHexEditor("ShowAddressArea")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | self.addressAreaWidthSpinBox.setValue( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | Preferences.getHexEditor("AddressAreaWidth") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | self.asciiAreaCheckBox.setChecked(Preferences.getHexEditor("ShowAsciiArea")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | self.highlightingCheckBox.setChecked( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | Preferences.getHexEditor("HighlightChanges") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | self.recentFilesSpinBox.setValue(Preferences.getHexEditor("RecentNumber")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | # font |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | self.monospacedFont = Preferences.getHexEditor("Font") |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | self.monospacedFontSample.setFont(self.monospacedFont) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | def save(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | Public slot to save the IRC configuration. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | Preferences.setHexEditor("OpenReadOnly", self.readOnlyCheckBox.isChecked()) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | Preferences.setHexEditor( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | "OpenInOverwriteMode", self.overwriteCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | ) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | Preferences.setHexEditor( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | "ShowAddressArea", self.addressAreaCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | ) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Preferences.setHexEditor( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | "AddressAreaWidth", self.addressAreaWidthSpinBox.value() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | Preferences.setHexEditor("ShowAsciiArea", self.asciiAreaCheckBox.isChecked()) |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | Preferences.setHexEditor( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | "HighlightChanges", self.highlightingCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | Preferences.setHexEditor("Font", self.monospacedFont) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | Preferences.setHexEditor("RecentNumber", self.recentFilesSpinBox.value()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | @pyqtSlot() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | def on_monospacedFontButton_clicked(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | Private method used to select the font to be used. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.monospacedFont = self.selectFont( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | self.monospacedFontSample, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | self.monospacedFont, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | options=QFontDialog.FontDialogOption.MonospacedFonts, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
82 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | def polishPage(self): |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | Public slot to perform some polishing actions. |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.monospacedFontSample.setFont(self.monospacedFont) |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
91 | def create(_dlg): |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | Module function to create the configuration page. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
95 | @param _dlg reference to the configuration dialog (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
96 | @type ConfigurationDialog |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
97 | @return reference to the instantiated page |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
98 | @rtype ConfigurationPageBase |
4658
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | """ |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | page = HexEditorPage() |
d760763dcc4a
Created a configuration page for the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | return page |