mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-22 13:06:45 +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")
|
REVERSE: Key = Key(ids=[Qt.Key_V], name="REVERSE")
|
||||||
REWIND: Key = Key(ids=[Qt.Key_R], name="REWIND")
|
REWIND: Key = Key(ids=[Qt.Key_R], name="REWIND")
|
||||||
PLAY_PAUSE: Key = Key(ids=[Qt.Key_Space], name="PLAY / PAUSE")
|
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
|
@root_validator
|
||||||
def ids_are_unique_across_keys(cls, values):
|
def ids_are_unique_across_keys(cls, values):
|
||||||
|
@ -284,7 +284,7 @@ class Display(QThread):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
presentations,
|
presentations,
|
||||||
config,
|
config: Config = Config(),
|
||||||
start_paused=False,
|
start_paused=False,
|
||||||
skip_all=False,
|
skip_all=False,
|
||||||
record_to=None,
|
record_to=None,
|
||||||
@ -517,6 +517,7 @@ class App(QWidget):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*args,
|
*args,
|
||||||
|
config: Config = Config(),
|
||||||
fullscreen: bool = False,
|
fullscreen: bool = False,
|
||||||
resolution: Tuple[int, int] = (1980, 1080),
|
resolution: Tuple[int, int] = (1980, 1080),
|
||||||
hide_mouse: bool = False,
|
hide_mouse: bool = False,
|
||||||
@ -528,8 +529,9 @@ class App(QWidget):
|
|||||||
self.setWindowTitle(WINDOW_NAME)
|
self.setWindowTitle(WINDOW_NAME)
|
||||||
self.display_width, self.display_height = resolution
|
self.display_width, self.display_height = resolution
|
||||||
self.aspect_ratio = aspect_ratio
|
self.aspect_ratio = aspect_ratio
|
||||||
|
self.hide_mouse = hide_mouse
|
||||||
if hide_mouse:
|
self.config = config
|
||||||
|
if self.hide_mouse:
|
||||||
self.setCursor(Qt.BlankCursor)
|
self.setCursor(Qt.BlankCursor)
|
||||||
|
|
||||||
self.label = QLabel(self)
|
self.label = QLabel(self)
|
||||||
@ -541,7 +543,7 @@ class App(QWidget):
|
|||||||
self.label.setMinimumSize(1, 1)
|
self.label.setMinimumSize(1, 1)
|
||||||
|
|
||||||
# create the video capture thread
|
# create the video capture thread
|
||||||
self.thread = Display(*args, **kwargs)
|
self.thread = Display(*args, config=config, **kwargs)
|
||||||
# create the info dialog
|
# create the info dialog
|
||||||
self.info = Info()
|
self.info = Info()
|
||||||
self.info.show()
|
self.info.show()
|
||||||
@ -562,7 +564,15 @@ class App(QWidget):
|
|||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
|
|
||||||
key = event.key()
|
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
|
# We send key to be handled by video display
|
||||||
self.send_key_signal.emit(key)
|
self.send_key_signal.emit(key)
|
||||||
event.accept()
|
event.accept()
|
||||||
|
Reference in New Issue
Block a user