def showEvent(self, evt): """ Protected method handleing the show event. @param evt show event to handle (QShowEvent) """ E4TabWidget.showEvent(self, evt) if self.embeddedBrowser: self.fileBrowser.layoutDisplay()
def insertWidget(self, index, editor, title): """ Overwritten method to insert a new tab. @param index index position for the new tab (integer) @param editor the editor object to be added (QScintilla.Editor.Editor) @param title title for the new tab (string or QString) @return index of the inserted tab (integer) """ newIndex = E4TabWidget.insertTab(self, index, editor, UI.PixmapCache.getIcon("empty.png"), title) if self.closeButton: self.closeButton.setEnabled(True) else: self.setTabsClosable(True) self.navigationButton.setEnabled(True) if not editor in self.editors: self.editors.append(editor) self.connect(editor, SIGNAL('captionChanged'), self.__captionChange) emptyIndex = self.indexOf(self.emptyLabel) if emptyIndex > -1: self.removeTab(emptyIndex) return newIndex
def currentWidget(self): """ Overridden method to return a reference to the current page. @return reference to the current page (QWidget) """ if not self.editors: return None else: return E4TabWidget.currentWidget(self)
def removeWidget(self, object): """ Public method to remove a widget. @param object object to be removed (QWidget) """ index = self.indexOf(object) if index > -1: self.removeTab(index) if isinstance(object, QScintilla.Editor.Editor): self.disconnect(object, SIGNAL('captionChanged'), self.__captionChange) self.editors.remove(object) if not self.editors: E4TabWidget.addTab(self, self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "") self.emptyLabel.show() if self.closeButton: self.closeButton.setEnabled(False) else: self.setTabsClosable(False) self.navigationButton.setEnabled(False)
def __init__(self, project, parent = None, embeddedBrowser = True): """ Constructor @param project reference to the project object @param parent parent widget (QWidget) @param embeddedBrowser flag indicating whether the file browser should be included. This flag is set to False by those layouts, that have the file browser in a separate window or embedded in the debeug browser instead """ E4TabWidget.__init__(self, parent) self.project = project self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) self.setUsesScrollButtons(True) self.vcsStatusIndicator = E4Led(self) self.setCornerWidget(self.vcsStatusIndicator, Qt.TopLeftCorner) self.vcsStatusColorNames = { "A" : "VcsAdded", "M" : "VcsModified", "O" : "VcsRemoved", "R" : "VcsReplaced", "U" : "VcsUpdate", "Z" : "VcsConflict", } self.vcsStatusText = { " " : self.trUtf8("up to date"), "A" : self.trUtf8("files added"), "M" : self.trUtf8("local modifications"), "O" : self.trUtf8("files removed"), "R" : self.trUtf8("files replaced"), "U" : self.trUtf8("update required"), "Z" : self.trUtf8("conflict"), } self.__vcsStateChanged(" ") # step 1: create all the individual browsers # sources browser self.psBrowser = ProjectSourcesBrowser(self.project) # forms browser self.pfBrowser = ProjectFormsBrowser(self.project) # resources browser self.prBrowser = ProjectResourcesBrowser(self.project) # translations browser self.ptBrowser = ProjectTranslationsBrowser(self.project) # interfaces (IDL) browser self.piBrowser = ProjectInterfacesBrowser(self.project) # others browser self.poBrowser = ProjectOthersBrowser(self.project) # add the file browser, if it should be embedded here self.embeddedBrowser = embeddedBrowser if embeddedBrowser: self.fileBrowser = Browser() # step 2: connect all the browsers # connect the sources browser self.connect(self.project, SIGNAL('projectClosed'), self.psBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.psBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.psBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.psBrowser._initMenusAndVcs) # connect the forms browser self.connect(self.project, SIGNAL('projectClosed'), self.pfBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.pfBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.pfBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.pfBrowser._initMenusAndVcs) # connect the resources browser self.connect(self.project, SIGNAL('projectClosed'), self.prBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.prBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.prBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.prBrowser._initMenusAndVcs) # connect the translations browser self.connect(self.project, SIGNAL('projectClosed'), self.ptBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.ptBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.ptBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.ptBrowser._initMenusAndVcs) # connect the interfaces (IDL) browser self.connect(self.project, SIGNAL('projectClosed'), self.piBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.piBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.piBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.piBrowser._initMenusAndVcs) # connect the others browser self.connect(self.project, SIGNAL('projectClosed'), self.poBrowser._projectClosed) self.connect(self.project, SIGNAL('projectOpened'), self.poBrowser._projectOpened) self.connect(self.project, SIGNAL('newProject'), self.poBrowser._newProject) self.connect(self.project, SIGNAL('reinitVCS'), self.poBrowser._initMenusAndVcs) # add signal connection to ourself self.connect(self.project, SIGNAL('projectOpened'), self.__projectOpened) self.connect(self.project, SIGNAL('projectClosed'), self.__projectClosed) self.connect(self.project, SIGNAL('newProject'), self.__newProject) self.connect(self.project, SIGNAL('projectPropertiesChanged'), self.__projectPropertiesChanged) self.connect(self, SIGNAL("currentChanged(int)"), self.__currentChanged) self.connect(self.project.getModel(), SIGNAL("vcsStateChanged"), self.__vcsStateChanged) self.__currentBrowsersFlags = 0 self.__projectPropertiesChanged() if self.embeddedBrowser: self.setCurrentWidget(self.fileBrowser) else: self.setCurrentIndex(0)
def __init__(self, vm): """ Constructor @param vm view manager widget (Tabview) """ E4TabWidget.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose, True) self.__tabBar = TabBar(self) self.setTabBar(self.__tabBar) self.setUsesScrollButtons(True) self.setElideMode(Qt.ElideNone) if isMacPlatform(): self.setDocumentMode(True) self.connect(self.__tabBar, SIGNAL("tabMoveRequested(int, int)"), self.moveTab) self.connect(self.__tabBar, SIGNAL("tabRelocateRequested(long, int, int)"), self.relocateTab) self.connect(self.__tabBar, SIGNAL("tabCopyRequested(long, int, int)"), self.copyTabOther) self.connect(self.__tabBar, SIGNAL("tabCopyRequested(int, int)"), self.copyTab) self.vm = vm self.editors = [] self.indicator = E4Led(self) self.setCornerWidget(self.indicator, Qt.TopLeftCorner) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.__navigationMenu = QMenu(self) self.connect(self.__navigationMenu, SIGNAL("aboutToShow()"), self.__showNavigationMenu) self.connect(self.__navigationMenu, SIGNAL("triggered(QAction*)"), self.__navigationMenuTriggered) self.navigationButton = QToolButton(self) self.navigationButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png")) self.navigationButton.setToolTip(self.trUtf8("Show a navigation menu")) self.navigationButton.setPopupMode(QToolButton.InstantPopup) self.navigationButton.setMenu(self.__navigationMenu) self.navigationButton.setEnabled(False) self.rightCornerWidgetLayout.addWidget(self.navigationButton) if Preferences.getUI("SingleCloseButton") or \ not hasattr(self, 'setTabsClosable'): self.closeButton = QToolButton(self) self.closeButton.setIcon(UI.PixmapCache.getIcon("close.png")) self.closeButton.setToolTip(self.trUtf8("Close the current editor")) self.closeButton.setEnabled(False) self.connect(self.closeButton, SIGNAL("clicked(bool)"), self.__closeButtonClicked) self.rightCornerWidgetLayout.addWidget(self.closeButton) else: self.connect(self, SIGNAL("tabCloseRequested(int)"), self.__closeRequested) self.closeButton = None self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) self.__initMenu() self.contextMenuEditor = None self.contextMenuIndex = -1 self.setTabContextMenuPolicy(Qt.CustomContextMenu) self.connect(self, SIGNAL('customTabContextMenuRequested(const QPoint &, int)'), self.__showContextMenu) ericPic = QPixmap(os.path.join(getConfig('ericPixDir'), 'eric_small.png')) self.emptyLabel = QLabel() self.emptyLabel.setPixmap(ericPic) self.emptyLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) E4TabWidget.addTab(self, self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "")