src/eric7/Preferences/ConfigurationPages/HexEditorPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6
7 """
8 Module implementing the Hex Editor configuration page.
9 """
10
11 from PyQt6.QtCore import pyqtSlot
12 from PyQt6.QtWidgets import QFontDialog
13
14 from .ConfigurationPageBase import ConfigurationPageBase
15 from .Ui_HexEditorPage import Ui_HexEditorPage
16
17 import Preferences
18
19
20 class HexEditorPage(ConfigurationPageBase, Ui_HexEditorPage):
21 """
22 Class implementing the Hex Editor configuration page.
23 """
24 def __init__(self):
25 """
26 Constructor
27 """
28 super().__init__()
29 self.setupUi(self)
30 self.setObjectName("HexEditorPage")
31
32 # set initial values
33 self.readOnlyCheckBox.setChecked(Preferences.getHexEditor(
34 "OpenReadOnly"))
35 self.overwriteCheckBox.setChecked(Preferences.getHexEditor(
36 "OpenInOverwriteMode"))
37 self.addressAreaCheckBox.setChecked(Preferences.getHexEditor(
38 "ShowAddressArea"))
39 self.addressAreaWidthSpinBox.setValue(Preferences.getHexEditor(
40 "AddressAreaWidth"))
41 self.asciiAreaCheckBox.setChecked(Preferences.getHexEditor(
42 "ShowAsciiArea"))
43 self.highlightingCheckBox.setChecked(Preferences.getHexEditor(
44 "HighlightChanges"))
45 self.recentFilesSpinBox.setValue(Preferences.getHexEditor(
46 "RecentNumber"))
47
48 # font
49 self.monospacedFont = Preferences.getHexEditor("Font")
50 self.monospacedFontSample.setFont(self.monospacedFont)
51
52 def save(self):
53 """
54 Public slot to save the IRC configuration.
55 """
56 Preferences.setHexEditor(
57 "OpenReadOnly", self.readOnlyCheckBox.isChecked())
58 Preferences.setHexEditor(
59 "OpenInOverwriteMode", self.overwriteCheckBox.isChecked())
60 Preferences.setHexEditor(
61 "ShowAddressArea", self.addressAreaCheckBox.isChecked())
62 Preferences.setHexEditor(
63 "AddressAreaWidth", self.addressAreaWidthSpinBox.value())
64 Preferences.setHexEditor(
65 "ShowAsciiArea", self.asciiAreaCheckBox.isChecked())
66 Preferences.setHexEditor(
67 "HighlightChanges", self.highlightingCheckBox.isChecked())
68 Preferences.setHexEditor(
69 "Font", self.monospacedFont)
70 Preferences.setHexEditor(
71 "RecentNumber", self.recentFilesSpinBox.value())
72
73 @pyqtSlot()
74 def on_monospacedFontButton_clicked(self):
75 """
76 Private method used to select the font to be used.
77 """
78 self.monospacedFont = self.selectFont(
79 self.monospacedFontSample, self.monospacedFont,
80 options=QFontDialog.FontDialogOption.MonospacedFonts)
81
82 def polishPage(self):
83 """
84 Public slot to perform some polishing actions.
85 """
86 self.monospacedFontSample.setFont(self.monospacedFont)
87
88
89 def create(dlg):
90 """
91 Module function to create the configuration page.
92
93 @param dlg reference to the configuration dialog
94 @return reference to the instantiated page (ConfigurationPageBase)
95 """
96 page = HexEditorPage()
97 return page

eric ide

mercurial