Preferences/ConfigurationPages/HexEditorPage.py

changeset 4658
d760763dcc4a
child 4673
6fa2418f010c
equal deleted inserted replaced
4656:ec546bd4ec56 4658:d760763dcc4a
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 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
15 from .ConfigurationPageBase import ConfigurationPageBase
16 from .Ui_HexEditorPage import Ui_HexEditorPage
17
18 import Preferences
19
20
21 class HexEditorPage(ConfigurationPageBase, Ui_HexEditorPage):
22 """
23 Class implementing the Hex Editor configuration page.
24 """
25 def __init__(self):
26 """
27 Constructor
28 """
29 super(HexEditorPage, self).__init__()
30 self.setupUi(self)
31 self.setObjectName("HexEditorPage")
32
33 # set initial values
34 self.readOnlyCheckBox.setChecked(Preferences.getHexEditor(
35 "OpenReadOnly"))
36 self.overwriteCheckBox.setChecked(Preferences.getHexEditor(
37 "OpenInOverwriteMode"))
38 self.addressAreaCheckBox.setChecked(Preferences.getHexEditor(
39 "ShowAddressArea"))
40 self.addressAreaWidthSpinBox.setValue(Preferences.getHexEditor(
41 "AddressAreaWidth"))
42 self.asciiAreaCheckBox.setChecked(Preferences.getHexEditor(
43 "ShowAsciiArea"))
44 self.highlightingCheckBox.setChecked(Preferences.getHexEditor(
45 "HighlightChanges"))
46
47 # font
48 self.monospacedFont = Preferences.getHexEditor("Font")
49 self.monospacedFontSample.setFont(self.monospacedFont)
50
51 # colours
52 self.initColour("HighlightingBackGround",
53 self.highlightingBackGroundButton,
54 Preferences.getHexEditor)
55 self.initColour("HighlightingForeGround",
56 self.highlightingForeGroundButton,
57 Preferences.getHexEditor)
58 self.initColour("SelectionBackGround",
59 self.selectionBackGroundButton,
60 Preferences.getHexEditor)
61 self.initColour("SelectionForeGround",
62 self.selectionForeGroundButton,
63 Preferences.getHexEditor)
64 self.initColour("AddressAreaBackGround",
65 self.addressAreaBackGroundButton,
66 Preferences.getHexEditor)
67 self.initColour("AddressAreaForeGround",
68 self.addressAreaForeGroundButton,
69 Preferences.getHexEditor)
70
71 def save(self):
72 """
73 Public slot to save the IRC configuration.
74 """
75 Preferences.setHexEditor(
76 "OpenReadOnly", self.readOnlyCheckBox.isChecked())
77 Preferences.setHexEditor(
78 "OpenInOverwriteMode", self.overwriteCheckBox.isChecked())
79 Preferences.setHexEditor(
80 "ShowAddressArea", self.addressAreaCheckBox.isChecked())
81 Preferences.setHexEditor(
82 "AddressAreaWidth", self.addressAreaWidthSpinBox.value())
83 Preferences.setHexEditor(
84 "ShowAsciiArea", self.asciiAreaCheckBox.isChecked())
85 Preferences.setHexEditor(
86 "HighlightChanges", self.highlightingCheckBox.isChecked())
87 Preferences.setHexEditor(
88 "Font", self.monospacedFont)
89
90 # colours
91 self.saveColours(Preferences.setHexEditor)
92
93 @pyqtSlot()
94 def on_monospacedFontButton_clicked(self):
95 """
96 Private method used to select the font to be used.
97 """
98 self.monospacedFont = self.selectFont(
99 self.monospacedFontSample, self.monospacedFont)
100
101 def polishPage(self):
102 """
103 Public slot to perform some polishing actions.
104 """
105 self.monospacedFontSample.setFont(self.monospacedFont)
106
107
108 def create(dlg):
109 """
110 Module function to create the configuration page.
111
112 @param dlg reference to the configuration dialog
113 @return reference to the instantiated page (ConfigurationPageBase)
114 """
115 page = HexEditorPage()
116 return page

eric ide

mercurial