def __init__(self, parent): super().__init__(parent) # The popup window will hide itself when the mouse moves this distance # away from the window self._hidePopupDistance = 50 self._hidePersistantPopupDistance = 150 self._fullOpacityMargin = 10 self._extraAutoMargin = 0 # Install an eventFilter so that we can track mouse positions # and hide the popup when the user doesn't mouse over it. # Mouse events exist in the viewport, if the parent has one. try: filterable = self.parent().viewport() except AttributeError: filterable = self.parent() finally: filterable.installEventFilter(self) # Setup the opacity effect self._opacityEffect = QtWidgets.QGraphicsOpacityEffect(opacity=1) self.setGraphicsEffect(self._opacityEffect) # Don't show on construction. # Parent must call "popup" to show self.hide() # Hide automatically by default. self._persistant = False # Mouse tracking state used to keep track of what the parent's # mouse tracking state was before we changed it. self._mouseTrackingState = False
def __init__(self, parent=None, emptyText="Hint"): super().__init__(parent=parent) self.backgroundLabel = QLabel(self) self.backgroundLabel.setAttribute( QtCore.Qt.WA_TransparentForMouseEvents) self.backgroundLabel.setWordWrap(True) self.backgroundLabel.show() self.openFileAction = self.doNothing self.backgroundLabel.setAlignment(QtCore.Qt.AlignCenter) self.backgroundLabel.setText(emptyText) self.backgroundLabel.resize(400, 200) self.opacity = QtWidgets.QGraphicsOpacityEffect(self) self.opacity.setOpacity(0.5) self.backgroundLabel.setGraphicsEffect(self.opacity) self.backgroundLabel.setStyleSheet( "background-color: transparent; font-size: 15pt; font-weight: light;" ) self.setColumnCount(5) self.setIconSize(QtCore.QSize(32, 32)) self.setAutoScroll(True) self.setVerticalScrollMode(QtWidgets.QTreeWidget.ScrollPerPixel) self.setHorizontalScrollMode(QtWidgets.QTreeWidget.ScrollPerPixel) self.setColumnWidth(0, 300) self.setSelectionMode( QtWidgets.QTreeView.SelectionMode.ContiguousSelection) self.setColumnWidth(3, 200) self.setHeaderLabels( ["File name", "Size", "Status", "File location", "Relative path"]) self.setDropIndicatorShown(True) self.setAcceptDrops(True) self.setSupportedDropActions = QtCore.Qt.CopyAction | QtCore.Qt.MoveAction
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 __init__(self, s: str, additional_style=""): super().__init__(s) self.opacityEffect = QtWidgets.QGraphicsOpacityEffect(self) self.setMaximumHeight(15) self.opacityEffect.setProperty("opacity", 0) self.setStyleSheet("background-color: transparent;" + additional_style) self.setGraphicsEffect(self.opacityEffect)
def _animate(self, current, duration, start, end, callback): if end == 1: self.win.scroll_up() self.eff = qtw.QGraphicsOpacityEffect() current.setGraphicsEffect(self.eff) a = QPropertyAnimation(self.eff, b'opacity') a.setDuration(duration) a.setStartValue(start) a.setEndValue(end) a.setEasingCurve(QEasingCurve.Linear) a.finished.connect(callback) a.start(QPropertyAnimation.DeleteWhenStopped) self.a = a
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_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): """ 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 __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()
def __init__(self, parent): super().__init__(parent) self.setTextVisible(False) self.setRange(0, 100) # install an event filter on the parent so we # can resize when the parent is resized self.parent().installEventFilter(self) # create opacity effect self.opacityEffect = QtWidgets.QGraphicsOpacityEffect(opacity=0) 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(2000) self.opacityAni.finished.connect(self._checkHidden) self.h = 10 # style self.setStyleSheet(""" QProgressBar { border: 0px solid grey; border-radius: 5px; background-color: transparent; } QProgressBar::chunk { background-color: #007bff; /* light blue */ width: 20px; } """) self.hide()
def __init__(self, *args, **kwargs): try: common.message_widget.close() common.message_widget.deleteLater() except: pass finally: common.message_widget = None common.message_widget = self if 'parent' in kwargs: parent = kwargs['parent'] else: parent = None super().__init__(parent=parent) if parent is None: common.set_stylesheet(self) # labels self.no_buttons = False self.buttons = [] self.primary_label = None self.secondary_label = None self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setAttribute(QtCore.Qt.WA_NoSystemBackground) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint | QtCore.Qt.WindowStaysOnTopHint) self.installEventFilter(self) self.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) effect = QtWidgets.QGraphicsOpacityEffect(self) self.setGraphicsEffect(effect) self._opacity = 1.0 self.fade_in = QtCore.QPropertyAnimation( effect, QtCore.QByteArray('opacity'.encode('utf-8'))) self.fade_in.setStartValue(0.0) self.fade_in.setEndValue(1.0) self.fade_in.setDuration(200) self.fade_in.setEasingCurve(QtCore.QEasingCurve.InOutQuad) self.fade_out = QtCore.QPropertyAnimation( effect, QtCore.QByteArray('opacity'.encode('utf-8'))) self.fade_out.setStartValue(1.0) self.fade_out.setEndValue(0.0) self.fade_out.setDuration(200) self.fade_out.setEasingCurve(QtCore.QEasingCurve.InOutQuad) self._clicked_button = None self.set_labels(args) self.set_buttons(kwargs) self._create_ui() self._connect_signals()