Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse Show/Hide feature #56

Merged
merged 7 commits into from
Oct 21, 2022
Merged

Mouse Show/Hide feature #56

merged 7 commits into from
Oct 21, 2022

Conversation

MikeGillotti
Copy link
Contributor

Closes #51

@jeertmans jeertmans added the enhancement New feature or request label Oct 21, 2022
Copy link
Owner

@jeertmans jeertmans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MikeGillotti, many thanks for your PR!

I just left some comments and, if you apply requested changes, I will accept your PR ;-)

@@ -562,7 +562,15 @@ def __init__(
self.thread.start()

def keyPressEvent(self, event):
self.config = Config()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.config = Config()

Here, you define a default config for every key press. That is quite inefficient and does not use the config that was passed to self.thread. See above

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: can you modify Display.__init__ to take config: Config = Config() instead of just config? Then, also add config: Config = Config() to App.__init__ arguments, and modify the line self.thread = Display(*args, **kwargs) to be self.thread = Display(*args, config=config, **kwargs).

Comment on lines 568 to 576
if self.hide_mouse == False and self.config.HIDE_MOUSE.match(key):
self.setCursor(Qt.BlankCursor)
self.hide_mouse = True
elif self.hide_mouse == True and self.config.HIDE_MOUSE.match(key):
self.setCursor(Qt.ArrowCursor)
self.hide_mouse = False
# We send key to be handled by video display
self.send_key_signal.emit(key)
event.accept()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.hide_mouse == False and self.config.HIDE_MOUSE.match(key):
self.setCursor(Qt.BlankCursor)
self.hide_mouse = True
elif self.hide_mouse == True and self.config.HIDE_MOUSE.match(key):
self.setCursor(Qt.ArrowCursor)
self.hide_mouse = False
# We send key to be handled by video display
self.send_key_signal.emit(key)
event.accept()
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
else:
# We send key to be handled by video display
self.send_key_signal.emit(key)
event.accept()

There is no need to send the key to the thread if we already handled it ;-)

@MikeGillotti
Copy link
Contributor Author

Thank you for your feedback. I applied the requested changes.

@jeertmans
Copy link
Owner

Look perfect to me, thank you @MikeGillotti! Merging this now

@jeertmans jeertmans merged commit 1632604 into jeertmans:main Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants