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