diff --git a/build/jam/images/definitions/regular b/build/jam/images/definitions/regular index 7bca89a614..5e06f76512 100644 --- a/build/jam/images/definitions/regular +++ b/build/jam/images/definitions/regular @@ -289,3 +289,8 @@ AddDirectoryToHaikuImage home config settings printers "Save as PDF" # padblocker AddDirectoryToHaikuImage home config settings touchpad ; + +# shortcuts defaults +local shortcutsSettingsFile = shortcuts_settings ; +SEARCH on $(shortcutsSettingsFile) = [ FDirName $(HAIKU_TOP) data settings ] ; +AddFilesToHaikuImage home config settings : $(shortcutsSettingsFile) ; diff --git a/data/settings/shortcuts_settings b/data/settings/shortcuts_settings new file mode 100644 index 0000000000..e0ee2199c6 Binary files /dev/null and b/data/settings/shortcuts_settings differ diff --git a/src/preferences/shortcuts/ShortcutsWindow.cpp b/src/preferences/shortcuts/ShortcutsWindow.cpp index d41db869b4..6f67b24081 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.cpp +++ b/src/preferences/shortcuts/ShortcutsWindow.cpp @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include "EditWindow.h" #include "KeyInfos.h" @@ -215,6 +217,12 @@ ShortcutsWindow::ShortcutsWindow() message.AddString("startupRef", "please"); PostMessage(&message); // tell ourselves to load this file if it exists + } else { + _AddNewSpec("/bin/setvolume -m", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_MUTE); + _AddNewSpec("/bin/setvolume -i", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_VOLUME_INCREMENT); + _AddNewSpec("/bin/setvolume -d", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_VOLUME_DECREMENT); + fLastSaved = BEntry(&keySetRef); + PostMessage(SAVE_KEYSET); } BLayoutBuilder::Group<>(this, B_VERTICAL, 0) @@ -315,11 +323,9 @@ ShortcutsWindow::_GetSettingsFile(entry_ref* eref) return false; else path.Append(SHORTCUTS_SETTING_FILE_NAME); - - if (BEntry(path.Path(), true).GetRef(eref) == B_OK) - return true; - else - return false; + BEntry entry(path.Path(), true); + entry.GetRef(eref); + return entry.Exists(); } @@ -435,7 +441,7 @@ ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMessage) // Creates a new entry and adds it to the GUI. (defaultCommand) will be the // text in the entry, or NULL if no text is desired. void -ShortcutsWindow::_AddNewSpec(const char* defaultCommand) +ShortcutsWindow::_AddNewSpec(const char* defaultCommand, uint32 keyCode) { _MarkKeySetModified(); @@ -454,6 +460,10 @@ ShortcutsWindow::_AddNewSpec(const char* defaultCommand) fColumnListView->ScrollTo(spec); if (defaultCommand) spec->SetCommand(defaultCommand); + if (keyCode != 0) { + spec->ProcessColumnTextString(ShortcutsSpec::KEY_COLUMN_INDEX, + GetFallbackKeyName(keyCode).String()); + } } diff --git a/src/preferences/shortcuts/ShortcutsWindow.h b/src/preferences/shortcuts/ShortcutsWindow.h index 00d1001959..f7f6d895a5 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.h +++ b/src/preferences/shortcuts/ShortcutsWindow.h @@ -57,7 +57,7 @@ public: private: BMenuItem* _CreateActuatorPresetMenuItem(const char* label) const; - void _AddNewSpec(const char* defaultCommand); + void _AddNewSpec(const char* defaultCommand, uint32 keyCode = 0); void _MarkKeySetModified(); bool _LoadKeySet(const BMessage& loadMessage); bool _SaveKeySet(BEntry& saveEntry);