[PowerDisplay] Add custom vcp code name map and fix some bugs (#45355)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
1. Fix quick access not working bug
2. Add custom value mapping
3. Fix some vcp slider visibility bug

demo for custom vcp value name mapping:
<img width="1399" height="744" alt="image"
src="https://github.com/user-attachments/assets/517e4dbb-409a-4e43-b15a-d0d31e59ce49"
/>
<img width="1379" height="337" alt="image"
src="https://github.com/user-attachments/assets/18f6f389-089c-4441-ad9f-5c45cac53814"
/>
<img width="521" height="1152" alt="image"
src="https://github.com/user-attachments/assets/27b5f796-66fa-4781-b16f-4770bebf3504"
/>
<img width="295" height="808" alt="image"
src="https://github.com/user-attachments/assets/54eaf5b9-5d54-4531-a40b-de3113122715"
/>


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Yu Leng <yuleng@microsoft.com>
This commit is contained in:
moooyo
2026-02-05 17:02:55 +08:00
committed by GitHub
parent 4c0926d7b7
commit 3336c134dd
16 changed files with 1195 additions and 40 deletions

View File

@@ -133,6 +133,65 @@ namespace Microsoft.PowerToys.Settings.UI.Views
return ProfileHelper.GenerateUniqueProfileName(existingNames, baseName);
}
// Custom VCP Mapping event handlers
private async void AddCustomMapping_Click(object sender, RoutedEventArgs e)
{
var dialog = new CustomVcpMappingEditorDialog(ViewModel.Monitors);
dialog.XamlRoot = this.XamlRoot;
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary && dialog.ResultMapping != null)
{
ViewModel.AddCustomVcpMapping(dialog.ResultMapping);
}
}
private async void EditCustomMapping_Click(object sender, RoutedEventArgs e)
{
if (sender is not Button button || button.Tag is not CustomVcpValueMapping mapping)
{
return;
}
var dialog = new CustomVcpMappingEditorDialog(ViewModel.Monitors);
dialog.XamlRoot = this.XamlRoot;
dialog.PreFillMapping(mapping);
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary && dialog.ResultMapping != null)
{
ViewModel.UpdateCustomVcpMapping(mapping, dialog.ResultMapping);
}
}
private async void DeleteCustomMapping_Click(object sender, RoutedEventArgs e)
{
if (sender is not Button button || button.Tag is not CustomVcpValueMapping mapping)
{
return;
}
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
var dialog = new ContentDialog
{
XamlRoot = this.XamlRoot,
Title = resourceLoader.GetString("PowerDisplay_CustomMapping_Delete_Title"),
Content = resourceLoader.GetString("PowerDisplay_CustomMapping_Delete_Message"),
PrimaryButtonText = resourceLoader.GetString("Yes"),
CloseButtonText = resourceLoader.GetString("No"),
DefaultButton = ContentDialogButton.Close,
};
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
ViewModel.DeleteCustomVcpMapping(mapping);
}
}
// Flag to prevent reentrant handling during programmatic checkbox changes
private bool _isRestoringColorTempCheckbox;