Skip to content

[Settings][Image Resizer] Edit/add presets in a ContentDialog instead of a Flyout#49161

Open
niels9001 wants to merge 3 commits into
mainfrom
niels9001-image-resizer-preset-dialog
Open

[Settings][Image Resizer] Edit/add presets in a ContentDialog instead of a Flyout#49161
niels9001 wants to merge 3 commits into
mainfrom
niels9001-image-resizer-preset-dialog

Conversation

@niels9001

@niels9001 niels9001 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

Replaces the inline preset-edit Flyout on the Image Resizer settings page with a ContentDialog, matching the add/edit pattern already used on the Color Picker page. This aligns the experience with the Windows 11 / Fluent paradigm and fixes preset settings being saved on every intermediate change.

Editing now happens on a working copy of the preset (ImageSize.Clone()), which is committed only when the user presses Save/Update. As a side effect, the intermediate width/height spinner changes no longer persist settings.json / sizes.json on every value change — resolving #36938.

The per-row delete action moves from an inline trash button into a "..." (More options) MenuFlyout, again matching the Color Picker page.

Historically this editing was a Flyout rather than a ContentDialog due to known ContentDialog / XamlRoot issues back when Settings was a UWP app. Now that Settings is on WinUI 3 / Windows App SDK, ContentDialog works reliably (as Color Picker's ColorFormatDialog demonstrates), so the original constraint no longer applies.

ImageResizer.mp4

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • Dialog: Clicking a preset card (or Add new size) opens an EditSizeDialog ContentDialog. Fields are bound with compiled {x:Bind} against a working-copy EditingSize. The dimensions field header is dynamic — "Width" when height is used, "Size" for aspect-ratio-preserving percentage scaling — so the label isn't misleading. The dialog is widened for a less cramped layout.
  • Save semantics:
    • ImageSize.Clone() — builds the editable working copy.
    • ImageResizerViewModel.CreateNewImageSizeModel() — builds a default-valued model for the add dialog without adding it to Sizes.
    • ImageResizerViewModel.AddImageSize(ImageSize) — commits a new preset with the next unique ID.
    • ImageResizerViewModel.UpdateImageSize(original, updated) — applies edited values back onto the original, temporarily detaching the per-item PropertyChanged save handler so it persists once instead of on every property. This is what fixes the "saved too often" behavior in [Settings] ImageResizer settings files may be saved too often #36938.
  • Delete: per-row ButtonMenuFlyout with a Delete MenuFlyoutItem; the ImageSize is passed via CommandParameter="{x:Bind}" (robust inside a flyout popup) and the Yes/No confirmation dialog is preserved.

Validation Steps Performed

  • Built PowerToys.Settings (x64/Debug) — clean (exit 0).
  • Ran the runner from this build and manually validated in Settings → Image Resizer:
    • Add new size opens the dialog pre-filled; Save adds the preset; Cancel discards.
    • Editing a preset in the dialog and pressing Cancel leaves the original untouched (working-copy clone).
    • Selecting Percent shows the Size header (not a misleading "Width").
    • Spinning width/height inside the dialog no longer writes settings files on each change; a single save occurs on Update ([Settings] ImageResizer settings files may be saved too often #36938).
    • The "..." menu shows Delete, with the confirmation dialog intact.

Replace the inline preset-edit Flyout with a ContentDialog that matches
the Color Picker add/edit pattern. Editing now happens on a working copy
(ImageSize.Clone) that is committed only when the user hits Save, so the
intermediate width/height spinner changes no longer persist settings.json
and sizes.json on every change. The dialog uses compiled {x:Bind}
bindings and a dynamic Width/Size field header.

Also move the per-row delete action into a "..." MenuFlyout (matching the
Color Picker page) instead of an inline trash button.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added Product-Image Resizer Things regarding image resizing module Product-Settings The standalone PowerToys Settings application labels Jul 6, 2026
niels9001 and others added 2 commits July 6, 2026 17:14
- De-duplicate the legacy AddImageSize(string) into a thin wrapper over
  CreateNewImageSizeModel + AddImageSize(ImageSize).
- Drop the dead "Remove" mapping from
  ImageResizerSizeToAccessibleTextConverter (delete now lives in the "..."
  MenuFlyout, so no XAML passes 'Remove').
- Remove 6 resw entries orphaned by replacing the Flyout with the dialog.
- Add unit tests for CreateNewImageSizeModel, AddImageSize(ImageSize) and
  UpdateImageSize.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fix attribute ordering on the NumberBox in EditSizeDialog to satisfy the
CI XAML Styler check (.\.pipelines\applyXamlStyling.ps1).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Image Resizer Things regarding image resizing module Product-Settings The standalone PowerToys Settings application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Settings][Image Resizer] Edit/add presets in a ContentDialog instead of a Flyout [Settings] ImageResizer settings files may be saved too often

1 participant