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

Hotkey config #1571

Merged
merged 25 commits into from
Jul 7, 2020
Merged

Hotkey config #1571

merged 25 commits into from
Jul 7, 2020

Conversation

ricab
Copy link
Collaborator

@ricab ricab commented Jun 3, 2020

Fixes #1311. Also introduces get --raw.

@ricab
Copy link
Collaborator Author

ricab commented Jun 3, 2020

@Saviq what do you think about this? I am going a bit further than we discussed by tentatively placing things at the platform level, so that we can handle the mac case properly, rather than tell users they need to use ctrl for cmd and meta for ctrl.

Refactoring needed to use current linux approach on win.

@multipass-ci-bot

This comment has been minimized.

@Saviq
Copy link
Collaborator

Saviq commented Jun 3, 2020

How do you think they'll be inputting Command and Option? Cmd and Opt?

@ricab
Copy link
Collaborator Author

ricab commented Jun 4, 2020

I was thinking something like that. Not sure about Opt. Here's what they use: https://support.apple.com/en-us/HT201236

@ricab
Copy link
Collaborator Author

ricab commented Jun 4, 2020

But I suppose we can accept both opt and alt.

@ricab ricab force-pushed the hotkey-config branch 2 times, most recently from 651719d to a0cd5ff Compare June 18, 2020 17:07
@multipass-ci-bot

This comment has been minimized.

@ricab
Copy link
Collaborator Author

ricab commented Jun 18, 2020

Tentative updates to the documentation in https://discourse.ubuntu.com/t/multipass-get-command/13735 and https://discourse.ubuntu.com/t/multipass-set-command/13734. Let me know if I am missing some other place where the hotkey is mentioned.

@ricab
Copy link
Collaborator Author

ricab commented Jun 18, 2020

I have found that both QKeySequence and QHotKey have a few rough corners. The altgr and meta issues are particularly unfortunate, because they don't work but there is no error whatsoever. The numpad issue too.

