Example #1
0
    def create_on_scene_layout(self):
        self.previewGraphicsView_layout = QtGui.QGridLayout(self.previewGraphicsView)
        self.previewGraphicsView_layout.setContentsMargins(0, 0, 0, 0)
        self.previewGraphicsView_layout.setSpacing(0)
        self.back_button = QtGui.QPushButton('')
        self.back_button_opacity_effect = QtGui.QGraphicsOpacityEffect()
        self.back_button_opacity_effect.setOpacity(0)
        self.back_button.setGraphicsEffect(self.back_button_opacity_effect)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        self.back_button.setSizePolicy(sizePolicy)
        self.back_button.setIcon(gf.get_icon('chevron-left'))
        self.back_button.setStyleSheet('QPushButton {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 64), stop:1 rgba(0, 0, 0, 0)); border-style: none; outline: none; border-width: 0px;}')

        self.back_button_hover_animation = QtCore.QPropertyAnimation(self.back_button_opacity_effect, "opacity", self)
        self.back_button_hover_animation.setDuration(200)
        self.back_button_hover_animation.setEasingCurve(QtCore.QEasingCurve.InSine)
        self.back_button_hover_animation.setStartValue(0)
        self.back_button_hover_animation.setEndValue(1)

        self.back_button_leave_animation = QtCore.QPropertyAnimation(self.back_button_opacity_effect, "opacity", self)
        self.back_button_leave_animation.setDuration(200)
        self.back_button_leave_animation.setEasingCurve(QtCore.QEasingCurve.OutSine)
        self.back_button_leave_animation.setEndValue(0)

        # forward button
        self.forward_button = QtGui.QPushButton('')
        self.forward_button_opacity_effect = QtGui.QGraphicsOpacityEffect(self)
        self.forward_button_opacity_effect.setOpacity(0)
        self.forward_button.setGraphicsEffect(self.forward_button_opacity_effect)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        self.forward_button.setSizePolicy(sizePolicy)
        self.forward_button.setIcon(gf.get_icon('chevron-right'))
        self.forward_button.setStyleSheet('QPushButton {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(0, 0, 0, 64)); border-style: none; outline: none; border-width: 0px;}')

        self.forward_button_hover_animation = QtCore.QPropertyAnimation(self.forward_button_opacity_effect, "opacity", self)
        self.forward_button_hover_animation.setDuration(200)
        self.forward_button_hover_animation.setEasingCurve(QtCore.QEasingCurve.InSine)
        self.forward_button_hover_animation.setStartValue(0)
        self.forward_button_hover_animation.setEndValue(1)

        self.forward_button_leave_animation = QtCore.QPropertyAnimation(self.forward_button_opacity_effect, "opacity", self)
        self.forward_button_leave_animation.setDuration(200)
        self.forward_button_leave_animation.setEasingCurve(QtCore.QEasingCurve.OutSine)
        self.forward_button_leave_animation.setEndValue(0)

        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.previewGraphicsView_layout.addWidget(self.forward_button, 0, 2, 1, 1)
        self.previewGraphicsView_layout.addWidget(self.back_button, 0, 0, 1, 1)
        self.previewGraphicsView_layout.addItem(spacerItem, 0, 1, 1, 1)
        self.previewGraphicsView_layout.setColumnStretch(0, 1)
        self.previewGraphicsView_layout.setColumnStretch(1, 1)
        self.previewGraphicsView_layout.setColumnStretch(2, 1)
    def tab_bar_customization(self):
        self.hamburger_tab_button = QtGui.QToolButton()
        self.hamburger_tab_button.setAutoRaise(True)
        self.hamburger_tab_button.setMinimumWidth(20)
        self.hamburger_tab_button.setMinimumHeight(20)
        self.animation_close = QtCore.QPropertyAnimation(
            self.sTypesTreeWidget, "maximumWidth", self)
        self.animation_open = QtCore.QPropertyAnimation(
            self.sTypesTreeWidget, "maximumWidth", self)
        self.hamburger_tab_button.setIcon(gf.get_icon('navicon'))

        self.sObjTabWidget.setCornerWidget(self.hamburger_tab_button,
                                           QtCore.Qt.BottomLeftCorner)
    def tab_bar_customization(self):
        self.hamburger_tab_button = QtGui.QToolButton()
        self.hamburger_tab_button.setAutoRaise(True)
        self.hamburger_tab_button.setMinimumWidth(24)
        self.hamburger_tab_button.setMinimumHeight(24)
        self.animation_close = QtCore.QPropertyAnimation(
            self.stypes_tree_widget, "maximumWidth", self)
        self.animation_open = QtCore.QPropertyAnimation(
            self.stypes_tree_widget, "maximumWidth", self)
        self.hamburger_tab_button.setIcon(
            gf.get_icon('menu', icons_set='mdi', scale_factor=1.2))

        self.stypes_tab_widget.add_left_corner_widget(
            self.hamburger_tab_button)
    def create_scene(self):
        self.scene_created = True

        self.pm1 = Pixmap(self)
        self.pm2 = Pixmap(self)
        self.pm3 = Pixmap(self)

        self.scene.addItem(self.pm1.pixmap_item)
        self.scene.addItem(self.pm2.pixmap_item)
        self.scene.addItem(self.pm3.pixmap_item)

        # animation
        self.machine = QtCore.QStateMachine()
        self.state1 = QtCore.QState()
        self.state2 = QtCore.QState()
        self.state3 = QtCore.QState()

        self.state1.assignProperty(self.pm1, 'pos', QtCore.QPoint(0, 0))
        self.state1.assignProperty(self.pm1, 'opacity', 1)

        self.state2.assignProperty(self.pm1, 'pos', QtCore.QPoint(-255, 0))
        self.state2.assignProperty(self.pm1, 'opacity', 0)

        self.state3.assignProperty(self.pm1, 'pos', QtCore.QPoint(255, 0))
        self.state3.assignProperty(self.pm1, 'opacity', 0)

        self.state1.assignProperty(self.pm2, 'pos', QtCore.QPoint(255, 0))
        self.state1.assignProperty(self.pm2, 'opacity', 0)

        self.state2.assignProperty(self.pm2, 'pos', QtCore.QPoint(0, 0))
        self.state2.assignProperty(self.pm2, 'opacity', 1)

        self.state3.assignProperty(self.pm2, 'pos', QtCore.QPoint(-255, 0))
        self.state3.assignProperty(self.pm2, 'opacity', 0)

        self.state1.assignProperty(self.pm3, 'pos', QtCore.QPoint(-255, 0))
        self.state1.assignProperty(self.pm3, 'opacity', 0)

        self.state2.assignProperty(self.pm3, 'pos', QtCore.QPoint(255, 0))
        self.state2.assignProperty(self.pm3, 'opacity', 0)

        self.state3.assignProperty(self.pm3, 'pos', QtCore.QPoint(0, 0))
        self.state3.assignProperty(self.pm3, 'opacity', 1)

        self.pm1_anm = QtCore.QPropertyAnimation(self.pm1, 'pos', self)
        self.pm1_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm1_anm.setDuration(300)

        self.pm1_anm_o = QtCore.QPropertyAnimation(self.pm1, 'opacity', self)
        self.pm1_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm1_anm_o.setDuration(200)

        self.pm2_anm = QtCore.QPropertyAnimation(self.pm2, 'pos', self)
        self.pm2_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm2_anm.setDuration(300)

        self.pm2_anm_o = QtCore.QPropertyAnimation(self.pm2, 'opacity', self)
        self.pm2_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm2_anm_o.setDuration(200)

        self.pm3_anm = QtCore.QPropertyAnimation(self.pm3, 'pos', self)
        self.pm3_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm3_anm.setDuration(300)

        self.pm3_anm_o = QtCore.QPropertyAnimation(self.pm3, 'opacity', self)
        self.pm3_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm3_anm_o.setDuration(200)

        self.t4 = self.state1.addTransition(self.value_decreased, self.state3)
        self.t4.addAnimation(self.pm1_anm)
        self.t4.addAnimation(self.pm1_anm_o)
        self.t4.addAnimation(self.pm2_anm)
        self.t4.addAnimation(self.pm2_anm_o)
        self.t4.addAnimation(self.pm3_anm)
        self.t4.addAnimation(self.pm3_anm_o)

        self.t5 = self.state2.addTransition(self.value_decreased, self.state1)
        self.t5.addAnimation(self.pm1_anm)
        self.t5.addAnimation(self.pm1_anm_o)
        self.t5.addAnimation(self.pm2_anm)
        self.t5.addAnimation(self.pm2_anm_o)
        self.t5.addAnimation(self.pm3_anm)
        self.t5.addAnimation(self.pm3_anm_o)

        self.t6 = self.state3.addTransition(self.value_decreased, self.state2)
        self.t6.addAnimation(self.pm1_anm)
        self.t6.addAnimation(self.pm1_anm_o)
        self.t6.addAnimation(self.pm2_anm)
        self.t6.addAnimation(self.pm2_anm_o)
        self.t6.addAnimation(self.pm3_anm)
        self.t6.addAnimation(self.pm3_anm_o)

        self.t1 = self.state1.addTransition(self.value_increased, self.state2)
        self.t1.addAnimation(self.pm1_anm)
        self.t1.addAnimation(self.pm1_anm_o)
        self.t1.addAnimation(self.pm2_anm)
        self.t1.addAnimation(self.pm2_anm_o)
        self.t1.addAnimation(self.pm3_anm)
        self.t1.addAnimation(self.pm3_anm_o)

        self.t2 = self.state2.addTransition(self.value_increased, self.state3)
        self.t2.addAnimation(self.pm1_anm)
        self.t2.addAnimation(self.pm1_anm_o)
        self.t2.addAnimation(self.pm2_anm)
        self.t2.addAnimation(self.pm2_anm_o)
        self.t2.addAnimation(self.pm3_anm)
        self.t2.addAnimation(self.pm3_anm_o)

        self.t3 = self.state3.addTransition(self.value_increased, self.state1)
        self.t3.addAnimation(self.pm1_anm)
        self.t3.addAnimation(self.pm1_anm_o)
        self.t3.addAnimation(self.pm2_anm)
        self.t3.addAnimation(self.pm2_anm_o)
        self.t3.addAnimation(self.pm3_anm)
        self.t3.addAnimation(self.pm3_anm_o)

        # initial fill
        if self.pix_list:
            self.pm_list = [self.pm1, self.pm2, self.pm3]
            for i, pm in enumerate(self.pm_list):
                pixmap = Qt4Gui.QPixmap(self.pix_list[i % len(self.pix_list)])
                if not pixmap.isNull():
                    pm.add_pixmap(pixmap.scaledToWidth(640, QtCore.Qt.SmoothTransformation))

            self.previewGraphicsView.setSceneRect(self.pm1.pixmap_item.boundingRect())
            self.previewGraphicsView.fitInView(self.pm1.pixmap_item.boundingRect(), QtCore.Qt.KeepAspectRatio)

        self.imagesSlider.setValue(0)

        if not self.machine.isRunning():
            self.machine.addState(self.state1)
            self.machine.addState(self.state2)
            self.machine.addState(self.state3)
            self.machine.setInitialState(self.state1)
            self.machine.start()
