eric6/Preferences/ConfigurationPages/TemplatesPage.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Templates configuration page.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QFontDialog
14
15 from .ConfigurationPageBase import ConfigurationPageBase
16 from .Ui_TemplatesPage import Ui_TemplatesPage
17
18 import Preferences
19
20 try:
21 MonospacedFontsOption = QFontDialog.MonospacedFonts
22 except AttributeError:
23 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
24
25
26 class TemplatesPage(ConfigurationPageBase, Ui_TemplatesPage):
27 """
28 Class implementing the Templates configuration page.
29 """
30 def __init__(self):
31 """
32 Constructor
33 """
34 super(TemplatesPage, self).__init__()
35 self.setupUi(self)
36 self.setObjectName("TemplatesPage")
37
38 # set initial values
39 self.templatesAutoOpenGroupsCheckBox.setChecked(
40 Preferences.getTemplates("AutoOpenGroups"))
41 self.templatesSeparatorCharEdit.setText(
42 Preferences.getTemplates("SeparatorChar"))
43 if Preferences.getTemplates("SingleDialog"):
44 self.templatesSingleDialogButton.setChecked(True)
45 else:
46 self.templatesMultiDialogButton.setChecked(True)
47 self.templatesToolTipCheckBox.setChecked(
48 Preferences.getTemplates("ShowTooltip"))
49 self.editorFont = Preferences.getTemplates("EditorFont")
50 self.editorFontSample.setFont(self.editorFont)
51
52 def save(self):
53 """
54 Public slot to save the Templates configuration.
55 """
56 Preferences.setTemplates(
57 "AutoOpenGroups",
58 self.templatesAutoOpenGroupsCheckBox.isChecked())
59 sepChar = self.templatesSeparatorCharEdit.text()
60 if sepChar:
61 Preferences.setTemplates("SeparatorChar", sepChar)
62 Preferences.setTemplates(
63 "SingleDialog",
64 self.templatesSingleDialogButton.isChecked())
65 Preferences.setTemplates(
66 "ShowTooltip",
67 self.templatesToolTipCheckBox.isChecked())
68 Preferences.setTemplates("EditorFont", self.editorFont)
69
70 @pyqtSlot()
71 def on_editorFontButton_clicked(self):
72 """
73 Private method used to select the font to be used by the code editor.
74 """
75 self.editorFont = self.selectFont(
76 self.editorFontSample, self.editorFont,
77 options=MonospacedFontsOption)
78
79
80 def create(dlg):
81 """
82 Module function to create the configuration page.
83
84 @param dlg reference to the configuration dialog
85 @return reference to the instantiated page (ConfigurationPageBase)
86 """
87 page = TemplatesPage()
88 return page

eric ide

mercurial