Ejemplo n.º 1
0
    def hide_banner(self):
        """
        Hides the banner with a scrolling animation.
        """
        elapsed = (time.time() - self._show_time) * 1000

        # Make sure we store any animations we create as a class instance variable to avoid it being garbage collected.
        # Not doing so will result in a warning when we try to clear the animation group.

        # We'll pause if required.
        self._anim_pause = self._banner_animation.addPause(
            max(3000 - elapsed, 0))

        # Compute the fully expanded and folded positions.
        expanded_pos = self._calc_expanded_pos()
        folded_pos = expanded_pos.translated(0, -self._HEIGHT)

        # Animate the banner sliding out of the dialog.
        self._anim_sliding_out = QtCore.QPropertyAnimation(self, b"geometry")
        self._anim_sliding_out.setDuration(250)
        self._anim_sliding_out.setStartValue(expanded_pos)
        self._anim_sliding_out.setEndValue(folded_pos)
        self._banner_animation.addAnimation(self._anim_sliding_out)

        # Launch the sliding out!
        self._banner_animation.start()
Ejemplo n.º 2
0
    def show_top(self, widget, duration=2000):
        '''Show the notice at the top center of the specified widget'''

        ref_rect = widget.rect()
        ref_pos = QtCore.QPoint(int(ref_rect.width() * 0.5), ref_rect.top())
        ref_pos = widget.mapToGlobal(ref_pos)

        rect = self.rect()
        rect.setWidth(ref_rect.width())
        self.setGeometry(rect)

        pos = QtCore.QPoint(int(rect.width() * 0.5), rect.top())

        delta = ref_pos - pos
        self.move(delta)

        # Set start and end values for animation
        start_value = self.geometry()
        start_value.setHeight(0)
        end_value = self.geometry()

        self.show()

        anim = QtCore.QPropertyAnimation(
            self,
            QtCore.QByteArray('geometry'.encode()),
            parent=self,
        )
        anim.setDuration(150)
        anim.setEasingCurve(QtCore.QEasingCurve.OutQuad)
        anim.setStartValue(start_value)
        anim.setEndValue(end_value)
        anim.start()
        QtCore.QTimer.singleShot(duration, self._hide_top)
Ejemplo n.º 3
0
    def _pin_to_menu(self, animated=True):
        # figure out start and end positions for the window
        self.systray.show()
        QtGui.QApplication.instance().processEvents()
        systray_geo = self.systray.geometry()

        logger.debug("systray_geo: %s", systray_geo)

        if animated:
            final = QtCore.QRect(systray_geo.center().x(),
                                 systray_geo.bottom(), 5, 5)
            start = self.geometry()

            # setup the animation to shrink the window to the systray
            # parent the anim to self to keep it from being garbage collected
            anim = QtCore.QPropertyAnimation(self, b"geometry", self)
            anim.setDuration(300)
            anim.setStartValue(start)
            anim.setEndValue(final)
            anim.setEasingCurve(QtCore.QEasingCurve.InQuad)

            # when the anim is finished, call the post handler
            def post_close_animation():
                self.hide()
                self.setGeometry(start)
                self.state = self.STATE_PINNED

            anim.finished.connect(post_close_animation)

            # run the animation
            anim.start()
        else:
            # not animated
            self.hide()
            self.state = self.STATE_PINNED
 def animate_widget(self):
     """ Run the animation that will move the widget in the view """
     anim = QtCore.QPropertyAnimation(self, "pos")
     anim.setDuration(500)
     anim.setEasingCurve(QtCore.QEasingCurve.OutCubic)
     anim.setStartValue(self._start_pos)
     anim.setEndValue(self._end_pos)
     self._animgroup = QtCore.QParallelAnimationGroup()
     self._animgroup.addAnimation(anim)
     self._animgroup.start()
Ejemplo n.º 5
0
 def showEvent(self, evt):
     """
     Show event
     """
     self._fit_screen_geometry()
     # Start fade in animation
     fade_anim = QtCore.QPropertyAnimation(self, "_opacity_anim_prop", self)
     fade_anim.setStartValue(self._opacity)
     fade_anim.setEndValue(127)
     fade_anim.setDuration(300)
     fade_anim.setEasingCurve(QtCore.QEasingCurve.OutCubic)
     fade_anim.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
Ejemplo n.º 6
0
    def _hide_top(self):
        start_value = self.geometry()
        end_value = self.geometry()
        end_value.setHeight(0)

        anim = QtCore.QPropertyAnimation(
            self,
            QtCore.QByteArray('geometry'.encode()),
            parent=self,
        )
        anim.setDuration(150)
        anim.setEasingCurve(QtCore.QEasingCurve.OutQuad)
        anim.setStartValue(start_value)
        anim.setEndValue(end_value)
        anim.finished.connect(self.close)
        anim.start()
    def __init__(self, notificationList = [], peopleList = [], parent = None):
        QtGui.QWidget.__init__(self, parent)


        self.speedFactor = 1

        self.notificationList = notificationList
        self.notification = 0

        

        self.lay = QtGui.QHBoxLayout()
        self.lay.setSpacing(0)
        self.lay.setContentsMargins(0,0,0,0)
        

        self.setLayout(self.lay)


        self.labelEdit = NotificationWriter()
        self.label=QtGui.QLabel()
        #self.setText()

        self.label.setAlignment(QtCore.Qt.AlignTop)
        self.label.setMinimumHeight(32)
        self.label.setMinimumWidth(600)
        self.animate = QtCore.QPropertyAnimation(self.label, "pos")
        self.animate.finished.connect(self.myfinished)

        self.lay.addWidget(self.label)
        self.geom = QtCore.QRect()
        self.painted = False

        self._filter = Filter()
        self.labelEdit.writeTo.installEventFilter(self)
        self.labelEdit.writeTo.setAutoCompletion(peopleList)
        self.labelEdit.writeWhat.installEventFilter(self)
        self.labelEdit.sendButton.installEventFilter(self)

        self.radioChecked = 0

        if self.radioChecked == 0 :
            self.notificationList = docLoad()
        elif self.radioChecked == 1 :
            self.notificationList = autoLoad()
        else :
            self.notificationList = []
Ejemplo n.º 8
0
    def hide_banner(self):
        """
        Hides the banner with a scrolling animation.
        """
        elapsed = (time.time() - self._show_time) * 1000

        # We'll pause if required.
        self._banner_animation.addPause(max(3000 - elapsed, 0))

        # Compute the fully expanded and folded positions.
        expanded_pos = self._calc_expanded_pos()
        folded_pos = expanded_pos.translated(0, -self._HEIGHT)

        # Animate the banner sliding out of the dialog.
        sliding_out = QtCore.QPropertyAnimation(self, "geometry")
        sliding_out.setDuration(250)
        sliding_out.setStartValue(expanded_pos)
        sliding_out.setEndValue(folded_pos)
        self._banner_animation.addAnimation(sliding_out)

        # Launch the sliding out!
        self._banner_animation.start()