Example #5
0
    def create_scene(self):
        self.scene.clear()

        # self.scene.setBackgroundBrush(QtCore.Qt.black)

        self.pm1 = Pixmap()
        self.pm2 = Pixmap()
        self.pm3 = Pixmap()

        self.scene.addItem(self.pm1.pixmap_item)
        self.scene.addItem(self.pm2.pixmap_item)
        self.scene.addItem(self.pm3.pixmap_item)

        # animation
        self.machine = QtCore.QStateMachine()
        self.state1 = QtCore.QState(self.machine)
        self.state2 = QtCore.QState(self.machine)
        self.state3 = QtCore.QState(self.machine)

        self.state1.assignProperty(self.pm1, 'pos', QtCore.QPoint(0, 0))
        self.state1.assignProperty(self.pm1, 'opacity', 1)

        self.state2.assignProperty(self.pm1, 'pos', QtCore.QPoint(-255, 0))
        self.state2.assignProperty(self.pm1, 'opacity', 0)

        self.state3.assignProperty(self.pm1, 'pos', QtCore.QPoint(255, 0))
        self.state3.assignProperty(self.pm1, 'opacity', 0)

        self.state1.assignProperty(self.pm2, 'pos', QtCore.QPoint(255, 0))
        self.state1.assignProperty(self.pm2, 'opacity', 0)

        self.state2.assignProperty(self.pm2, 'pos', QtCore.QPoint(0, 0))
        self.state2.assignProperty(self.pm2, 'opacity', 1)

        self.state3.assignProperty(self.pm2, 'pos', QtCore.QPoint(-255, 0))
        self.state3.assignProperty(self.pm2, 'opacity', 0)

        self.state1.assignProperty(self.pm3, 'pos', QtCore.QPoint(-255, 0))
        self.state1.assignProperty(self.pm3, 'opacity', 0)

        self.state2.assignProperty(self.pm3, 'pos', QtCore.QPoint(255, 0))
        self.state2.assignProperty(self.pm3, 'opacity', 0)

        self.state3.assignProperty(self.pm3, 'pos', QtCore.QPoint(0, 0))
        self.state3.assignProperty(self.pm3, 'opacity', 1)

        self.machine.setInitialState(self.state1)

        self.pm1_anm = QtCore.QPropertyAnimation(self.pm1, 'pos', self)
        self.pm1_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm1_anm.setDuration(300)

        self.pm1_anm_o = QtCore.QPropertyAnimation(self.pm1, 'opacity', self)
        self.pm1_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm1_anm_o.setDuration(200)

        self.pm2_anm = QtCore.QPropertyAnimation(self.pm2, 'pos', self)
        self.pm2_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm2_anm.setDuration(300)

        self.pm2_anm_o = QtCore.QPropertyAnimation(self.pm2, 'opacity', self)
        self.pm2_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm2_anm_o.setDuration(200)

        self.pm3_anm = QtCore.QPropertyAnimation(self.pm3, 'pos', self)
        self.pm3_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm3_anm.setDuration(300)

        self.pm3_anm_o = QtCore.QPropertyAnimation(self.pm3, 'opacity', self)
        self.pm3_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo)
        self.pm3_anm_o.setDuration(200)

        self.t4 = self.state1.addTransition(self.value_decreased, self.state3)
        self.t4.addAnimation(self.pm1_anm)
        self.t4.addAnimation(self.pm1_anm_o)
        self.t4.addAnimation(self.pm2_anm)
        self.t4.addAnimation(self.pm2_anm_o)
        self.t4.addAnimation(self.pm3_anm)
        self.t4.addAnimation(self.pm3_anm_o)

        self.t5 = self.state2.addTransition(self.value_decreased, self.state1)
        self.t5.addAnimation(self.pm1_anm)
        self.t5.addAnimation(self.pm1_anm_o)
        self.t5.addAnimation(self.pm2_anm)
        self.t5.addAnimation(self.pm2_anm_o)
        self.t5.addAnimation(self.pm3_anm)
        self.t5.addAnimation(self.pm3_anm_o)

        self.t6 = self.state3.addTransition(self.value_decreased, self.state2)
        self.t6.addAnimation(self.pm1_anm)
        self.t6.addAnimation(self.pm1_anm_o)
        self.t6.addAnimation(self.pm2_anm)
        self.t6.addAnimation(self.pm2_anm_o)
        self.t6.addAnimation(self.pm3_anm)
        self.t6.addAnimation(self.pm3_anm_o)

        self.t1 = self.state1.addTransition(self.value_increased, self.state2)
        self.t1.addAnimation(self.pm1_anm)
        self.t1.addAnimation(self.pm1_anm_o)
        self.t1.addAnimation(self.pm2_anm)
        self.t1.addAnimation(self.pm2_anm_o)
        self.t1.addAnimation(self.pm3_anm)
        self.t1.addAnimation(self.pm3_anm_o)

        self.t2 = self.state2.addTransition(self.value_increased, self.state3)
        self.t2.addAnimation(self.pm1_anm)
        self.t2.addAnimation(self.pm1_anm_o)
        self.t2.addAnimation(self.pm2_anm)
        self.t2.addAnimation(self.pm2_anm_o)
        self.t2.addAnimation(self.pm3_anm)
        self.t2.addAnimation(self.pm3_anm_o)

        self.t3 = self.state3.addTransition(self.value_increased, self.state1)
        self.t3.addAnimation(self.pm1_anm)
        self.t3.addAnimation(self.pm1_anm_o)
        self.t3.addAnimation(self.pm2_anm)
        self.t3.addAnimation(self.pm2_anm_o)
        self.t3.addAnimation(self.pm3_anm)
        self.t3.addAnimation(self.pm3_anm_o)

        # initial fill
        if self.pix_list:
            self.pm_list = [self.pm1, self.pm2, self.pm3]
            for i, pm in enumerate(self.pm_list):
                pm.add_pixmap(self.pix_list[i % len(self.pix_list)])

            self.previewGraphicsView.setSceneRect(
                self.pm1.pixmap_item.boundingRect())
            self.previewGraphicsView.fitInView(
                self.pm1.pixmap_item.boundingRect(), QtCore.Qt.KeepAspectRatio)

        self.imagesSlider.setValue(0)