History log of /haiku/src/preferences/keymap/ModifierKeysWindow.cpp
Revision Date Author Comments
# 4fc18643 04-Dec-2023 John Scipione <jscipione@gmail.com>

Keymap: Put status icons inside menu fields

Draw warning and stop icons on top of the menu fields instead.
Remove conflict views, create a new file to hold StatusMenuField
and StatusMenuItem. Set the icon with them instead.

Change-Id: If6c00199f24ac4f4fc789f12cc6cdcd7a912418f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7209
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 0b3890fe 04-Dec-2023 John Scipione <jscipione@gmail.com>

Keymap: Fix Modifier Keys window regressions from hrev57267

Fix _DuplicateKeys() conflict check for Caps Lock to ignore right side.
- Create kUnset constant set to 0 so it's clear what's going on.
- Create kDisabled constant set to -1 for that case.
- Declare loop variables one time out of loop scope, uint => int for -1.

Fix _MarkMenuItem() warnings icon check. We should get a yellow warning
icon if your left and right modifiers don't match (except on Caps Lock).

Create an _UpdateStatus() method that calls the other methods we need.

Reverse the placement of the Revert and Cancel buttons. Cancel goes just
to the left of the OK button and Revert goes all the way left.

Restore _HideShowStatusIcons(), this is used to push the menu fields
over when there is no conflict. _ToggleStatusIcon() convenience method.

The key role is called "Caps Lock" not just Caps. Method and variable
names are fine, but the " Lock" part is important in the label. Also use
"Caps Lock key" instead of just "Caps Lock" for the menu field value.
We use " key" at the end for the other cases to differentiate them from
the role label.

Minor nitpicks:
- Change comment variable name to label. I understand that it says
B_TRANSLATE_COMMENT, but it's a label, the comment is for i18n.
- Fix same method declaration style, and in header.
- Add 2 new lines after pragma instead of 1

Change-Id: I194e69486310a249d0ef2d5d5977ae69954e9a27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7179
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# d51ee1e8 16-Aug-2023 Jorge Acereda <jacereda@gmail.com>

Keymap: Add caps modifiers remapping

Refactored some functions.

Change-Id: Idb16b1298fcd8f2fbca256275d16fbc3584bdb55
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6842
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 4dbd4747 20-May-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

Add BIconUtils::GetSystemIcon

Allow to easily access the alert icons and anything that's added to app_server
resources.

Fixes #10887.

Convert BAlert, Debugger AlertWithCheckbox and Keymap ModifierKeysWindow
to make use of it, removing the duplicate code to locate app_server
resources.

The resources are initialized only once (per application), so there is no need
to reload them for every access to the icons.

In the ticket there is discussion about putting this in BControlLook,
but I think this should in fact be moved fully into app_server with
special drawing commands for well-known icons. That would avoid loading
and rendering the icon on the application side to then send it to
app_server (especially in remote_app_server case)?

In any case, this simple API can serve as a base for applications to
use, and we can change how it is implemented later on.

Change-Id: Id370526ae5cf165cfb8bc277bc8a7f46c26f542d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6463
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 6a287ced 27-Sep-2022 Augustin Cavalier <waddlesplash@gmail.com>

Keymap: Use BControlLook::ComposeIconSize for the conflict view.

Fixes #17911.


# 3c5208e4 07-Nov-2015 Humdinger <humdingerb@gmail.com>

Improve/fix layout

Some tweaks to the layout of apps/prefs in the course of using
B_USE_WINDOW_SPACING.


# d0ac6099 07-Nov-2015 Humdinger <humdingerb@gmail.com>

Use B_USE_WINDOW_SPACING

Use B_USE_WINDOW_SPACING as inset from contents to window border.
Some whitespace cleanup.


# fd3fa917 21-Mar-2014 John Scipione <jscipione@gmail.com>

KeyMap: Redo modifier keys layout

... by using a group layout inside of a grid layout we can get this
to layout how we want it without having to calculate the label
widths manually.


# 449d6828 19-Mar-2014 John Scipione <jscipione@gmail.com>

KeyMap: Fix alignment of role labels

... by setting all labels to take up the width of the longest label.

Fixes #10693


# 4e152efc 21-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap modifiers: make it a floating window


# 73ee1578 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Hide/show warning/stop icon views


# a7b27d49 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: 80 char limit style fix


# 528688c0 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Sentence case these pragmas


