mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-20 21:43:22 -07:00
code release
This commit is contained in:
parent
b941ba41a3
commit
a902f11f74
354 changed files with 826570 additions and 1 deletions
43
xlib/qt/core/QXTimeLine.py
Normal file
43
xlib/qt/core/QXTimeLine.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from typing import Tuple
|
||||
|
||||
from PyQt6.QtCore import *
|
||||
|
||||
_linear_easing_curve = QEasingCurve(QEasingCurve.Type.Linear)
|
||||
class QXTimeLine(QTimeLine):
|
||||
"""
|
||||
QXTimeLine with default linear curve
|
||||
|
||||
|
||||
frame_range(None) (int,int) start,end
|
||||
"""
|
||||
def __init__(self, duration,
|
||||
frame_range : Tuple[int,int] = None,
|
||||
loop_count=1,
|
||||
update_interval : int = None,
|
||||
easing_curve=None,
|
||||
frameChanged=None,
|
||||
stateChanged=None,
|
||||
start=False):
|
||||
|
||||
super().__init__(duration)
|
||||
|
||||
if frame_range is not None:
|
||||
self.setFrameRange(*frame_range)
|
||||
|
||||
self.setLoopCount(loop_count)
|
||||
|
||||
if update_interval is not None:
|
||||
self.setUpdateInterval(update_interval)
|
||||
|
||||
if easing_curve is None:
|
||||
easing_curve = _linear_easing_curve
|
||||
self.setEasingCurve(easing_curve)
|
||||
|
||||
if frameChanged is not None:
|
||||
self.frameChanged.connect(frameChanged)
|
||||
|
||||
if stateChanged is not None:
|
||||
self.stateChanged.connect(stateChanged)
|
||||
|
||||
if start:
|
||||
self.start()
|
19
xlib/qt/core/QXTimer.py
Normal file
19
xlib/qt/core/QXTimer.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from PyQt6.QtCore import *
|
||||
|
||||
|
||||
class QXTimer(QTimer):
|
||||
|
||||
def __init__(self, interval=None, timeout=None, single_shot=False, start=False):
|
||||
super().__init__()
|
||||
|
||||
if interval is not None:
|
||||
self.setInterval(interval)
|
||||
|
||||
if timeout is not None:
|
||||
self.timeout.connect(timeout)
|
||||
|
||||
if single_shot:
|
||||
self.setSingleShot(True)
|
||||
|
||||
if start:
|
||||
self.start()
|
88
xlib/qt/core/widget.py
Normal file
88
xlib/qt/core/widget.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
from collections import Iterable
|
||||
|
||||
from PyQt6.QtCore import *
|
||||
|
||||
|
||||
class BlockSignals:
|
||||
def __init__(self, qt_widget_or_list, block_signals=True):
|
||||
if not isinstance(qt_widget_or_list, (tuple,list)):
|
||||
qt_widget_or_list = [qt_widget_or_list]
|
||||
self.qt_widget_or_list = qt_widget_or_list
|
||||
self.block_signals = block_signals
|
||||
|
||||
def __enter__(self):
|
||||
if self.block_signals:
|
||||
for qt_widget in self.qt_widget_or_list:
|
||||
qt_widget.blockSignals(True)
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(self, *_):
|
||||
if self.block_signals:
|
||||
for qt_widget in self.qt_widget_or_list:
|
||||
qt_widget.blockSignals(False)
|
||||
|
||||
def enable(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
enable(widget)
|
||||
else:
|
||||
widget.setEnabled(True)
|
||||
|
||||
def disable(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
disable(widget)
|
||||
else:
|
||||
widget.setEnabled(False)
|
||||
|
||||
def hide(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
hide(widget)
|
||||
else:
|
||||
widget.hide()
|
||||
|
||||
def show(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
show(widget)
|
||||
else:
|
||||
widget.show()
|
||||
|
||||
def show_and_enable(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
show_and_enable(widget)
|
||||
else:
|
||||
widget.show()
|
||||
widget.setEnabled(True)
|
||||
|
||||
def hide_and_disable(widget_or_list):
|
||||
if not isinstance(widget_or_list, (tuple,list)):
|
||||
widget_or_list = [widget_or_list]
|
||||
for widget in widget_or_list:
|
||||
if isinstance(widget, (tuple,list)):
|
||||
hide_and_disable(widget)
|
||||
else:
|
||||
widget.hide()
|
||||
widget.setEnabled(False)
|
||||
|
||||
def set_contents_margins(obj, contents_margins):
|
||||
|
||||
if contents_margins is not None:
|
||||
if isinstance(contents_margins, int):
|
||||
contents_margins = (contents_margins,)*4
|
||||
|
||||
if isinstance(contents_margins, Iterable):
|
||||
obj.setContentsMargins(*contents_margins)
|
Loading…
Add table
Add a link
Reference in a new issue