207 self.navigationButton.setPopupMode(QToolButton.InstantPopup) |
207 self.navigationButton.setPopupMode(QToolButton.InstantPopup) |
208 self.navigationButton.setMenu(self.__navigationMenu) |
208 self.navigationButton.setMenu(self.__navigationMenu) |
209 self.navigationButton.setEnabled(False) |
209 self.navigationButton.setEnabled(False) |
210 self.rightCornerWidgetLayout.addWidget(self.navigationButton) |
210 self.rightCornerWidgetLayout.addWidget(self.navigationButton) |
211 |
211 |
212 if Preferences.getUI("SingleCloseButton") or \ |
212 self.tabCloseRequested.connect(self.__closeRequested) |
213 not hasattr(self, 'setTabsClosable'): |
|
214 self.closeButton = QToolButton(self) |
|
215 self.closeButton.setIcon(UI.PixmapCache.getIcon("close.png")) |
|
216 self.closeButton.setToolTip( |
|
217 self.tr("Close the current editor")) |
|
218 self.closeButton.setEnabled(False) |
|
219 self.closeButton.clicked[bool].connect(self.__closeButtonClicked) |
|
220 self.rightCornerWidgetLayout.addWidget(self.closeButton) |
|
221 else: |
|
222 self.tabCloseRequested.connect(self.__closeRequested) |
|
223 self.closeButton = None |
|
224 |
213 |
225 self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) |
214 self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) |
226 |
215 |
227 self.__initMenu() |
216 self.__initMenu() |
228 self.contextMenuEditor = None |
217 self.contextMenuEditor = None |
368 @type str |
357 @type str |
369 """ |
358 """ |
370 editor = assembly.getEditor() |
359 editor = assembly.getEditor() |
371 super(TabWidget, self).addTab( |
360 super(TabWidget, self).addTab( |
372 assembly, UI.PixmapCache.getIcon("empty.png"), title) |
361 assembly, UI.PixmapCache.getIcon("empty.png"), title) |
373 if self.closeButton: |
362 self.setTabsClosable(True) |
374 self.closeButton.setEnabled(True) |
|
375 else: |
|
376 self.setTabsClosable(True) |
|
377 self.navigationButton.setEnabled(True) |
363 self.navigationButton.setEnabled(True) |
378 |
364 |
379 if editor not in self.editors: |
365 if editor not in self.editors: |
380 self.editors.append(editor) |
366 self.editors.append(editor) |
381 editor.captionChanged.connect(self.__captionChange) |
367 editor.captionChanged.connect(self.__captionChange) |
402 editor = assembly.getEditor() |
388 editor = assembly.getEditor() |
403 newIndex = super(TabWidget, self).insertTab( |
389 newIndex = super(TabWidget, self).insertTab( |
404 index, assembly, |
390 index, assembly, |
405 UI.PixmapCache.getIcon("empty.png"), |
391 UI.PixmapCache.getIcon("empty.png"), |
406 title) |
392 title) |
407 if self.closeButton: |
393 self.setTabsClosable(True) |
408 self.closeButton.setEnabled(True) |
|
409 else: |
|
410 self.setTabsClosable(True) |
|
411 self.navigationButton.setEnabled(True) |
394 self.navigationButton.setEnabled(True) |
412 |
395 |
413 if editor not in self.editors: |
396 if editor not in self.editors: |
414 self.editors.append(editor) |
397 self.editors.append(editor) |
415 editor.captionChanged.connect(self.__captionChange) |
398 editor.captionChanged.connect(self.__captionChange) |
486 |
469 |
487 if not self.editors: |
470 if not self.editors: |
488 super(TabWidget, self).addTab( |
471 super(TabWidget, self).addTab( |
489 self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "") |
472 self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "") |
490 self.emptyLabel.show() |
473 self.emptyLabel.show() |
491 if self.closeButton: |
474 self.setTabsClosable(False) |
492 self.closeButton.setEnabled(False) |
|
493 else: |
|
494 self.setTabsClosable(False) |
|
495 self.navigationButton.setEnabled(False) |
475 self.navigationButton.setEnabled(False) |
496 |
476 |
497 def __relocateTab(self, sourceId, sourceIndex, targetIndex): |
477 def __relocateTab(self, sourceId, sourceIndex, targetIndex): |
498 """ |
478 """ |
499 Private method to relocate an editor from another TabWidget. |
479 Private method to relocate an editor from another TabWidget. |