Exemplo n.º 1
0
 def addTab(self, editor, title):
     """
     Overwritten method to add a new tab.
     
     @param editor the editor object to be added (QScintilla.Editor.Editor)
     @param title title for the new tab (string or QString)
     """
     E4TabWidget.addTab(self, 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
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"), "")