src/eric7/Preferences/ConfigurationPages/TemplatesPage.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) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Templates configuration page.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QFontDialog
12
13 from .ConfigurationPageBase import ConfigurationPageBase
14 from .Ui_TemplatesPage import Ui_TemplatesPage
15
16 import Preferences
17
18
19 class TemplatesPage(ConfigurationPageBase, Ui_TemplatesPage):
20 """
21 Class implementing the Templates configuration page.
22 """
23 def __init__(self):
24 """
25 Constructor
26 """
27 super().__init__()
28 self.setupUi(self)
29 self.setObjectName("TemplatesPage")
30
31 # set initial values
32 self.templatesAutoOpenGroupsCheckBox.setChecked(
33 Preferences.getTemplates("AutoOpenGroups"))
34 self.templatesSeparatorCharEdit.setText(
35 Preferences.getTemplates("SeparatorChar"))
36 if Preferences.getTemplates("SingleDialog"):
37 self.templatesSingleDialogButton.setChecked(True)
38 else:
39 self.templatesMultiDialogButton.setChecked(True)
40 self.templatesToolTipCheckBox.setChecked(
41 Preferences.getTemplates("ShowTooltip"))
42 self.editorFont = Preferences.getTemplates("EditorFont")
43 self.editorFontSample.setFont(self.editorFont)
44
45 def save(self):
46 """
47 Public slot to save the Templates configuration.
48 """
49 Preferences.setTemplates(
50 "AutoOpenGroups",
51 self.templatesAutoOpenGroupsCheckBox.isChecked())
52 sepChar = self.templatesSeparatorCharEdit.text()
53 if sepChar:
54 Preferences.setTemplates("SeparatorChar", sepChar)
55 Preferences.setTemplates(
56 "SingleDialog",
57 self.templatesSingleDialogButton.isChecked())
58 Preferences.setTemplates(
59 "ShowTooltip",
60 self.templatesToolTipCheckBox.isChecked())
61 Preferences.setTemplates("EditorFont", self.editorFont)
62
63 @pyqtSlot()
64 def on_editorFontButton_clicked(self):
65 """
66 Private method used to select the font to be used by the code editor.
67 """
68 self.editorFont = self.selectFont(
69 self.editorFontSample, self.editorFont,
70 options=QFontDialog.FontDialogOption.MonospacedFonts)
71
72
73 def create(dlg):
74 """
75 Module function to create the configuration page.
76
77 @param dlg reference to the configuration dialog
78 @return reference to the instantiated page (ConfigurationPageBase)
79 """
80 page = TemplatesPage()
81 return page

eric ide

mercurial