|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Editor Documentation Viewer configuration page. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from .ConfigurationPageBase import ConfigurationPageBase |
|
13 from .Ui_EditorDocViewerPage import Ui_EditorDocViewerPage |
|
14 |
|
15 from E5Gui.E5Application import e5App |
|
16 |
|
17 import Preferences |
|
18 |
|
19 |
|
20 class EditorDocViewerPage(ConfigurationPageBase, Ui_EditorDocViewerPage): |
|
21 """ |
|
22 Class implementing the Editor Documentation Viewer configuration page. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super(EditorDocViewerPage, self).__init__() |
|
29 self.setupUi(self) |
|
30 self.setObjectName("EditorExportersPage") |
|
31 |
|
32 try: |
|
33 providers = e5App().getObject("DocuViewer").getProviders() |
|
34 for provider, text in providers: |
|
35 self.providerComboBox.addItem(text, provider) |
|
36 |
|
37 self.infoLabel.clear() |
|
38 |
|
39 # set initial values |
|
40 self.parenthesisCheckBox.setChecked( |
|
41 Preferences.getDocuViewer("ShowInfoOnOpenParenthesis")) |
|
42 |
|
43 provider = Preferences.getDocuViewer("Provider") |
|
44 self.viewerGroupBox.setChecked(provider != "disabled") |
|
45 |
|
46 index = self.providerComboBox.findData(provider) |
|
47 if index >= 0: |
|
48 self.providerComboBox.setCurrentIndex(index) |
|
49 except KeyError: |
|
50 # documentation viewer is globally disabled |
|
51 self.viewerGroupBox.setChecked(False) |
|
52 self.viewerGroupBox.setEnabled(False) |
|
53 self.infoLabel.setText(self.tr( |
|
54 "The Documentation Viewer is disabled globally. Re-enable it" |
|
55 " on the Interface/Interface configuration page and restart" |
|
56 " the eric.")) |
|
57 |
|
58 def save(self): |
|
59 """ |
|
60 Public slot to save the Editor Typing configuration. |
|
61 """ |
|
62 enabled = self.viewerGroupBox.isChecked() |
|
63 if enabled: |
|
64 Preferences.setDocuViewer( |
|
65 "ShowInfoOnOpenParenthesis", |
|
66 self.parenthesisCheckBox.isChecked()) |
|
67 Preferences.setDocuViewer( |
|
68 "Provider", |
|
69 self.providerComboBox.itemData( |
|
70 self.providerComboBox.currentIndex()) |
|
71 ) |
|
72 else: |
|
73 Preferences.setDocuViewer("Provider", "disabled") |
|
74 |
|
75 |
|
76 def create(dlg): |
|
77 """ |
|
78 Module function to create the configuration page. |
|
79 |
|
80 @param dlg reference to the configuration dialog |
|
81 @return reference to the instantiated page (ConfigurationPageBase) |
|
82 """ |
|
83 page = EditorDocViewerPage() |
|
84 return page |