Commit Graph

5 Commits

Author SHA1 Message Date
Yu Leng
f0a828ee22 [KBM] Fix C4190 build error in template metadata helper
SetTemplateMetadata previously delegated to a std::wstring-returning
SerializeTemplateParameters defined inside the wrapper's extern "C"
block; a C-linkage function may not return a C++ type (warning C4190,
treated as error). Inline the JSON serialization so both helpers return
void. Verified: KeyboardManagerEditorLibraryWrapper.vcxproj builds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 13:05:13 +08:00
Yu Leng
b2bd24db0d [KBM] Fix review findings in CLI command template feature
Addresses correctness, robustness, and round-trip issues found while
reviewing the CLI-command-template work:

- Required-parameter validation: gate Save on IsAllValid and bubble
  parameter changes to the host (previously could save "--open-settings=").
- FFI read-back: carry templateId/templateParameters back to C# so a
  template mapping survives a rebuild from default.json (struct + both
  GetShortcutRemap[ByType] + KeyboardMappingService projection).
- Catalog load: wrap menu build in try/catch so a malformed catalog
  degrades gracefully instead of crashing the editor at startup.
- Install location: retarget the per-user PowerToys.exe path to a
  machine-wide install when the LOCALAPPDATA path is absent.
- Missing-template "Keep as plain command": preserve the resolved
  command instead of leaving an empty, unsavable OpenApp form.
- TemplateResolver: single-pass substitution + CommandLineToArgvW
  quoting (prevents substitution-injection and arg-splitting).
- C++ load: type-check templateParameters before reading so malformed
  optional metadata no longer drops the whole mapping; dedupe GetObjectW.
- schemaVersion: accept forward-compatible (>=1) catalogs; honor iconGlyph.
- Fix SelectionChanged/AppSpecificCheckBox handler re-subscription leak.
- Add KeyboardManagerEditorUI.UnitTests (resolver + catalog model);
  15 tests, wired into PowerToys.slnx.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 12:36:28 +08:00
Yu Leng
78c0e3e131 KBM: Full C++ wiring for template persistence in default.json
Adds templateId / templateParameters round-trip through the full stack:
Shortcut struct → MappingConfiguration (load+save) → EditorLibraryWrapper
(AddShortcutRemap) → C# P/Invoke → KeyboardMappingService. Non-template
mappings produce clean JSON (fields only emitted when non-empty). New
params default to nullptr so existing callers are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 22:00:33 +08:00
Zach Teutsch
f651d1a611 [Keyboard Manager] Updated WinUI3 KBM and toggles (#45649)
## Running the Project
**Option 1: Test via runner**
1. Check out branch `niels9001/kbm-ux-consolidation`
2. Build PowerToys project
3. Manually build `Modules/KeyboardManagerEditorUI` project separately
4. Run `runner` project
5. Ensure experimental features are enabled in general settings (should
be on by default)
6. Launch keyboard manager via settings app

**Option 2: Test via installer**
1. Install PowerToys via installer on azure pipeline
1. Launch keyboard manager

## Validation
For each page (Text, Remappings, Programs, URLs):
* Create shortcuts with variable options and ensure they run as expected
* Delete shortcuts and ensure they no longer execute
* Try to create invalid shortcuts to check for proper validation
* Ensure created shortcuts appear in Power Toys Settings Keyboard
manager page
* Try toggling shortcuts
* Try deleting shortcuts while toggled off

### UI
* Any feedback on UI design appreciated as well
<img width="1071" height="671" alt="image"
src="https://github.com/user-attachments/assets/d2e81de0-6d92-4189-9a33-32e94cce74f7"
/>
<img width="2142" height="1341" alt="image"
src="https://github.com/user-attachments/assets/0e4e5685-fdf1-4dfd-ba52-a2e5bc9a66db"
/>



Closes: #15870
Closes: #31902
Closes: #45302
Closes: #36227
Closes: #16093
Closes: #13409
Closes: #9919
Closes:  #9482
Closes: #8798
Closes:  #7054
Closes: #2733
Closes: #2027
Closes: #30167

---------

Co-authored-by: Hao Liu <liuhao3418@gmail.com>
Co-authored-by: chenmy77 <162882040+chenmy77@users.noreply.github.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Co-authored-by: Jaylyn Barbee <51131738+Jaylyn-Barbee@users.noreply.github.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
2026-03-04 15:46:42 -05:00
Hao Liu
68afc6623f [KeyboardManager WinUI3] Create WinUI3 project and wrapper for Keyboard Manager Editor (#37427)
* Set up KBM WinUI3 Editor UI project

* Test invoking the KBM library via wrapper for WinUI3 C# UI

* Set up Editor Library Wrapper and enable logging

* fix spelling

* update spacing and remove unused file

* fix formatting

* update sln

* update wrapper project config

* import common props

* update UI reference

* gate the new editor with the experimentation toggle in settings
2025-02-18 17:10:15 +08:00