10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import Qt |
12 from PyQt5.QtCore import Qt |
13 from PyQt5.QtGui import QColor |
13 from PyQt5.QtGui import QColor |
14 from PyQt5.QtWidgets import QApplication |
14 from PyQt5.QtWidgets import QApplication |
15 |
|
16 from UI.Browser import Browser |
|
17 |
15 |
18 from E5Gui.E5TabWidget import E5TabWidget |
16 from E5Gui.E5TabWidget import E5TabWidget |
19 from E5Gui.E5Led import E5ClickableLed |
17 from E5Gui.E5Led import E5ClickableLed |
20 |
18 |
21 import UI.PixmapCache |
19 import UI.PixmapCache |
35 the project resources browser, the project translations browser, |
33 the project resources browser, the project translations browser, |
36 the project interfaces (IDL) browser and a browser for stuff, |
34 the project interfaces (IDL) browser and a browser for stuff, |
37 that doesn't fit these categories. Optionally it contains an additional |
35 that doesn't fit these categories. Optionally it contains an additional |
38 tab with the file system browser. |
36 tab with the file system browser. |
39 """ |
37 """ |
40 def __init__(self, project, parent=None, embeddedBrowser=True): |
38 def __init__(self, project, parent=None): |
41 """ |
39 """ |
42 Constructor |
40 Constructor |
43 |
41 |
44 @param project reference to the project object |
42 @param project reference to the project object |
45 @param parent parent widget (QWidget) |
43 @param parent parent widget (QWidget) |
46 @param embeddedBrowser flag indicating whether the file browser should |
|
47 be included. This flag is set to False by those layouts, that |
|
48 have the file browser in a separate window or embedded |
|
49 in the debeug browser instead |
|
50 """ |
44 """ |
51 E5TabWidget.__init__(self, parent) |
45 E5TabWidget.__init__(self, parent) |
52 self.project = project |
46 self.project = project |
53 |
47 |
54 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) |
48 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) |
99 # protocols (protobuf) browser |
93 # protocols (protobuf) browser |
100 self.ppBrowser = ProjectProtocolsBrowser(self.project) |
94 self.ppBrowser = ProjectProtocolsBrowser(self.project) |
101 # others browser |
95 # others browser |
102 self.poBrowser = ProjectOthersBrowser(self.project) |
96 self.poBrowser = ProjectOthersBrowser(self.project) |
103 |
97 |
104 # add the file browser, if it should be embedded here |
|
105 self.embeddedBrowser = embeddedBrowser |
|
106 if embeddedBrowser: |
|
107 self.fileBrowser = Browser() |
|
108 |
|
109 # step 2: connect all the browsers |
98 # step 2: connect all the browsers |
110 # connect the sources browser |
99 # connect the sources browser |
111 self.project.projectClosed.connect(self.psBrowser._projectClosed) |
100 self.project.projectClosed.connect(self.psBrowser._projectClosed) |
112 self.project.projectOpened.connect(self.psBrowser._projectOpened) |
101 self.project.projectOpened.connect(self.psBrowser._projectOpened) |
113 self.project.newProject.connect(self.psBrowser._newProject) |
102 self.project.newProject.connect(self.psBrowser._newProject) |
172 self.currentChanged.connect(self.__currentChanged) |
161 self.currentChanged.connect(self.__currentChanged) |
173 self.project.getModel().vcsStateChanged.connect(self.__vcsStateChanged) |
162 self.project.getModel().vcsStateChanged.connect(self.__vcsStateChanged) |
174 |
163 |
175 self.__currentBrowsersFlags = 0 |
164 self.__currentBrowsersFlags = 0 |
176 self.__projectPropertiesChanged() |
165 self.__projectPropertiesChanged() |
177 if self.embeddedBrowser: |
166 self.setCurrentIndex(0) |
178 self.setCurrentWidget(self.fileBrowser) |
|
179 else: |
|
180 self.setCurrentIndex(0) |
|
181 |
167 |
182 def __setBrowsersAvailable(self, browserFlags): |
168 def __setBrowsersAvailable(self, browserFlags): |
183 """ |
169 """ |
184 Private method to add selected browsers to the project browser. |
170 Private method to add selected browsers to the project browser. |
185 |
171 |
230 index = self.addTab( |
216 index = self.addTab( |
231 self.poBrowser, |
217 self.poBrowser, |
232 UI.PixmapCache.getIcon("projectOthers.png"), '') |
218 UI.PixmapCache.getIcon("projectOthers.png"), '') |
233 self.setTabToolTip(index, self.poBrowser.windowTitle()) |
219 self.setTabToolTip(index, self.poBrowser.windowTitle()) |
234 |
220 |
235 if self.embeddedBrowser: |
|
236 index = self.addTab( |
|
237 self.fileBrowser, |
|
238 UI.PixmapCache.getIcon("browser.png"), '') |
|
239 self.setTabToolTip(index, self.fileBrowser.windowTitle()) |
|
240 |
|
241 QApplication.processEvents() |
221 QApplication.processEvents() |
242 |
|
243 def showEvent(self, evt): |
|
244 """ |
|
245 Protected method handleing the show event. |
|
246 |
|
247 @param evt show event to handle (QShowEvent) |
|
248 """ |
|
249 E5TabWidget.showEvent(self, evt) |
|
250 if self.embeddedBrowser: |
|
251 self.fileBrowser.layoutDisplay() |
|
252 |
222 |
253 def __currentChanged(self, index): |
223 def __currentChanged(self, index): |
254 """ |
224 """ |
255 Private slot to handle the currentChanged(int) signal. |
225 Private slot to handle the currentChanged(int) signal. |
256 |
226 |
272 def __projectClosed(self): |
242 def __projectClosed(self): |
273 """ |
243 """ |
274 Private slot to handle the projectClosed signal. |
244 Private slot to handle the projectClosed signal. |
275 """ |
245 """ |
276 self.__projectPropertiesChanged() |
246 self.__projectPropertiesChanged() |
277 if self.embeddedBrowser: |
247 self.setCurrentIndex(0) |
278 self.setCurrentWidget(self.fileBrowser) |
|
279 else: |
|
280 self.setCurrentIndex(0) |
|
281 self.__setSourcesIcon() |
248 self.__setSourcesIcon() |
282 self.__vcsStateChanged(" ") |
249 self.__vcsStateChanged(" ") |
283 |
250 |
284 def __newProject(self): |
251 def __newProject(self): |
285 """ |
252 """ |
300 |
267 |
301 if flags != self.__currentBrowsersFlags: |
268 if flags != self.__currentBrowsersFlags: |
302 self.__currentBrowsersFlags = flags |
269 self.__currentBrowsersFlags = flags |
303 self.__setBrowsersAvailable(flags) |
270 self.__setBrowsersAvailable(flags) |
304 |
271 |
305 if self.embeddedBrowser: |
272 endIndex = self.count() |
306 endIndex = self.count() - 1 |
|
307 else: |
|
308 endIndex = self.count() |
|
309 for index in range(endIndex): |
273 for index in range(endIndex): |
310 self.setTabEnabled(index, self.project.isOpen()) |
274 self.setTabEnabled(index, self.project.isOpen()) |
311 |
275 |
312 self.__setSourcesIcon() |
276 self.__setSourcesIcon() |
313 |
277 |