eric6/Preferences/ConfigurationPages/HexEditorPage.py

branch
maintenance
changeset 6989
8b8cadf8d7e9
parent 6942
2602857055c5
child 7229
53054eb5b15a
equal deleted inserted replaced
6938:7926553b7509 6989:8b8cadf8d7e9
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6
7 """
8 Module implementing the Hex Editor configuration page.
9 """
10
11 from __future__ import unicode_literals
12
13 from PyQt5.QtCore import pyqtSlot
14 from PyQt5.QtWidgets import QFontDialog
15
16 from .ConfigurationPageBase import ConfigurationPageBase
17 from .Ui_HexEditorPage import Ui_HexEditorPage
18
19 import Preferences
20
21 try:
22 MonospacedFontsOption = QFontDialog.MonospacedFonts
23 except AttributeError:
24 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
25
26
27 class HexEditorPage(ConfigurationPageBase, Ui_HexEditorPage):
28 """
29 Class implementing the Hex Editor configuration page.
30 """
31 def __init__(self):
32 """
33 Constructor
34 """
35 super(HexEditorPage, self).__init__()
36 self.setupUi(self)
37 self.setObjectName("HexEditorPage")
38
39 # set initial values
40 self.readOnlyCheckBox.setChecked(Preferences.getHexEditor(
41 "OpenReadOnly"))
42 self.overwriteCheckBox.setChecked(Preferences.getHexEditor(
43 "OpenInOverwriteMode"))
44 self.addressAreaCheckBox.setChecked(Preferences.getHexEditor(
45 "ShowAddressArea"))
46 self.addressAreaWidthSpinBox.setValue(Preferences.getHexEditor(
47 "AddressAreaWidth"))
48 self.asciiAreaCheckBox.setChecked(Preferences.getHexEditor(
49 "ShowAsciiArea"))
50 self.highlightingCheckBox.setChecked(Preferences.getHexEditor(
51 "HighlightChanges"))
52 self.recentFilesSpinBox.setValue(Preferences.getHexEditor(
53 "RecentNumber"))
54
55 # font
56 self.monospacedFont = Preferences.getHexEditor("Font")
57 self.monospacedFontSample.setFont(self.monospacedFont)
58
59 # colours
60 self.initColour("HighlightingBackGround",
61 self.highlightingBackGroundButton,
62 Preferences.getHexEditor)
63 self.initColour("HighlightingForeGround",
64 self.highlightingForeGroundButton,
65 Preferences.getHexEditor)
66 self.initColour("SelectionBackGround",
67 self.selectionBackGroundButton,
68 Preferences.getHexEditor)
69 self.initColour("SelectionForeGround",
70 self.selectionForeGroundButton,
71 Preferences.getHexEditor)
72 self.initColour("AddressAreaBackGround",
73 self.addressAreaBackGroundButton,
74 Preferences.getHexEditor)
75 self.initColour("AddressAreaForeGround",
76 self.addressAreaForeGroundButton,
77 Preferences.getHexEditor)
78
79 def save(self):
80 """
81 Public slot to save the IRC configuration.
82 """
83 Preferences.setHexEditor(
84 "OpenReadOnly", self.readOnlyCheckBox.isChecked())
85 Preferences.setHexEditor(
86 "OpenInOverwriteMode", self.overwriteCheckBox.isChecked())
87 Preferences.setHexEditor(
88 "ShowAddressArea", self.addressAreaCheckBox.isChecked())
89 Preferences.setHexEditor(
90 "AddressAreaWidth", self.addressAreaWidthSpinBox.value())
91 Preferences.setHexEditor(
92 "ShowAsciiArea", self.asciiAreaCheckBox.isChecked())
93 Preferences.setHexEditor(
94 "HighlightChanges", self.highlightingCheckBox.isChecked())
95 Preferences.setHexEditor(
96 "Font", self.monospacedFont)
97 Preferences.setHexEditor(
98 "RecentNumber", self.recentFilesSpinBox.value())
99
100 # colours
101 self.saveColours(Preferences.setHexEditor)
102
103 @pyqtSlot()
104 def on_monospacedFontButton_clicked(self):
105 """
106 Private method used to select the font to be used.
107 """
108 self.monospacedFont = self.selectFont(
109 self.monospacedFontSample, self.monospacedFont,
110 options=MonospacedFontsOption)
111
112 def polishPage(self):
113 """
114 Public slot to perform some polishing actions.
115 """
116 self.monospacedFontSample.setFont(self.monospacedFont)
117
118
119 def create(dlg):
120 """
121 Module function to create the configuration page.
122
123 @param dlg reference to the configuration dialog
124 @return reference to the instantiated page (ConfigurationPageBase)
125 """
126 page = HexEditorPage()
127 return page

eric ide

mercurial