# 313b1c62 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Center Modifier Keys window in main window


# 2943ba13 21-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Add warning icon.

That shows when the left and right side key roles don't match.
e.g. The left control key has a different key role than the right
control key.

The warning doesn't actually stop you from setting the modifier
keys though.

Add tooltips on the warning and stop icons explaining the
problem.

Also a couple minor style fixes.


# f6c5dbf8 03-Jan-2014 Humdinger <humdingerb@gmail.com>

Some more code style corrections of Keymap.


# b87ee2bf 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Conflict if either left or right

... key doesn't match rather than requiring both left and right keys
to not match for a conflict.

Also update copyright year


# 460168d5 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Use menu field label and refactor

Use CreateLabelLayoutItem() instead of faking the label with a BStringView.
This is important because it means the label is part of the menu field control
rather than being it's own separate view.

Also convert from using deprecated BGroupLayoutBuilder and
BGridLayoutBuilder classes and use the BLayoutBuilder template instead.

Use font-relative spacing values instead of constants.

Make key label take up 2 columns

Make protected methods private, don't want to subclass
ModifierKeysWindow


# c1971982 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: style fixes


# 2388b04a 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Move ConflictView to top.

Also, move includes from .h to .cpp file.

Make _FillSavedIcon() private, make Draw() public.


# 546208a5 16-Apr-2012 Oliver Tappe <zooey@hirschkaefer.de>

More catalog-related cleanup.

* rename B_TRANSLATE_CONTEXT to B_TRANSLATION_CONTEXT and
B_TRANSLATE_WITH_CONTEXT to B_TRANSLATE_CONTEXT, squashing a TODO
* adjust all uses of both macros in Haiku's source tree
* use correct header guard for collecting/Catalog.h

The renamed macros require adjustments to all external applications
using catalogs.


# 1cd97d5e 15-Apr-2012 John Scipione <jscipione@gmail.com>

Update modifier keys window to take out cruft.

I don't need to set the ExplicitMaxSize of the StringView's in
Modifier Keys anymore or calculate the widest label now that the
StringView's have an explicit alignment set. I used the old method
of SetAlignment(B_ALIGN_RIGHT) just because I can,
SetExplicitAlignment() should work too.


# 3cee15aa 28-Mar-2012 John Scipione <jscipione@gmail.com>

Keymap changes from recent activity. No AltGr yet.

Below is a mostly complete summary of the changes in this commit.

* Set the DeadKeys for the US-International Keymap to use the Option map.
* Rename American keymap to US
* Update the US, US-International, and United-Kingdom keymaps to take
out unneeded spaces in the option layer. Also updated the dead keys
and some other keys on the US-International keyboard to use UTF-8
characters rather than there ASCII equivalents when different.
* Make the Option key fall-through when there is no mapping in the Option
table. Option is for special characters, if none, print the regular one.
This is mostly meant for the US keymap which has an empty option map. But
also so that you don't have to repeat the normal, shift, and caps maps in
the option map needlessly. Although the keymaps are still not empty in
some cases that it could be like numpad keys and space.
* Update the /bin/keymap app to use fputs() instead of printf() when there
is no actual formatting taking place. I've gotten into trouble for doing
this before and it is faster to not process the string unnecessarily.
* Also several 80-char limit style fixes and updated comments.
* In Keymap class Reorder the modifier keys to match the keymap files.
Put B_CONTROL_KEY check above B_OPTION_KEY. Neither change has any effect,
they are purely aesthetic.
* Update DumpKeymap() method to use the abbreviated modifier letters so it
will fit in your 80-char wide terminal.
* Tiny style fix in InputServer
* 80-char limit style fix in BWindow and add a comment that the shortcut
gets eaten in the case of Cmd+Q
* Implement IndexForModifier() in KeyboardLayout, although I am not using it.
* Take Caps Lock out of the Modifier keys window because I couldn't get
it to work the way I wanted it to.
* Move key roles to the left column, and the key label on the left. Add column
header labels. Thanks Rimas!
* Add validation and improve marking menu options. Add a 'Disabled' option
to control, option, and command menus to disable the key. Make the key
role text grey if the key roles is disabled. Validation ensures that you
cannot repeat the same key twice in the Modifier keys window since that
won't work. You can't define 2 sets of option keys even if you really want
to. You can disable your control, option, and command keys if you
want, but that is not recommended.
* Rename kUpdateModifiers to kUpdateModifierKeys message to differetiate
it from kUpdateModifier.
* Add shift key to Modifier keys window, use the stop icon instead of the
warning icon to indicate conflicts.
* Allow the Layout system to control the size of the Modifier keys window
again, set the width's of the key role lables to the widest, set the width
of the menu fields to take up the rest of the space minus room for the
conflict views. I didn't like it that the Modifier keys window would change
size based on what options you had selected in the menu fields. Now it
doesn't, but, the layout system still makes it all fit.


