8 combos and the editor widget. |
8 combos and the editor widget. |
9 """ |
9 """ |
10 |
10 |
11 import contextlib |
11 import contextlib |
12 |
12 |
13 from PyQt6.QtCore import QTimer |
13 from PyQt6.QtCore import Qt, QTimer |
14 from PyQt6.QtWidgets import QComboBox, QGridLayout, QWidget |
14 from PyQt6.QtWidgets import QComboBox, QGridLayout, QSplitter, QWidget |
15 |
15 |
16 from eric7 import Preferences |
16 from eric7 import Preferences |
17 from eric7.EricGui import EricPixmapCache |
17 from eric7.EricGui import EricPixmapCache |
18 from eric7.EricWidgets.EricApplication import ericApp |
18 from eric7.EricWidgets.EricApplication import ericApp |
19 from eric7.Utilities.ModuleParser import Function |
19 from eric7.Utilities.ModuleParser import Function |
57 self.__showOutline = Preferences.getEditor("ShowSourceOutline") |
57 self.__showOutline = Preferences.getEditor("ShowSourceOutline") |
58 self.__outlineSortByOccurrence = Preferences.getEditor( |
58 self.__outlineSortByOccurrence = Preferences.getEditor( |
59 "SourceOutlineListContentsByOccurrence" |
59 "SourceOutlineListContentsByOccurrence" |
60 ) |
60 ) |
61 |
61 |
62 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv) |
62 self.__editor = Editor( |
|
63 dbs=dbs, |
|
64 fn=fn, |
|
65 vm=vm, |
|
66 filetype=filetype, |
|
67 editor=editor, |
|
68 tv=tv, |
|
69 assembly=self, |
|
70 ) |
63 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self) |
71 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self) |
64 self.__globalsCombo = QComboBox() |
72 self.__globalsCombo = QComboBox() |
65 self.__globalsCombo.setDuplicatesEnabled(True) |
73 self.__globalsCombo.setDuplicatesEnabled(True) |
66 self.__membersCombo = QComboBox() |
74 self.__membersCombo = QComboBox() |
67 self.__membersCombo.setDuplicatesEnabled(True) |
75 self.__membersCombo.setDuplicatesEnabled(True) |
68 self.__sourceOutline = EditorOutlineView( |
76 self.__sourceOutline = EditorOutlineView( |
69 self.__editor, populate=self.__showOutline |
77 self.__editor, populate=self.__showOutline |
70 ) |
78 ) |
71 self.__sourceOutline.setMaximumWidth( |
79 self.__editorSplitter = QSplitter(Qt.Orientation.Horizontal) |
72 Preferences.getEditor("SourceOutlineWidth") |
80 self.__editorSplitter.setChildrenCollapsible(False) |
73 ) |
81 self.__editorSplitter.addWidget(self.__editor) |
|
82 self.__editorSplitter.addWidget(self.__sourceOutline) |
74 |
83 |
75 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1) |
84 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1) |
76 self.__layout.addWidget(self.__globalsCombo, 0, 1) |
85 self.__layout.addWidget(self.__globalsCombo, 0, 1) |
77 self.__layout.addWidget(self.__membersCombo, 0, 2) |
86 self.__layout.addWidget(self.__membersCombo, 0, 2) |
78 self.__layout.addWidget(self.__editor, 1, 1, 1, 2) |
87 self.__layout.addWidget(self.__editorSplitter, 1, 1, 1, 2) |
79 self.__layout.addWidget(self.__sourceOutline, 0, 3, -1, -1) |
|
80 |
88 |
81 self.setFocusProxy(self.__editor) |
89 self.setFocusProxy(self.__editor) |
82 |
90 |
83 self.__module = None |
91 self.__module = None |
84 |
92 |
98 self.__activateCombos(self.__showNavigator and not self.__showOutline) |
106 self.__activateCombos(self.__showNavigator and not self.__showOutline) |
99 |
107 |
100 ericApp().getObject("UserInterface").preferencesChanged.connect( |
108 ericApp().getObject("UserInterface").preferencesChanged.connect( |
101 self.__preferencesChanged |
109 self.__preferencesChanged |
102 ) |
110 ) |
|
111 |
|
112 def finishSetup(self): |
|
113 """ |
|
114 Public method to finish the setup of the assembly. |
|
115 """ |
|
116 splitterWidth = ( |
|
117 self.__editorSplitter.width() - self.__editorSplitter.handleWidth() |
|
118 ) |
|
119 outlineWidth = Preferences.getEditor("SourceOutlineWidth") |
|
120 self.__editorSplitter.setSizes([splitterWidth - outlineWidth, outlineWidth]) |
103 |
121 |
104 def aboutToBeClosed(self): |
122 def aboutToBeClosed(self): |
105 """ |
123 """ |
106 Public method to stop and disconnect the timer and disconnect some signals. |
124 Public method to stop and disconnect the timer and disconnect some signals. |
107 """ |
125 """ |
142 if showOutline != self.__showOutline or showNavigator != self.__showNavigator: |
160 if showOutline != self.__showOutline or showNavigator != self.__showNavigator: |
143 self.__showOutline = showOutline |
161 self.__showOutline = showOutline |
144 self.__showNavigator = showNavigator |
162 self.__showNavigator = showNavigator |
145 self.__activateOutline(self.__showNavigator and self.__showOutline) |
163 self.__activateOutline(self.__showNavigator and self.__showOutline) |
146 self.__activateCombos(self.__showNavigator and not self.__showOutline) |
164 self.__activateCombos(self.__showNavigator and not self.__showOutline) |
|
165 |
|
166 self.finishSetup() |
147 |
167 |
148 ####################################################################### |
168 ####################################################################### |
149 ## Methods dealing with the navigation combos below |
169 ## Methods dealing with the navigation combos below |
150 ####################################################################### |
170 ####################################################################### |
151 |
171 |