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

On macOS, register cmd+q on sclang interpreter main menu, solves #3824 #4533

Conversation

geoffroymontel
Copy link
Contributor

@geoffroymontel geoffroymontel commented Aug 11, 2019

Purpose and Motivation

Fixes #3824

Like in PR #4500 the fix consists in adding an Action with QAction::QuitRole so that this action registers cmd+q on macOS.
I disable this menu action so that Quit menu item is greyed out in the interpreter window.

MainMenu is not affected, it still works, I checked.

Types of changes

  • Bug fix

To-do list

  • Code is tested
  • All tests are passing
  • Updated documentation
  • This PR is ready for review

@geoffroymontel geoffroymontel added the comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" label Aug 11, 2019
@nhthn
Copy link
Contributor

nhthn commented Aug 11, 2019

thanks geoffroy! cc @redFrik

@dyfer
Copy link
Member

dyfer commented Aug 14, 2019

Thank you @geoffroymontel ! I won't be able to look at this for few days but I'd love to eventually - unless others get to it first :)

@nhthn nhthn added this to the 3.10.4 milestone Aug 30, 2019
@dyfer
Copy link
Member

dyfer commented Sep 10, 2019

I can confirm this prevents the crash when pressing cmd+q.

Not sure if it would be in the scope of this PR, but the SC GUI window still can't be closed with cmd+w (#4309). Would adding cmd+w to close the GUI window be a possible addition and in the scope of this PR?

QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
@dyfer
Copy link
Member

dyfer commented Sep 10, 2019

BTW should we write cmd+q or cmd-q, or all caps CMD+Q?

@geoffroymontel
Copy link
Contributor Author

Thanks for reviewing !!

I can confirm this prevents the crash when pressing cmd+q.
Cool !

Not sure if it would be in the scope of this PR, but the SC GUI window still can't be closed with cmd+w (#4309). Would adding cmd+w to close the GUI window be a possible addition and in the scope of this PR?

Mmm, it's quite different. Could you file a new issue with this feature request please ?

Best

@dyfer dyfer self-requested a review September 13, 2019 19:43
Copy link
Member

@dyfer dyfer left a comment

Choose a reason for hiding this comment

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

I'd like to get the ball rolling with this - I can confirm that this works as expected.

It would be great if someone else with c++ knowledge took a look at this before merging.

@dyfer
Copy link
Member

dyfer commented Sep 13, 2019

Mmm, it's quite different. Could you file a new issue with this feature request please ?

#4309 is already filed, is this what you had in mind?

@geoffroymontel
Copy link
Contributor Author

geoffroymontel commented Sep 14, 2019 via email

QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
QtCollider/QcApplication.cpp Outdated Show resolved Hide resolved
Copy link
Member

@joshpar joshpar left a comment

Choose a reason for hiding this comment

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

I think these look good now. Thanks! However, @brianlheim - I'm not sure, but looking at the travis output it looks like something is failing in the linting? Thoughts?

@mossheim
Copy link
Contributor

Yes, it is. @geoffroymontel can you please fix that? Check the build log for the details.

@geoffroymontel
Copy link
Contributor Author

@brianlheim sorry for that, it's fixed now !

Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

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

thanks! sorry for the delay, life was busy for the last month or so.

@nhthn
Copy link
Contributor

nhthn commented Nov 17, 2019

going through 3.10.4 changes for the changelog, i'm a bit confused by this one -- if cmd+q is supposed to quit the interpreter, why is it bad that the interpreter would quit with this shortcut? is this a regression from earlier behavior somehow?

@mossheim
Copy link
Contributor

see #3824 (comment)

i'm not sure whether in the past cmd-q was supposed to quit the interpreter on macos. i think it's mainly that this can be confusing for beginners and doesn't offer much benefit for experienced users. someone else can probably answer this more fully though, i'm now also a bit confused myself.

@nhthn
Copy link
Contributor

nhthn commented Nov 17, 2019

it also looks like the bug report in #3824 is a full-blown segmentation fault, not a graceful exit, but maybe someone could answer to what the behavior was before the crash (assuming that it was a regression).

@dyfer
Copy link
Member

dyfer commented Nov 17, 2019

It is (was?) a regression. And yes, the issue was that this was a segfault instead of a graceful exit.

In 3.8, when the interpreter got a separate icon, cmd-q was not triggering shutdown (no action) when interpreter was in focus. This seems to be the desired behavior. At some point this changed to segfault, which is definitely a regression. This PR restores the behavior from 3.8.

For reference, in the cocoa days, and before the interpreter had a separate icon, there was no concept of shutting it off by itself. With either the editor or a gui window cmd-q would quit everything - editor, interpreter (and by extension the server). In practice, if one was in the middle of working on code with unsaved changes, any accidental cmd-q would prompt "save changes?" dialog, preventing accidental shutdown.
In short, cmd-q should not shut down the interpreter by itself. It should either not do anything (behavior with this PR), or possibly attempt shutting down the IDE (which would be closer to the cocoa SC behavior). But I really believe with this PR we have the desired behavior.

@nhthn
Copy link
Contributor

nhthn commented Nov 17, 2019

thanks for the explanation.

there is a lot of "convention over configuration" keybindings happening in sclang gui, which i'm not a huge fan of. what if someone isn't using the IDE, and actually does want cmd+q to quit the interpreter?

@geoffroymontel
Copy link
Contributor Author

I think supporting cmd+q to quit the interpreter causes more harm than benefits ! I don't see a practical use case for it. Removing it at least solves a few annoying bugs (like pressing cmd+q on a user Window during a performance would kill the interpreter).

@dyfer
Copy link
Member

dyfer commented Nov 18, 2019

there is a lot of "convention over configuration" keybindings happening in sclang gui, which i'm not a huge fan of. what if someone isn't using the IDE, and actually does want cmd+q to quit the interpreter?

I just checked - cmd+q is propagated like any other key combination to the views in the QT GUI. So user still has the option to implement quit if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants