diff --git a/src/mcedit2/widgets/mcedockwidget.py b/src/mcedit2/widgets/mcedockwidget.py index 19ae449..e14639d 100644 --- a/src/mcedit2/widgets/mcedockwidget.py +++ b/src/mcedit2/widgets/mcedockwidget.py @@ -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 - \ No newline at end of file + 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()