# 1a6b60e6 25-Mar-2012 John Scipione <jscipione@gmail.com>

Addresses some of the issues brought up in ticket #8148

The key labels have been changed to Win/Option and Alt/Command
to better associate them with the key names on a PC keyboard. This is
not perfect, but, better.

Added a checkbox entitled "Switch right Alt/Command and Win/Option keys"
This checkbox does what it says, switches the keys on the right side
of your keyboard leaving the left side according to how you set them.
This is needed for some international keymaps.

Whether or not you have switched already is not remembered, you have to
check the box each time you open the dialog. I don't know how to figure
out whether or not the keys have been switched already reliably. Hopefully
this isn't a big deal.

Set the menu option and window title to sentence case, thanks Humdinger.


# 4d3d4878 14-Nov-2011 John Scipione <jscipione@gmail.com>

Patch by taos to add localized catalog for the Keymaps Modifier keys window.

Due to a missing entry in Keymap's Jamfile, the localized strings of
ModifierKeysWindow.cpp are not yet included in the corresponding catalog
on HTA.

The attached patch adds ModifierKeysWindow.cpp to DoCatalogs and changes 'Ok' to 'OK'.

Fixes #8127


# 6a99b224 08-Nov-2011 Siarzhuk Zharski <zharik@gmx.li>

- fix GCC4 build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed1b7b12 08-Nov-2011 John Scipione <jscipione@gmail.com>

Another small change to the Keymap Modifier Keys window. Only mark the control, option, and command menu items if both the left and right keys are set.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43222 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bce949f5 07-Nov-2011 John Scipione <jscipione@gmail.com>

Implemented the style changes and other improvements suggested by Axel to the Keymap preference app Modifier Keys window. The number of lines of code in the class was significantly reduced by these changes. I also made one small change to change the window title from 'Modifers Keys' to 'Modifier Keys'.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f5ac2da0 07-Nov-2011 John Scipione <jscipione@gmail.com>

Adds a dialog to the Keymap preference app to more easily and
reliably change your modifier keys.

The dialog box is shown by selecting the new 'Set Modifier Keys...'
option under the File menu. This brings up a window which contains 4
dialog boxes labeled: Caps Lock, Control, Option, and Command.

Each of the labels in followed by a drop down box which allows you to select
from one of the other keys listed. So for instance you could switch the Caps
Lock and Control keys but selecting the 'Control' option next to Caps Lock and
the 'Caps Lock' option next to Control.

The Caps Lock menu has an additional option which I find appealing...
'Disable' which, as it sounds, disables your Caps Lock key.

At the bottom of the dialog there are 3 buttons, 'Cancel', 'Revert', and 'Ok'.
'Cancel' and 'Ok' are self explanatory. The 'Revert' button, which is
initially disabled, puts you back into the state that you were when you first
opened the dialog.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43210 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd3fa9178b08d2232a62e8c4a1f59ad6dcdfee71 21-Mar-2014 John Scipione <jscipione@gmail.com>

KeyMap: Redo modifier keys layout

... by using a group layout inside of a grid layout we can get this
to layout how we want it without having to calculate the label
widths manually.


# 449d68282f23f348be5840a5210191871eee53a7 19-Mar-2014 John Scipione <jscipione@gmail.com>

KeyMap: Fix alignment of role labels

... by setting all labels to take up the width of the longest label.

Fixes #10693


# 4e152efced69329531ec708e0fda29394efdfa56 21-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap modifiers: make it a floating window


# 73ee1578a9600915e5d48a3bbff2cd6321421388 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Hide/show warning/stop icon views


# a7b27d4916ab28b5a19829f263ae4c8765019123 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: 80 char limit style fix


# 528688c0c863e63e0b9fcd204de36e48b333a3b9 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Sentence case these pragmas


