MCEDockWidget has an optional fade in/out when mouse enters/leaves.

This commit is contained in:
David Vierra 2015-09-14 23:01:50 -10:00
parent b6dc6ffe14
commit bde6ab2df8

View File

@ -2,7 +2,7 @@
mcedockwidget
"""
from __future__ import absolute_import, division, print_function, unicode_literals
from PySide import QtGui
from PySide import QtGui, QtCore
import logging
log = logging.getLogger(__name__)
@ -11,5 +11,31 @@ log = logging.getLogger(__name__)
class MCEDockWidget(QtGui.QDockWidget):
def __init__(self, *a, **kw):
super(MCEDockWidget, self).__init__(*a, **kw)
self._unfocusedOpacity = 1.0
def setUnfocusedOpacity(self, value):
self._unfocusedOpacity = value
def animate(self, value):
log.info("ANIMATION")
self.setWindowOpacity(value)
def enterEvent(self, event):
if self._unfocusedOpacity == 1.0:
return
self.animation = animation = QtCore.QPropertyAnimation(self, 'windowOpacity')
animation.setDuration(100)
animation.setStartValue(self.windowOpacity())
animation.setEndValue(1.0)
animation.valueChanged.connect(self.animate)
animation.start()
def leaveEvent(self, event):
if self._unfocusedOpacity == 1.0:
return
self.animation = animation = QtCore.QPropertyAnimation(self, 'windowOpacity')
animation.setDuration(250)
animation.setStartValue(self.windowOpacity())
animation.setEndValue(self._unfocusedOpacity)
animation.valueChanged.connect(self.animate)
animation.start()