MCEDockWidget has an optional fade in/out when mouse enters/leaves.
This commit is contained in:
parent
b6dc6ffe14
commit
bde6ab2df8
@ -2,7 +2,7 @@
|
|||||||
mcedockwidget
|
mcedockwidget
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
from PySide import QtGui
|
from PySide import QtGui, QtCore
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -11,5 +11,31 @@ log = logging.getLogger(__name__)
|
|||||||
class MCEDockWidget(QtGui.QDockWidget):
|
class MCEDockWidget(QtGui.QDockWidget):
|
||||||
def __init__(self, *a, **kw):
|
def __init__(self, *a, **kw):
|
||||||
super(MCEDockWidget, self).__init__(*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()
|
||||||
|
Reference in New Issue
Block a user