def run(self): self.states.addState(self.rootState) self.states.setInitialState(self.rootState) self.rootState.setInitialState(self.centeredState) for i, item in enumerate(self.items): anim = QtCore.QPropertyAnimation(item, b'pos') anim.setDuration(750) anim.setEasingCurve(QtCore.QEasingCurve.InOutBack) self.group.addAnimation(anim) self.anim = QtCore.QPropertyAnimation(self.endItem, b'pos') self.anim.setDuration(750) self.anim.setEasingCurve(QtCore.QEasingCurve.InOutBack) self.group.addAnimation(self.anim) self.trans = self.rootState.addTransition(endSignal.sig, self.endState) self.trans.addAnimation(self.group) for i in range(0, len(self.names)): self.trans = self.rootState.addTransition(itemsSignals[i].sig, self.tiledStates[i]) self.trans.addAnimation(self.group) self.states.start() global start start = True
def __init__(self, title, message, parent=None): super(Toast, self).__init__(parent) self.setupUi() self.initWidgets() self.timer = QtCore.QTimer(parent) self.titleLabel.setText(title) self.messageLabel.setText(message) self.setFrameShape(QtWidgets.QFrame.StyledPanel) self.setFrameShadow(QtWidgets.QFrame.Plain) eff = QtWidgets.QGraphicsOpacityEffect(self) self.setGraphicsEffect(eff) self.showAnim = QtCore.QPropertyAnimation(eff, b'opacity', parent) self.showAnim.setDuration(Toast.settings.get('fadeInTime')) self.showAnim.setStartValue(0) self.showAnim.setEndValue(1) self.showAnim.setEasingCurve( QtCore.QEasingCurve( QtCore.QEasingCurve.Type( Toast.settings.get('showAnimationType')))) self.hideAnim = QtCore.QPropertyAnimation(eff, b'opacity', parent) self.hideAnim.setDuration(Toast.settings.get('fadeOutTime')) self.hideAnim.setStartValue(1) self.hideAnim.setEndValue(0) self.hideAnim.setEasingCurve( QtCore.QEasingCurve( QtCore.QEasingCurve.Type( Toast.settings.get('hideAnimationType')))) self.initSignalsAndSlot()
def mousePressEvent(self, event): if not self.__enabled: return self.__circlemove = QtCore.QPropertyAnimation(self.__circle, b"pos") self.__circlemove.setDuration(self.__duration) self.__ellipsemove = QtCore.QPropertyAnimation(self.__background, b"size") self.__ellipsemove.setDuration(self.__duration) xs = 2 y = 2 xf = self.width() - 22 hback = 20 isize = QtCore.QSize(hback, hback) bsize = QtCore.QSize(self.width() - 4, hback) if self.__value: xf = 2 xs = self.width() - 22 bsize = QtCore.QSize(hback, hback) isize = QtCore.QSize(self.width() - 4, hback) self.__circlemove.setStartValue(QtCore.QPoint(xs, y)) self.__circlemove.setEndValue(QtCore.QPoint(xf, y)) self.__ellipsemove.setStartValue(isize) self.__ellipsemove.setEndValue(bsize) self.__circlemove.start() self.__ellipsemove.start() self.__value = not self.__value self.toggled.emit()
def _doToggleAnim(self, xStart, xEnd, startColor, endColor): self.anim = QtCore.QPropertyAnimation(self.toggle_switch, 'pos') self.anim.setDuration(100) self.anim.setStartValue(QtCore.QPoint(xStart, self.padding)) self.anim.setEndValue(QtCore.QPoint(xEnd, self.padding)) self.anim.start(QtCore.QAbstractAnimation.DeleteWhenStopped) self.animbg = QtCore.QPropertyAnimation(self.toggle_bg, 'color') self.animbg.setDuration(200) self.animbg.setStartValue(startColor) self.animbg.setEndValue(endColor) self.animbg.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
def __init__(self, parent=None): super(MaterialCheckBox, self).__init__(parent) self._is_checked = False style = QtWidgets.QApplication.style() icon = style.standardIcon(QtWidgets.QStyle.SP_DialogApplyButton) checkedIcon = MaterialIcon(self, icon.pixmap(24, 24)) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) uncheckedIcon = MaterialIcon(self, icon.pixmap(24, 24)) stateMachine = QtCore.QStateMachine(self) checkedState = QtCore.QState() checkedState.assignProperty(self, b"checked", True) checkedState.assignProperty(checkedIcon, b"opacity", 1.0) checkedState.assignProperty(uncheckedIcon, b"opacity", 0.0) uncheckedState = QtCore.QState() uncheckedState.assignProperty(self, b"checked", False) uncheckedState.assignProperty(checkedIcon, b"opacity", 0.0) uncheckedState.assignProperty(uncheckedIcon, b"opacity", 1.0) stateMachine.addState(checkedState) stateMachine.addState(uncheckedState) stateMachine.setInitialState(uncheckedState) duration = 2000 transition1 = checkedState.addTransition(self.clicked, uncheckedState) animation1 = QtCore.QPropertyAnimation(checkedIcon, b"opacity", self, duration=duration) transition1.addAnimation(animation1) animation2 = QtCore.QPropertyAnimation(uncheckedIcon, b"opacity", self, duration=duration) transition1.addAnimation(animation2) transition2 = uncheckedState.addTransition(self.clicked, checkedState) animation3 = QtCore.QPropertyAnimation(checkedIcon, b"opacity", self, duration=duration) transition2.addAnimation(animation3) animation4 = QtCore.QPropertyAnimation(uncheckedIcon, b"opacity", self, duration=duration) transition2.addAnimation(animation4) stateMachine.start()
def __init__(self, parent=None, title="QCollapse"): """ QCollapse is a collapsible widget with transition Args: parent (QWidget): parent widget for the QCollapseWidget title (str): Title name for the widget """ super(QCollapse, self).__init__(parent=parent) # create main layout main_layout = QtWidgets.QVBoxLayout(self) main_layout.setSpacing(0) main_layout.setContentsMargins(0, 0, 0, 0) # create arrow button self.arrow_button = QtWidgets.QToolButton() self.arrow_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon) self.arrow_button.setArrowType(QtCore.Qt.RightArrow) self.arrow_button.setText(title) self.arrow_button.setCheckable(True) self.arrow_button.setChecked(False) # create collapsible scroll area. This will reception use layout self.scrool_area = QtWidgets.QScrollArea() self.scrool_area.setFrameStyle(6) self.scrool_area.setMinimumHeight(0) self.scrool_area.setMaximumHeight(0) self.scrool_area.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) # adds widgets to layout main_layout.addWidget(self.arrow_button) main_layout.addWidget(self.scrool_area) # creates animation group self.animation_group = QtCore.QParallelAnimationGroup() # declares property to expand the QCollapse widget self.animation_group.addAnimation(QtCore.QPropertyAnimation( self, "minimumHeight")) self.animation_group.addAnimation(QtCore.QPropertyAnimation( self, "maximumHeight")) # declares property to expand the scroll area widget self.animation_group.addAnimation(QtCore.QPropertyAnimation( self.scrool_area, "maximumHeight")) # adds signal connection self.arrow_button.clicked.connect(self.__run_animation)
def _animateExpand(self, value): opacity_anim = QtCore.QPropertyAnimation(self.main_widget_proxy, "opacity") opacity_anim.setStartValue(not(value)); opacity_anim.setEndValue(value) opacity_anim.setDuration(200) opacity_anim_curve = QtCore.QEasingCurve() if value is True: opacity_anim_curve.setType(QtCore.QEasingCurve.InQuad) else: opacity_anim_curve.setType(QtCore.QEasingCurve.OutQuad) opacity_anim.setEasingCurve(opacity_anim_curve) size_anim = QtCore.QPropertyAnimation(self, "geometry") geometry = self.geometry() width = geometry.width() x, y, _, _ = geometry.getCoords() size_start = QtCore.QRect(x, y, width, int(not(value)) * 150) size_end = QtCore.QRect(x, y, width, value * 150) size_anim.setStartValue(size_start) size_anim.setEndValue(size_end) size_anim.setDuration(300) size_anim_curve = QtCore.QEasingCurve() if value: size_anim_curve.setType(QtCore.QEasingCurve.InQuad) else: size_anim_curve.setType(QtCore.QEasingCurve.OutQuad) size_anim.setEasingCurve(size_anim_curve) self._animation = QtCore.QSequentialAnimationGroup() if value: self.main_widget_proxy.setOpacity(0) self._animation.addAnimation(size_anim) self._animation.addAnimation(opacity_anim) else: self.main_widget_proxy.setOpacity(1) self._animation.addAnimation(opacity_anim) self._animation.addAnimation(size_anim) size_anim.valueChanged.connect(self._forceResize) self._animation.finished.connect(self._animation.clear) if not value: self._animation.finished.connect(self.deleteWidget) self._animation.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
def __init__(self, *args, **kwargs): QtWidgets.QLabel.__init__(self, *args, **kwargs) self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.setStyleSheet("background-color: grey;") self.anim = QtCore.QPropertyAnimation(self,'geometry') self.anim.setDuration(300) self.anim.setEasingCurve(QtCore.QEasingCurve.InOutCubic) self.rect = None self.toggled = False self.small = QtCore.QRect(0,0,200,10) self.big = QtCore.QRect(10,10,200,50) self.myfont = self.font() self.setFont(self.myfont) # self.myfont.setFixedPitch(True) # self.myfont.setRawMode(True) # self.myfont.setStretch(50) # self.myfont.setStyleHint(QtGui.QFont.SansSerif, QtGui.QFont.PreferMatch) # self.move(self.big.x(), self.big.y()) # self.resize(self.big.width(),self.big.height()) # self.setMinimumHeight(self.small.height()) # self.setMaximumHeight(self.big.height()) self.setBaseSize(QtCore.QSize(self.big.width(), self.big.height())) # self.updateGeometry() # self.setGeometry(10,10,300,50) print('Height: {0}'.format(self.sizeHint().height())) print('Width: {0}'.format(self.sizeHint().width()))
def start_animation2(self): self.anim2 = QtCore.QPropertyAnimation(self.label2, b"geometry") self.anim2.setDuration(3000) self.anim2.setStartValue(QtCore.QRect(300, 100, 5, 5)) self.anim2.setEndValue(QtCore.QRect(275, 75, 65, 65)) self.label2.show() self.anim2.start()
def __init__(self, parent=None): super().__init__(parent) self.setFixedSize(200, 200) # color constants self.dark = "#3B3A44" self.light = "#4A4953" self.color = "#75ECB5" # text constants self.module_name = "CPU" self.postfix = "average" # timer with an interval of 1 sec self.timer = QtCore.QTimer() self.timer.setInterval(2000) self.timer.timeout.connect(self.onTimeout) self.timer.start() # animation initialization self._percent = 0 self._animation = QtCore.QPropertyAnimation(self, b"percent", duration=400) self._animation.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.percentChanged.connect(self.update)
def __init_graphic_effects(self): """ Initializes graphic effects. """ # Opacityeffect for fade in/out self.opacityEffect = QtWidgets.QGraphicsOpacityEffect(self) # Fade in animation self.fadeInAnimation = QtCore.QPropertyAnimation( self.opacityEffect, safe_encode("opacity")) self.fadeInAnimation.setStartValue(0.0) self.fadeInAnimation.setEndValue(1.0) # Fade out animation self.fadeOutAnimation = QtCore.QPropertyAnimation( self.opacityEffect, safe_encode("opacity")) self.fadeOutAnimation.setStartValue(1.0) self.fadeOutAnimation.setEndValue(0.0)
def __init__(self, parent=None): super().__init__(parent) self.setFixedSize(150, 150) # color constants self.dark = "#3B3A44" self.light = "#4A4953" self.color = "#75ECB5" # text constants self.module_name = "RAM" self.postfix = "average" # timer with an interval of 1 sec self.timer = QtCore.QTimer() self.timer.setInterval(2000) self.timer.timeout.connect(self.onTimeout) self.timer.start() # animation initialization self._percent = 0 self._animation = QtCore.QPropertyAnimation(self, b"percent", duration=400) self._animation.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.percentChanged.connect(self.update) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) self.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.X11BypassWindowManagerHint )
def initView(self): self.ball = Ball() self.anim = QtCore.QPropertyAnimation(self.ball, b'pos') self.anim.setDuration(10000) self.anim.setLoopCount(2) self.anim.setStartValue(QtCore.QPointF(5, 30)) self.anim.setKeyValueAt(0.3, QtCore.QPointF(80, 30)) self.anim.setKeyValueAt(0.5, QtCore.QPointF(200, 30)) self.anim.setKeyValueAt(0.8, QtCore.QPointF(250, 250)) self.anim.setEndValue(QtCore.QPointF(290, 30)) self.scene = QtWidgets.QGraphicsScene(self) self.scene.setSceneRect(0, 0, 300, 300) self.scene.addItem(self.ball.pixmap_item) self.setScene(self.scene) self.setWindowTitle("Ball Animation") self.setRenderHint(QtGui.QPainter.Antialiasing) self.setGeometry(300, 300, 500, 350) self.anim.start() self.show()
def do_animation(self): self.anim = QtCore.QPropertyAnimation(self, b"size") self.anim.setDuration(250) self.anim.setEasingCurve(QtCore.QEasingCurve.InOutBack) self.anim.setStartValue(QtCore.QSize(self.width, self.height)) self.anim.setEndValue(QtCore.QSize(self.width, self.get_height())) self.anim.start()
def setupUI(self): mainLayout = VertBox() self.layout = QtWidgets.QHBoxLayout() self.layout.setContentsMargins(1, 1, 1, 1) if self.labelName != '': self.label = QtWidgets.QLabel(self.labelName) self.layout.addWidget(self.label) self.edit = QtWidgets.QLineEdit() self.edit.setValidator(CharNameValidator()) color1 = self.edit.palette().color(self.edit.backgroundRole()) color2 = QtGui.QColor(255, 0, 0) self.backColorAnim = QtCore.QPropertyAnimation(self, "backColor") self.backColorAnim.setDuration(250) self.backColorAnim.setLoopCount(4) self.backColorAnim.setStartValue(color1) self.backColorAnim.setKeyValueAt(0.5, color2) self.backColorAnim.setEndValue(color1) self.layout.addWidget(self.edit) mainLayout.addLayout(self.layout) self.setLayout(mainLayout)
def start_progress_timer(self, time): if self.progress_animation: self.progress_animation.stop() self.progress_animation = QtCore.QPropertyAnimation(self, b"progress") self.progress_animation.setStartValue(0) self.progress_animation.setEndValue(10000) self.progress_animation.setDuration(time) self.progress_animation.start()
def __init__(self, title="", parent=None): """ Creates a Widget that can collapse and un-collapse at the click of a toggle button Args: title: Displayed title of the Collapsible Widget parent: Collapsed Widget's parent """ super(CollapsibleWidget, self).__init__(parent) self.toggle_button = QtWidgets.QToolButton(text=title, checkable=True, checked=False) self.toggle_button.setStyleSheet("QToolButton { border: none; }") self.toggle_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon) self.toggle_button.setArrowType(QtCore.Qt.RightArrow) self.toggle_button.pressed.connect(self.on_pressed) self.toggle_animation = QtCore.QParallelAnimationGroup(self) self.content_area = QtWidgets.QScrollArea(maximumHeight=0, minimumHeight=0) self.content_area.setWidgetResizable(True) self.content_area.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame) lay = QtWidgets.QVBoxLayout(self) lay.setSpacing(0) lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(self.toggle_button) lay.addWidget(self.content_area) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"minimumHeight")) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"maximumHeight")) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.content_area, b"maximumHeight")) self.is_set_up = False
def slideInWgt(self, newwidget): if self.m_active: return self.m_active = True _now = self.currentIndex() _next = self.indexOf(newwidget) if _now == _next: self.m_active = False return offsetx, offsety = self.frameRect().width(), self.frameRect().height() self.widget(_next).setGeometry(self.frameRect()) if not self.m_direction == QtCore.Qt.Horizontal: if _now < _next: offsetx, offsety = 0, -offsety else: offsetx = 0 else: if _now < _next: offsetx, offsety = -offsetx, 0 else: offsety = 0 pnext = self.widget(_next).pos() pnow = self.widget(_now).pos() self.m_pnow = pnow offset = QtCore.QPoint(offsetx, offsety) self.widget(_next).move(pnext - offset) self.widget(_next).show() self.widget(_next).raise_() anim_group = QtCore.QParallelAnimationGroup( self, finished=self.animationDoneSlot) for index, start, end in zip((_now, _next), (pnow, pnext - offset), (pnow + offset, pnext)): animation = QtCore.QPropertyAnimation( self.widget(index), b"pos", duration=self.m_speed, easingCurve=self.m_animationtype, startValue=start, endValue=end, ) anim_group.addAnimation(animation) self.m_next = _next self.m_now = _now self.m_active = True anim_group.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
def __init__(self, title="", parent=None): """ Implementation of collapsible boxes: https://stackoverflow.com/a/52617714/11483674 """ super().__init__(parent) self.toggle_button = QtWidgets.QToolButton( text=title, checkable=True, checked=False ) self.toggle_button.setStyleSheet("QToolButton { border: none; }") self.toggle_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon ) self.toggle_button.setArrowType(QtCore.Qt.RightArrow) self.toggle_button.pressed.connect(self.on_pressed) self.toggle_animation = QtCore.QParallelAnimationGroup(self) self.content_area = QtWidgets.QScrollArea( maximumHeight=0, minimumHeight=0 ) self.content_area.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed ) self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame) lay = QtWidgets.QVBoxLayout(self) lay.setSpacing(0) lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(self.toggle_button) lay.addWidget(self.content_area) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"minimumHeight") ) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"maximumHeight") ) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.content_area, b"maximumHeight") )
def toggle_menu(self, min_extend, max_extend): """Creates smooth opening and closing animation for the projects bar""" width = self.window.sidebar_frame.width() width_extend = max_extend if width == min_extend else min_extend self.window.animation = QtCore.QPropertyAnimation( self.window.sidebar_frame, b"maximumWidth") self.window.animation.setDuration(500) self.window.animation.setStartValue(width) self.window.animation.setEndValue(width_extend) self.window.animation.setEasingCurve(QtCore.QEasingCurve.InOutCubic) self.window.animation.start()
def __init__(self, parent=None, index=0): super(BlueprintButton, self).__init__(parent) self.index = index color1 = QtGui.QColor(255, 255, 255) color2 = QtGui.QColor(255, 0, 0) self.backColorAnim = QtCore.QPropertyAnimation(self, "backColor") self.backColorAnim.setDuration(250) self.backColorAnim.setLoopCount(4) self.backColorAnim.setStartValue(color1) self.backColorAnim.setKeyValueAt(0.5, color2) self.backColorAnim.setEndValue(color1)
def _animate_expand(self, value): # opacity_anim = QtCore.QPropertyAnimation(self.main_widget_proxy, # 'opacity') # opacity_anim.setStartValue(not(value)) # opacity_anim.setEndValue(value) # opacity_anim.setDuration(200) # opacity_anim_curve = QtCore.QEasingCurve() """if value: opacity_anim_curve.setType(QtCore.QEasingCurve.InQuad) else: opacity_anim_curve.setType(QtCore.QEasingCurve.OutQuad) opacity_anim.setEasingCurve(opacity_anim_curve) """ size_anim = QtCore.QPropertyAnimation(self, 'geometry') geometry = self.geometry() width = geometry.width() x, y, _, _ = geometry.getCoords() # _ variables accept info then dump size_start = QtCore.QRect(x, y, width, int(not (value) * 150)) size_end = QtCore.QRect(x, y, width, int(value) * 150) size_anim.setStartValue(size_start) size_anim.setEndValue(size_end) size_anim.setDuration(300) size_anim_curve = QtCore.QEasingCurve() if value: size_anim_curve.setType(QtCore.QEasingCurve.InQuad) else: size_anim_curve.setType(QtCore.QEasingCurve.OutQuad) size_anim.setEasingCurve(size_anim_curve) self._animation = size_anim """ if value: self.main_widget_proxy.setOpacity(0) self._animation.addAnimation(size_anim) self._animation.addAnimation(opacity_anim) else: self.main_widget_proxy.setOpacity(1) self._animation.addAnimation(opacity_anim) self._animation.addAnimation(size_anim) # self._animation.finished.connect(self._animation.clear) """ size_anim.valueChanged.connect(self._force_resize) if not value: size_anim.finished.connect(self.delete_widget) size_anim.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
def __init__(self, application): super(Ui, self).__init__() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) signal.signal(signal.SIGINT, signal.SIG_DFL) self.application = application if application.window_layout == Layout.MINI: QUiLoader().load(":/layout_mini.ui", self) else: QUiLoader().load(":/layout_full.ui", self) self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.Tool) self.setWindowOpacity(application.window_opacity) self.move(application.window_pos_x, application.window_pos_y) self.saved_geometry = None # Should be set after first show action self.track_title_label = self.findChild(QLabel, 'track_title') self.artist_label = self.findChild(QLabel, 'artist') self.volume_slider = self.findChild(QSlider, 'volume') self.album_cover = self.findChild(QLabel, 'album_cover') self.placeholder = self.findChild(QLabel, 'slider_value') self.slider = self.findChild(QSlider, 'volume') self.slider_timer_id = -1 self.slider.valueChanged.connect(self.on_slider_value_changed) self.player_interface = None self.properties = None self.prev_btn = self.findChild(QPushButton, 'prev_btn') self.pause_btn = self.findChild(QPushButton, 'pause_btn') self.next_btn = self.findChild(QPushButton, 'next_btn') self.prev_btn.clicked.connect(lambda: self.player_interface.Previous() if self.properties else False) self.pause_btn.clicked.connect(lambda: self.player_interface.PlayPause() if self.properties else False) self.next_btn.clicked.connect(lambda: self.player_interface.Next() if self.properties else False) self.hide_timer_id = -1 self.installEventFilter(self) self.application.communicator.resetHideTimer.connect(self.reset_hide_timer) self.long_load_timer_id = -1 self.is_album_cover_loaded = False self.latest_cover_url = "" self.show_hide_animation = QtCore.QPropertyAnimation(self, b"geometry") self.show_hide_animation.setEasingCurve(QEasingCurve.InOutQuad) self.show_hide_animation.finished.connect(self.on_animation_finished) self.is_animation_started = False self.application.communicator.showWindow.connect(lambda: self.show_hide_with_animation(QEvent.Show))
def __init__(self, parent=None): super(PanelPicker, self).__init__(parent=parent) effect = QtWidgets.QGraphicsOpacityEffect(self) self.setGraphicsEffect(effect) self.fade_in = QtCore.QPropertyAnimation( effect, QtCore.QByteArray('opacity'.encode('utf-8')) ) self.fade_in.setStartValue(0.0) self.fade_in.setEndValue(0.5) self.fade_in.setDuration(500) self.fade_in.setEasingCurve(QtCore.QEasingCurve.InOutQuad) self._mouse_pos = None self._click_pos = None self._offset_pos = None self._capture_rect = QtCore.QRect() self.setWindowFlags( QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint ) self.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.setMouseTracking(True) self.installEventFilter(self) self.panels = {} self.panel = None panels = cmds.lsUI(panels=True) if not panels: return for panel in panels: if not cmds.modelPanel(panel, exists=True): continue ptr = OpenMayaUI.MQtUtil.findControl(panel) if not ptr: continue widget = shiboken2.wrapInstance(int(ptr), QtWidgets.QWidget) if not widget: continue if not widget.isVisible(): continue self.panels[panel] = widget
def __init__(self, title="", parent=None): super(CollapsibleBox, self).__init__(parent) self.toggle_button = QtWidgets.QToolButton(text=title, checkable=True, checked=True) self.toggle_button.setStyleSheet( "QToolButton { border: none;\nbackground-color: rgb(100,100,100); }" ) self.toggle_button.setSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) self.toggle_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon) self.toggle_button.setArrowType(QtCore.Qt.DownArrow) self.toggle_button.pressed.connect(self.on_pressed) self.toggle_animation = QtCore.QParallelAnimationGroup(self) self.content_area = QtWidgets.QScrollArea(maximumHeight=0, minimumHeight=0) self.content_area.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame) lay = QtWidgets.QVBoxLayout(self) lay.setSpacing(0) lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(self.toggle_button) lay.addWidget(self.content_area) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"minimumHeight")) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"maximumHeight")) self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.content_area, b"maximumHeight")) self.toggle_animation.start()
def toggleAnimation(self): self.animation = QtCore.QPropertyAnimation(self.customLayer, "maximumHeight") if self.showCustomLayer == 0: self.animation.setDuration(300) self.animation.setStartValue(100) self.animation.setEndValue(0) self.animation.start() self.showCustomLayer = 1 else: self.animation.setDuration(200) self.animation.setStartValue(0) self.animation.setEndValue(100) self.animation.start() self.showCustomLayer = 0
def _setLyricIndex(self, lyricIndex): self._logger.debug("Set lyric index to %d", lyricIndex) for index in range(len(self._lyrics)): lyricLabel: QtWidgets.QLabel = gg(self._layout.itemAt(index + 1).widget()) color = QtGui.QColor("#e1413c" if index == lyricIndex else "#23557d") palette = lyricLabel.palette() palette.setColor(QtGui.QPalette.ColorRole.WindowText, color) lyricLabel.setPalette(palette) originalValue = self.verticalScrollBar().value() targetValue = lyricLabel.pos().y() - self.height() // 2 + lyricLabel.height() // 2 index == lyricIndex and (lambda animation=QtCore.QPropertyAnimation( self.verticalScrollBar(), gg(b"value"), self): [ animation.setStartValue(originalValue), animation.setEndValue(targetValue), animation.start(QtCore.QPropertyAnimation.DeletionPolicy.DeleteWhenStopped) ])() self._logger.debug("Lyrics refreshed")
def __init__(self, parent): """ A loading overlay screen that blocks user input and displays load progress over it's parent widget. """ super().__init__(parent) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents, False) # Opacity effect / animation self.opacityEffect = QtWidgets.QGraphicsOpacityEffect() self.setGraphicsEffect(self.opacityEffect) self.opacityAni = QtCore.QPropertyAnimation(self.opacityEffect, b"opacity") self.opacityAni.setStartValue(0.0) self.opacityAni.setEndValue(1.0) self.opacityAni.setDuration(350) self.opacityAni.finished.connect(self._hideIfFadedOut) # Loading label self.label = QtWidgets.QLabel( "Loading..." ) # TODO: Come up with better system of setting loading text. Or add a progress bar self.label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) self.label.setStyleSheet( """ color: rgb(80, 90, 90); font-size: 48px; font-family: arial, helvetica; """ ) # Animal images self.animalLabel = QtWidgets.QLabel() self.animalLabel.setPixmap(ctx.loadingAnimalsPixmap) self.animalLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom) # Main layout layout = QtWidgets.QVBoxLayout() layout.addWidget(self.animalLabel) layout.addWidget(self.label) self.setLayout(layout) # Extra overlays may be involved if there are floating dock widgets self.extraOverlays = []
def animate_bubble(self, label, label_bool, next_label, next_label_bool): if self.caller_label1_bool: self.caller_label1.hide() elif self.caller_label2_bool: self.caller_label2.hide() elif self.caller_label3_bool: self.caller_label3.hide() label.setPixmap(QtGui.QPixmap(self.picture)) label.setScaledContents(True) start_pnt = QtCore.QPoint(self.pnt11, self.pnt12) end_ptn = QtCore.QPoint(self.pnt21, self.pnt22) start_size = QtCore.QSize(self.a1, self.a2) end_size = QtCore.QSize(self.b1, self.b2) anim = QtCore.QPropertyAnimation(label, b"geometry") anim.setDuration(50) anim.setStartValue(QtCore.QRect(start_pnt, start_size)) anim.setEndValue(QtCore.QRect(end_ptn, end_size)) anim.start() self.increase(label, label_bool, next_label, next_label_bool)
def __init__(self, server, job, root, source, proxy, parent=None): super(ScreenCapture, self).__init__(parent=parent) self.server = server self.job = job self.root = root self.source = source self.proxy = proxy self.capture_path = None effect = QtWidgets.QGraphicsOpacityEffect(self) self.setGraphicsEffect(effect) self.fade_in = QtCore.QPropertyAnimation( effect, QtCore.QByteArray('opacity'.encode('utf-8')) ) self.fade_in.setStartValue(0.0) self.fade_in.setEndValue(0.5) self.fade_in.setDuration(500) self.fade_in.setEasingCurve(QtCore.QEasingCurve.InOutQuad) self._mouse_pos = None self._click_pos = None self._offset_pos = None self._capture_rect = QtCore.QRect() self.setWindowFlags( QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint ) self.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.setCursor(QtCore.Qt.CrossCursor) self.setMouseTracking(True) self.installEventFilter(self) self._connect_signals()