# 313b1c624fa860fae78599d339a528561edd3b03 20-Feb-2014 John Scipione <jscipione@gmail.com>

Keymap: Center Modifier Keys window in main window


# 2943ba13544fea7521c02239c4fc4f30621e4077 21-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Add warning icon.

That shows when the left and right side key roles don't match.
e.g. The left control key has a different key role than the right
control key.

The warning doesn't actually stop you from setting the modifier
keys though.

Add tooltips on the warning and stop icons explaining the
problem.

Also a couple minor style fixes.


# f6c5dbf81cf723abdbdae12fc4ec81c780ed2190 03-Jan-2014 Humdinger <humdingerb@gmail.com>

Some more code style corrections of Keymap.


# b87ee2bfebe58eb6c6cddc5979a524b1511ed271 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Conflict if either left or right

... key doesn't match rather than requiring both left and right keys
to not match for a conflict.

Also update copyright year


# 460168d586c1aca66d13d79736370a649db7cd0e 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Use menu field label and refactor

Use CreateLabelLayoutItem() instead of faking the label with a BStringView.
This is important because it means the label is part of the menu field control
rather than being it's own separate view.

Also convert from using deprecated BGroupLayoutBuilder and
BGridLayoutBuilder classes and use the BLayoutBuilder template instead.

Use font-relative spacing values instead of constants.

Make key label take up 2 columns

Make protected methods private, don't want to subclass
ModifierKeysWindow


# c1971982382ad00038cd907f17053b56a873c17f 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: style fixes


# 2388b04ab89c5cb78f6038c235b9659b90149b04 19-Aug-2013 John Scipione <jscipione@gmail.com>

Keymap mod keys: Move ConflictView to top.

Also, move includes from .h to .cpp file.

Make _FillSavedIcon() private, make Draw() public.


# 546208a53940a26c6379c48a7854ade1a8250fc5 16-Apr-2012 Oliver Tappe <zooey@hirschkaefer.de>

More catalog-related cleanup.

* rename B_TRANSLATE_CONTEXT to B_TRANSLATION_CONTEXT and
B_TRANSLATE_WITH_CONTEXT to B_TRANSLATE_CONTEXT, squashing a TODO
* adjust all uses of both macros in Haiku's source tree
* use correct header guard for collecting/Catalog.h

The renamed macros require adjustments to all external applications
using catalogs.


# 1cd97d5e869c263a900f17a7cd314d1df9186a1c 15-Apr-2012 John Scipione <jscipione@gmail.com>

Update modifier keys window to take out cruft.

I don't need to set the ExplicitMaxSize of the StringView's in
Modifier Keys anymore or calculate the widest label now that the
StringView's have an explicit alignment set. I used the old method
of SetAlignment(B_ALIGN_RIGHT) just because I can,
SetExplicitAlignment() should work too.


# 3cee15aac2ef8c6ae8975d9add34c36aa4224c29 28-Mar-2012 John Scipione <jscipione@gmail.com>

Keymap changes from recent activity. No AltGr yet.

Below is a mostly complete summary of the changes in this commit.

* Set the DeadKeys for the US-International Keymap to use the Option map.
* Rename American keymap to US
* Update the US, US-International, and United-Kingdom keymaps to take
out unneeded spaces in the option layer. Also updated the dead keys
and some other keys on the US-International keyboard to use UTF-8
characters rather than there ASCII equivalents when different.
* Make the Option key fall-through when there is no mapping in the Option
table. Option is for special characters, if none, print the regular one.
This is mostly meant for the US keymap which has an empty option map. But
also so that you don't have to repeat the normal, shift, and caps maps in
the option map needlessly. Although the keymaps are still not empty in
some cases that it could be like numpad keys and space.
* Update the /bin/keymap app to use fputs() instead of printf() when there
is no actual formatting taking place. I've gotten into trouble for doing
this before and it is faster to not process the string unnecessarily.
* Also several 80-char limit style fixes and updated comments.
* In Keymap class Reorder the modifier keys to match the keymap files.
Put B_CONTROL_KEY check above B_OPTION_KEY. Neither change has any effect,
they are purely aesthetic.
* Update DumpKeymap() method to use the abbreviated modifier letters so it
will fit in your 80-char wide terminal.
* Tiny style fix in InputServer
* 80-char limit style fix in BWindow and add a comment that the shortcut
gets eaten in the case of Cmd+Q
* Implement IndexForModifier() in KeyboardLayout, although I am not using it.
* Take Caps Lock out of the Modifier keys window because I couldn't get
it to work the way I wanted it to.
* Move key roles to the left column, and the key label on the left. Add column
header labels. Thanks Rimas!
* Add validation and improve marking menu options. Add a 'Disabled' option
to control, option, and command menus to disable the key. Make the key
role text grey if the key roles is disabled. Validation ensures that you
cannot repeat the same key twice in the Modifier keys window since that
won't work. You can't define 2 sets of option keys even if you really want
to. You can disable your control, option, and command keys if you
want, but that is not recommended.
* Rename kUpdateModifiers to kUpdateModifierKeys message to differetiate
it from kUpdateModifier.
* Add shift key to Modifier keys window, use the stop icon instead of the
warning icon to indicate conflicts.
* Allow the Layout system to control the size of the Modifier keys window
again, set the width's of the key role lables to the widest, set the width
of the menu fields to take up the rest of the space minus room for the
conflict views. I didn't like it that the Modifier keys window would change
size based on what options you had selected in the menu fields. Now it
doesn't, but, the layout system still makes it all fit.


