def __init__(self, treeItem):
     super(XGanttViewItem, self).__init__()
     
     # define custom properties
     self._color                     = QColor('white')
     self._alternateColor            = QColor(230, 230, 230)
     self._highlightColor            = QColor('yellow')
     self._alternateHighlightColor   = self._highlightColor.darker(110)
     self._textColor                 = QColor('black')
     self._borderColor               = QColor(50, 50, 50)
     self._progressColor             = QColor(200, 200, 250)
     self._alternateProgressColor    = QColor(180, 180, 230)
     self._showProgress              = True
     self._padding                   = 3
     self._borderRadius              = 5
     self._percentComplete           = 0
     self._text                      = ''
     self._syncing                   = False
     self._treeItem                  = weakref.ref(treeItem)
     
     # setup standard properties
     flags  = self.ItemIsSelectable 
     flags |= self.ItemIsFocusable
     
     if treeItem.flags() & Qt.ItemIsEditable:
         flags |= self.ItemIsMovable
     
     effect = QGraphicsDropShadowEffect()
     effect.setXOffset(0)
     effect.setYOffset(0)
     effect.setColor(QColor(40, 40, 40, 100))
     effect.setBlurRadius(10)
     
     self.setFlags( flags )
     self.setAcceptHoverEvents(True)
     self.setGraphicsEffect(effect)
     
     # need this flag for Qt 4.6+
     try:
         self.setFlag(self.ItemSendsGeometryChanges)
     except AttributeError:
         pass
    def __init__(self, treeItem):
        super(XGanttViewItem, self).__init__()

        # define custom properties
        self._color = QColor('white')
        self._alternateColor = QColor(230, 230, 230)
        self._highlightColor = QColor('yellow')
        self._alternateHighlightColor = self._highlightColor.darker(110)
        self._textColor = QColor('black')
        self._borderColor = QColor(50, 50, 50)
        self._progressColor = QColor(200, 200, 250)
        self._alternateProgressColor = QColor(180, 180, 230)
        self._showProgress = True
        self._padding = 3
        self._borderRadius = 5
        self._percentComplete = 0
        self._text = ''
        self._syncing = False
        self._treeItem = weakref.ref(treeItem)

        # setup standard properties
        flags = self.ItemIsSelectable
        flags |= self.ItemIsFocusable

        if treeItem.flags() & Qt.ItemIsEditable:
            flags |= self.ItemIsMovable

        effect = QGraphicsDropShadowEffect()
        effect.setXOffset(0)
        effect.setYOffset(0)
        effect.setColor(QColor(40, 40, 40, 100))
        effect.setBlurRadius(10)

        self.setFlags(flags)
        self.setAcceptHoverEvents(True)
        self.setGraphicsEffect(effect)

        # need this flag for Qt 4.6+
        try:
            self.setFlag(self.ItemSendsGeometryChanges)
        except AttributeError:
            pass
Exemple #3
0
 def setCurrentAction(self, action):
     """
     Sets the current action for this widget that highlights the size
     for this toolbar.
     
     :param      action | <QAction>
     """
     if action == self._currentAction:
         return
     
     self._currentAction = action
     self.currentActionChanged.emit(action)
     
     labels   = self.actionLabels()
     anim_grp = QParallelAnimationGroup(self)
     max_size = self.maximumPixmapSize()
     min_size = self.minimumPixmapSize()
     
     if action:
         label = self.labelForAction(action)
         index = labels.index(label)
         
         # create the highlight effect
         palette = self.palette()
         effect = QGraphicsDropShadowEffect(label)
         effect.setXOffset(0)
         effect.setYOffset(0)
         effect.setBlurRadius(20)
         effect.setColor(QColor(40, 40, 40))
         label.setGraphicsEffect(effect)
         
         offset = self.padding()
         if self.position() in (XDockToolbar.Position.East,
                                XDockToolbar.Position.West):
             self.resize(max_size.width() + offset, self.height())
         
         elif self.position() in (XDockToolbar.Position.North,
                                  XDockToolbar.Position.South):
             self.resize(self.width(), max_size.height() + offset)
         
         w  = max_size.width()
         h  = max_size.height()
         dw = (max_size.width() - min_size.width()) / 3
         dh = (max_size.height() - min_size.height()) / 3
         
         for i in range(4):
             before = index - i
             after  = index + i
             
             if 0 <= before and before < len(labels):
                 anim = XObjectAnimation(labels[before],
                                         'setPixmapSize',
                                         anim_grp)
                 
                 anim.setEasingCurve(self.easingCurve())
                 anim.setStartValue(labels[before].pixmapSize())
                 anim.setEndValue(QSize(w, h))
                 anim.setDuration(self.duration())
                 anim_grp.addAnimation(anim)
                 
                 if i:
                     labels[before].setGraphicsEffect(None)
             
             if after != before and 0 <= after and after < len(labels):
                 anim = XObjectAnimation(labels[after],
                                         'setPixmapSize',
                                         anim_grp)
                 
                 anim.setEasingCurve(self.easingCurve())
                 anim.setStartValue(labels[after].pixmapSize())
                 anim.setEndValue(QSize(w, h))
                 anim.setDuration(self.duration())
                 anim_grp.addAnimation(anim)
                 
                 if i:
                     labels[after].setGraphicsEffect(None)
         
             w -= dw
             h -= dh
     else:
         offset = self.padding()
         for label in self.actionLabels():
             # clear the graphics effect 
             label.setGraphicsEffect(None)
             
             # create the animation
             anim = XObjectAnimation(label, 'setPixmapSize', self)
             anim.setEasingCurve(self.easingCurve())
             anim.setStartValue(label.pixmapSize())
             anim.setEndValue(min_size)
             anim.setDuration(self.duration())
             anim_grp.addAnimation(anim)
         
         anim_grp.finished.connect(self.resizeToMinimum)
     
     anim_grp.start()
     self._animating = True
     anim_grp.finished.connect(anim_grp.deleteLater)
     anim_grp.finished.connect(self.__markAnimatingFinished)
     
     if self._currentAction:
         self._hoverTimer.start()
     else:
         self._hoverTimer.stop()