Esempio n. 1
0
class BaseView(QtGui.QDockWidget, IWorkbenchPart):
    sig_requestViewStateChange = QtCore.pyqtSignal(str, object)
    
    def __init__(self, parent=None):
        QtGui.QDockWidget.__init__(self, parent)
        self.setFeatures(self.features()&~QtGui.QDockWidget.DockWidgetFloatable)
        self.initUI()
        
    def initUI(self):
        titlebar = QtGui.QFrame(self)
        self.iconLabel     = QtGui.QLabel(titlebar)
        self.titleLabel    = QtGui.QLabel(titlebar)
        self.toolKit        = ToolBar(titlebar)
        self.winBar         = WinBar(titlebar)
        layout              = QtGui.QHBoxLayout()
        layout.setSpacing(0)
        layout.setMargin(0)
        layout.addWidget(self.iconLabel)
        layout.addSpacing(5)
        layout.addWidget(self.titleLabel)
        layout.addStretch()
        layout.addWidget(self.toolKit)
        layout.addWidget(self.winBar)
        titlebar.setLayout(layout)
        titlebar.mouseMoveEvent = titlebar.mousePressEvent = titlebar.mouseReleaseEvent = lambda evt: evt.ignore()
        titlebar.setFrameStyle(QtGui.QFrame.Box)
        self.setTitleBarWidget(titlebar)
        self.setIconSize(QtCore.QSize(12,12))
        self.winBar.sig_triggered.connect(self.onWinStateRequest)
        titlebar.mouseDoubleClickEvent = lambda evt: self.winBar.maxAction.trigger()
        
    def setWindowIcon(self, icon):
        QtGui.QDockWidget.setWindowIcon(self, icon)
        self.iconLabel.setPixmap(icon.pixmap(self.toolKit.iconSize()))
        self.toggleViewAction().setIcon(icon)
        
    def setWindowTitle(self, title):
        QtGui.QDockWidget.setWindowTitle(self, title)
        self.titleLabel.setText(title)
        
    def iconSize(self):
        return self.winBar.iconSize()
    
    def setIconSize(self, size):
        self.toolKit.setIconSize(size)
        self.winBar.setIconSize(size)
        
    def onWinStateRequest(self, cmd):
        self.sig_requestViewStateChange.emit(cmd, self)
            
    def wpResetActions(self):
        self.toolKit.domain = self.objectName()
        self.toolKit.name   = ''
        self.toolKit.clear()
        self.workbench.wb_actionset.populate(self.toolKit, self)
Esempio n. 2
0
 def initUI(self):
     titlebar = QtGui.QFrame(self)
     self.iconLabel     = QtGui.QLabel(titlebar)
     self.titleLabel    = QtGui.QLabel(titlebar)
     self.toolKit        = ToolBar(titlebar)
     self.winBar         = WinBar(titlebar)
     layout              = QtGui.QHBoxLayout()
     layout.setSpacing(0)
     layout.setMargin(0)
     layout.addWidget(self.iconLabel)
     layout.addSpacing(5)
     layout.addWidget(self.titleLabel)
     layout.addStretch()
     layout.addWidget(self.toolKit)
     layout.addWidget(self.winBar)
     titlebar.setLayout(layout)
     titlebar.mouseMoveEvent = titlebar.mousePressEvent = titlebar.mouseReleaseEvent = lambda evt: evt.ignore()
     titlebar.setFrameStyle(QtGui.QFrame.Box)
     self.setTitleBarWidget(titlebar)
     self.setIconSize(QtCore.QSize(12,12))
     self.winBar.sig_triggered.connect(self.onWinStateRequest)
     titlebar.mouseDoubleClickEvent = lambda evt: self.winBar.maxAction.trigger()