mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-20 12:05:56 +08:00
Mouse Show/Hide feature (#56)
* Mouse Show/Hide feature * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Mouse Hide/Show Fix Applied requested changes for PR * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
This commit is contained in:
@ -41,6 +41,7 @@ class Config(BaseModel):
|
||||
REVERSE: Key = Key(ids=[Qt.Key_V], name="REVERSE")
|
||||
REWIND: Key = Key(ids=[Qt.Key_R], name="REWIND")
|
||||
PLAY_PAUSE: Key = Key(ids=[Qt.Key_Space], name="PLAY / PAUSE")
|
||||
HIDE_MOUSE: Key = Key(ids=[Qt.Key_H], name="HIDE / SHOW MOUSE")
|
||||
|
||||
@root_validator
|
||||
def ids_are_unique_across_keys(cls, values):
|
||||
|
@ -284,7 +284,7 @@ class Display(QThread):
|
||||
def __init__(
|
||||
self,
|
||||
presentations,
|
||||
config,
|
||||
config: Config = Config(),
|
||||
start_paused=False,
|
||||
skip_all=False,
|
||||
record_to=None,
|
||||
@ -517,6 +517,7 @@ class App(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
*args,
|
||||
config: Config = Config(),
|
||||
fullscreen: bool = False,
|
||||
resolution: Tuple[int, int] = (1980, 1080),
|
||||
hide_mouse: bool = False,
|
||||
@ -528,8 +529,9 @@ class App(QWidget):
|
||||
self.setWindowTitle(WINDOW_NAME)
|
||||
self.display_width, self.display_height = resolution
|
||||
self.aspect_ratio = aspect_ratio
|
||||
|
||||
if hide_mouse:
|
||||
self.hide_mouse = hide_mouse
|
||||
self.config = config
|
||||
if self.hide_mouse:
|
||||
self.setCursor(Qt.BlankCursor)
|
||||
|
||||
self.label = QLabel(self)
|
||||
@ -541,7 +543,7 @@ class App(QWidget):
|
||||
self.label.setMinimumSize(1, 1)
|
||||
|
||||
# create the video capture thread
|
||||
self.thread = Display(*args, **kwargs)
|
||||
self.thread = Display(*args, config=config, **kwargs)
|
||||
# create the info dialog
|
||||
self.info = Info()
|
||||
self.info.show()
|
||||
@ -562,7 +564,15 @@ class App(QWidget):
|
||||
self.thread.start()
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
|
||||
key = event.key()
|
||||
if self.config.HIDE_MOUSE.match(key):
|
||||
if self.hide_mouse:
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.hide_mouse = False
|
||||
else:
|
||||
self.setCursor(Qt.BlankCursor)
|
||||
self.hide_mouse = True
|
||||
# We send key to be handled by video display
|
||||
self.send_key_signal.emit(key)
|
||||
event.accept()
|
||||
|
Reference in New Issue
Block a user