# 1a6b60e613fde4ec77dd3bb247987e3430703c6f 25-Mar-2012 John Scipione <jscipione@gmail.com>

Addresses some of the issues brought up in ticket #8148

The key labels have been changed to Win/Option and Alt/Command
to better associate them with the key names on a PC keyboard. This is
not perfect, but, better.

Added a checkbox entitled "Switch right Alt/Command and Win/Option keys"
This checkbox does what it says, switches the keys on the right side
of your keyboard leaving the left side according to how you set them.
This is needed for some international keymaps.

Whether or not you have switched already is not remembered, you have to
check the box each time you open the dialog. I don't know how to figure
out whether or not the keys have been switched already reliably. Hopefully
this isn't a big deal.

Set the menu option and window title to sentence case, thanks Humdinger.


# 4d3d4878a51d87b707d59df42793b6ef198af06a 14-Nov-2011 John Scipione <jscipione@gmail.com>

Patch by taos to add localized catalog for the Keymaps Modifier keys window.

Due to a missing entry in Keymap's Jamfile, the localized strings of
ModifierKeysWindow.cpp are not yet included in the corresponding catalog
on HTA.

The attached patch adds ModifierKeysWindow.cpp to DoCatalogs and changes 'Ok' to 'OK'.

Fixes #8127


# 6a99b22472f09f797e6b8f5ca07d12161fc6c3fa 08-Nov-2011 Siarzhuk Zharski <zharik@gmx.li>

- fix GCC4 build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed1b7b12d4c4e31df87c14926b6cb58f1e628632 08-Nov-2011 John Scipione <jscipione@gmail.com>

Another small change to the Keymap Modifier Keys window. Only mark the control, option, and command menu items if both the left and right keys are set.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43222 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bce949f5318afe7645b643274f9d48c5ed8fa1cc 07-Nov-2011 John Scipione <jscipione@gmail.com>

Implemented the style changes and other improvements suggested by Axel to the Keymap preference app Modifier Keys window. The number of lines of code in the class was significantly reduced by these changes. I also made one small change to change the window title from 'Modifers Keys' to 'Modifier Keys'.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f5ac2da0a80a5c1075cfb06747c58a5f95ea124a 07-Nov-2011 John Scipione <jscipione@gmail.com>

Adds a dialog to the Keymap preference app to more easily and
reliably change your modifier keys.

The dialog box is shown by selecting the new 'Set Modifier Keys...'
option under the File menu. This brings up a window which contains 4
dialog boxes labeled: Caps Lock, Control, Option, and Command.

Each of the labels in followed by a drop down box which allows you to select
from one of the other keys listed. So for instance you could switch the Caps
Lock and Control keys but selecting the 'Control' option next to Caps Lock and
the 'Caps Lock' option next to Control.

The Caps Lock menu has an additional option which I find appealing...
'Disable' which, as it sounds, disables your Caps Lock key.

At the bottom of the dialog there are 3 buttons, 'Cancel', 'Revert', and 'Ok'.
'Cancel' and 'Ok' are self explanatory. The 'Revert' button, which is
initially disabled, puts you back into the state that you were when you first
opened the dialog.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43210 a95241bf-73f2-0310-859d-f6bbb57e9c96