The more I think about this, the more it feels like we should restrict the values to a subset that we know we can support well. Perhaps something like:

  • one of [F1-F12], or
  • one or more of [ctrl, alt, shift, meta], but not meta alone, plus any non-modifier key, excluding numpad, media keys, Fn, altgr, backspace, enter, caps lock, ... oh dear, how do we even document? We can't say [a-z0-9F1-F12] because that still excludes a bunch of symbols that work well but depend on keyboard layout (e.g. '[' has it's own key in my keyboard, but that's not always the case). Maybe we should really say "any non-modifier key except" and update the list as we find keys that don't work.

@multipass-ci-bot

This comment has been minimized.

@codecov
Copy link

codecov bot commented Jun 22, 2020

Codecov Report

Merging #1571 into master will increase coverage by 0.02%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1571      +/-   ##
==========================================
+ Coverage   75.23%   75.25%   +0.02%     
==========================================
  Files         222      223       +1     
  Lines        8184     8204      +20     
==========================================
+ Hits         6157     6174      +17     
- Misses       2027     2030       +3     
Impacted Files Coverage Δ
src/client/cli/cmd/get.h 100.00% <ø> (ø)
src/utils/settings.cpp 21.17% <27.27%> (+1.42%) ⬆️
src/platform/platform_linux.cpp 69.09% <50.00%> (-0.73%) ⬇️
src/client/cli/cmd/get.cpp 90.62% <100.00%> (+2.16%) ⬆️
src/client/cli/cmd/set.cpp 94.54% <100.00%> (ø)
src/platform/platform_shared.cpp 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0757509...0b6b36a. Read the comment docs.

@multipass-ci-bot

This comment has been minimized.

@multipass-ci-bot

This comment has been minimized.

@multipass-ci-bot

This comment has been minimized.

@ricab
Copy link
Collaborator Author

ricab commented Jun 26, 2020

OK this should be about done now. Only need a final test on windows and probably some rebasing.

@multipass-ci-bot

This comment has been minimized.

@ricab ricab marked this pull request as ready for review June 29, 2020 17:57
Comment on lines +28 to +39
// A few notes on this:
// 1) Some shortcuts may feel counter-intuitive. For example in a keyboard where pressing "shift+-" produces an
// underscore, "_" is still interpreted the same as "-". IOW, "shift+-" == "shift+_" != "_" (just like "u" is the same
// as "U").
// 2) QHotKey fails to register some of the shortcuts we accept here (e.g. "Media Play").
// 3) QKeySequence seems to have problems with AtlGr. QKeySequence("AltGr").toString() prints rubbish (that it does not
// interpret back to mean the same thing). Unfortunately it is not enough to specify "ú" when that's what the layout
// produces for AltGr+U. The Sequence "ú" is accepted and QHotKey registers it, but is gets triggered on "U" and not
// "AltGr+U".
// 4) There does not seem to be a way to specify numpad keys in QKeySequence (with or without numlock).
// 5) meta only seems to work with other modifiers (e.g. ctrl+meta+x works, but meta+x doesn't even though it is
// accepted with no warning)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this apply to all platforms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure TBH, those were conclusions from testing on Linux. I got some of those same results on the others, but I did not check each one on every platform. The items referring to Meta and AltGr have doubtful applicability on macOS (at least with the default keyboard).

src/platform/platform_shared.cpp Show resolved Hide resolved
src/platform/platform_shared.h Outdated Show resolved Hide resolved
src/utils/settings.cpp Show resolved Hide resolved
@Saviq
Copy link
Collaborator

Saviq commented Jul 2, 2020

I wonder if we should display the hotkey in the GUI, then?

@ricab
Copy link
Collaborator Author

ricab commented Jul 3, 2020

I wonder if we should display the hotkey in the GUI, then?

Makes sense indeed.

ricab added 20 commits July 3, 2020 17:56
Creates a place for things that are used in more than one platform and
which should be kept at the platform level (for dependency or conceptual
reasons).
Use native representation of hotkeys for both presentation and
persistence. This impacts macOS. With this approach, we can rely on
Qt to 1) give us a correct (and pretty) representation to show the user;
and 2) interpret our saved string correctly. We thus avoid a bunch of
extra conversions like cmd <-> ctrl in macOS, keeping the general
code for saving and retrieving settings clean.
This makes the backend file human readable when there are "funny" chars,
but it does not affect logic, since the same format used is for reading
and writing. Furthermore, no transitioning is needed because no existing
settings accepted anything beyond ASCII, so they will be interpreted the
same way in UTF-8.
The outcome is still platform dependent, but that's on Qt only.
@multipass-ci-bot
Copy link
Collaborator

multipass-ci-bot commented Jul 3, 2020

macOS build available: multipass-1.4.0-dev.219.pr1571+gba14823e.mac-Darwin.pkg
Snap build available: snap refresh multipass --channel edge/pr1571

@Saviq
Copy link
Collaborator

Saviq commented Jul 6, 2020

Alright, nice!

bors merge

@bors
Copy link
Contributor

bors bot commented Jul 6, 2020

Build failed:

@Saviq
Copy link
Collaborator

Saviq commented Jul 7, 2020

Conflict on macOS:

CONFLICT (content): Merge conflict in src/platform/CMakeLists.txt

@ricab
Copy link
Collaborator Author

ricab commented Jul 7, 2020

Conflict on macOS:

CONFLICT (content): Merge conflict in src/platform/CMakeLists.txt

Hi, that's because bors does not grab the matching branch when staging, right?

@Saviq Saviq merged commit badfd4a into master Jul 7, 2020
@bors bors bot deleted the hotkey-config branch July 7, 2020 11:25
@ricab ricab added this to the v1.4.0 milestone Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcut conflicting with Chrome "View Source" under macOS
3 participants