Tue, 18 Oct 2022 16:06:21 +0200
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
3 | # Copyright (c) 2017 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the Editor Documentation Viewer configuration page. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from .ConfigurationPageBase import ConfigurationPageBase |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from .Ui_EditorDocViewerPage import Ui_EditorDocViewerPage |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
13 | from eric7.EricWidgets.EricApplication import ericApp |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
15 | from eric7 import Preferences |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | class EditorDocViewerPage(ConfigurationPageBase, Ui_EditorDocViewerPage): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
6047
39586a2de99d
Fixed some forgotten source code documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
20 | Class implementing the Editor Documentation Viewer configuration page. |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | |
6380
4a932a7ab987
Configuration pages: corrected the constructor of some configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
23 | def __init__(self): |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Constructor |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
27 | super().__init__() |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | self.setupUi(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | self.setObjectName("EditorExportersPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
30 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
31 | try: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
32 | providers = ericApp().getObject("DocuViewer").getProviders() |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
33 | for provider, text in providers: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
34 | self.providerComboBox.addItem(text, provider) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
36 | self.infoLabel.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
38 | # set initial values |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
39 | self.parenthesisCheckBox.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | Preferences.getDocuViewer("ShowInfoOnOpenParenthesis") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
43 | provider = Preferences.getDocuViewer("Provider") |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
44 | self.viewerGroupBox.setChecked(provider != "disabled") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
46 | index = self.providerComboBox.findData(provider) |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
47 | if index >= 0: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
48 | self.providerComboBox.setCurrentIndex(index) |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
49 | except KeyError: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
50 | # documentation viewer is globally disabled |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
51 | self.viewerGroupBox.setChecked(False) |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6505
diff
changeset
|
52 | self.viewerGroupBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | self.infoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | "The Documentation Viewer is disabled globally. Re-enable it" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | " on the Interface/Interface configuration page and restart" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | " the eric." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | def save(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Public slot to save the Editor Typing configuration. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | enabled = self.viewerGroupBox.isChecked() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | if enabled: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | Preferences.setDocuViewer( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | "ShowInfoOnOpenParenthesis", self.parenthesisCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | ) |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
70 | Preferences.setDocuViewer( |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | "Provider", |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | self.providerComboBox.itemData(self.providerComboBox.currentIndex()), |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | ) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | Preferences.setDocuViewer("Provider", "disabled") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | def create(dlg): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | Module function to create the configuration page. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @param dlg reference to the configuration dialog |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | @return reference to the instantiated page (ConfigurationPageBase) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | page = EditorDocViewerPage() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | return page |