|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the QScintilla Autocompletion configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt5.Qsci import QsciScintilla |
|
11 |
|
12 from .ConfigurationPageBase import ConfigurationPageBase |
|
13 from .Ui_EditorAutocompletionQScintillaPage import ( |
|
14 Ui_EditorAutocompletionQScintillaPage |
|
15 ) |
|
16 |
|
17 import Preferences |
|
18 |
|
19 |
|
20 class EditorAutocompletionQScintillaPage( |
|
21 ConfigurationPageBase, Ui_EditorAutocompletionQScintillaPage): |
|
22 """ |
|
23 Class implementing the QScintilla Autocompletion configuration page. |
|
24 """ |
|
25 def __init__(self): |
|
26 """ |
|
27 Constructor |
|
28 """ |
|
29 super().__init__() |
|
30 self.setupUi(self) |
|
31 self.setObjectName("EditorAutocompletionQScintillaPage") |
|
32 |
|
33 # set initial values |
|
34 self.acShowSingleCheckBox.setChecked( |
|
35 Preferences.getEditor("AutoCompletionShowSingle")) |
|
36 self.acFillupsCheckBox.setChecked( |
|
37 Preferences.getEditor("AutoCompletionFillups")) |
|
38 |
|
39 acSource = Preferences.getEditor("AutoCompletionSource") |
|
40 if acSource == QsciScintilla.AutoCompletionSource.AcsDocument: |
|
41 self.acSourceDocumentRadioButton.setChecked(True) |
|
42 elif acSource == QsciScintilla.AutoCompletionSource.AcsAPIs: |
|
43 self.acSourceAPIsRadioButton.setChecked(True) |
|
44 elif acSource == QsciScintilla.AutoCompletionSource.AcsAll: |
|
45 self.acSourceAllRadioButton.setChecked(True) |
|
46 |
|
47 def save(self): |
|
48 """ |
|
49 Public slot to save the Editor Autocompletion configuration. |
|
50 """ |
|
51 Preferences.setEditor( |
|
52 "AutoCompletionShowSingle", |
|
53 self.acShowSingleCheckBox.isChecked()) |
|
54 Preferences.setEditor( |
|
55 "AutoCompletionFillups", |
|
56 self.acFillupsCheckBox.isChecked()) |
|
57 if self.acSourceDocumentRadioButton.isChecked(): |
|
58 Preferences.setEditor( |
|
59 "AutoCompletionSource", |
|
60 QsciScintilla.AutoCompletionSource.AcsDocument) |
|
61 elif self.acSourceAPIsRadioButton.isChecked(): |
|
62 Preferences.setEditor( |
|
63 "AutoCompletionSource", |
|
64 QsciScintilla.AutoCompletionSource.AcsAPIs) |
|
65 elif self.acSourceAllRadioButton.isChecked(): |
|
66 Preferences.setEditor( |
|
67 "AutoCompletionSource", |
|
68 QsciScintilla.AutoCompletionSource.AcsAll) |
|
69 |
|
70 |
|
71 def create(dlg): |
|
72 """ |
|
73 Module function to create the configuration page. |
|
74 |
|
75 @param dlg reference to the configuration dialog |
|
76 @return reference to the instantiated page (ConfigurationPageBase) |
|
77 """ |
|
78 page = EditorAutocompletionQScintillaPage() |
|
79 return page |