From db953bb325f014d7d1c4bf65e627fd21f1dd7552 Mon Sep 17 00:00:00 2001
From: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com>
Date: Thu, 21 Aug 2025 10:40:37 +0200
Subject: [PATCH] [Settings] Move title bar shutdown button to navigation view
(#40714)
## Summary of the Pull Request
Based on
https://github.com/microsoft/PowerToys/pull/40260#issuecomment-3085099815
feedback, this PR remove the title bar shutdown button in favor of a
menu item in the navigation view footer.
- Menu item is visible only when tray icon is hidden
- A confirm dialog has been added
- Close is used in tray icon menu for closing app
## PR Checklist
- [x] **Closes:** #40346 #40577
- [x] **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
- [x] **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
## Detailed Description of the Pull Request / Additional comments
## Validation Steps Performed
- Open settings with tray icon visible: close menu is hidden
- Open settings with tray icon hidden: close menu is visible
- Tested close menu visibility change when tray icon option is changed
- Tested cancel button of close dialog
- Tested close button of dialog
---------
Co-authored-by: Niels Laute
---
.../Helpers/TrayIconService.cs | 2 +-
.../Strings/en-us/Resources.resw | 5 ++-
src/runner/Resources.resx | 8 ++--
src/runner/resource.base.h | 2 +-
src/runner/runner.base.rc | Bin 2968 -> 2972 bytes
src/runner/tray_icon.cpp | 6 +--
.../SettingsXAML/Views/GeneralPage.xaml | 5 ++-
.../SettingsXAML/Views/GeneralPage.xaml.cs | 26 +++++------
.../SettingsXAML/Views/ShellPage.xaml | 41 ++++++------------
.../SettingsXAML/Views/ShellPage.xaml.cs | 18 +++++---
.../Settings.UI/Strings/en-us/Resources.resw | 22 ++++++++--
.../Settings.UI/ViewModels/ShellViewModel.cs | 22 +++++++---
12 files changed, 90 insertions(+), 67 deletions(-)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
index 224c851ff1..442341cc5e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
@@ -92,7 +92,7 @@ internal sealed partial class TrayIconService
{
_popupMenu = PInvoke.CreatePopupMenu_SafeHandle();
PInvoke.InsertMenu(_popupMenu, 0, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 1, RS_.GetString("TrayMenu_Settings"));
- PInvoke.InsertMenu(_popupMenu, 1, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 2, RS_.GetString("TrayMenu_Exit"));
+ PInvoke.InsertMenu(_popupMenu, 1, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 2, RS_.GetString("TrayMenu_Close"));
}
}
else
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw
index f5810a0513..dd69fa78d4 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw
@@ -419,8 +419,9 @@ Right-click to remove the key combination, thereby deactivating the shortcut.
Settings
-
- Exit
+
+ Close
+ Close as a verb, as in Close the applicationDirect
diff --git a/src/runner/Resources.resx b/src/runner/Resources.resx
index 3cc2f1ad36..c8eb5f25cc 100644
--- a/src/runner/Resources.resx
+++ b/src/runner/Resources.resx
@@ -176,10 +176,6 @@
Documentation
-
- Exit
- Exit as a verb, as in Exit the application
-
Report bug
@@ -193,4 +189,8 @@
Administrator
+
+ Close
+ Close as a verb, as in Close the application
+
\ No newline at end of file
diff --git a/src/runner/resource.base.h b/src/runner/resource.base.h
index 027f5b4281..7037f4342d 100644
--- a/src/runner/resource.base.h
+++ b/src/runner/resource.base.h
@@ -15,7 +15,7 @@
#define APPICON 101
#define ID_TRAY_MENU 102
-#define ID_EXIT_MENU_COMMAND 40001
+#define ID_CLOSE_MENU_COMMAND 40001
#define ID_SETTINGS_MENU_COMMAND 40002
#define ID_ABOUT_MENU_COMMAND 40003
#define ID_REPORT_BUG_COMMAND 40004
diff --git a/src/runner/runner.base.rc b/src/runner/runner.base.rc
index 10a4555db8ec5de58a2a12eb479c9547d7d7c186..367735ade45b0cdbe086a95fb5a2ce45f3cec744 100644
GIT binary patch
delta 48
zcmbOsK1Y1RCT4kOh8%``hGK?P1|
-
+
-
-
-
-
-
+
-
-
-
+
@@ -309,5 +289,12 @@
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
index 11835ceeb2..57abe04119 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation
+// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
+using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Windowing;
@@ -113,7 +114,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
///
/// Gets view model.
///
- public ShellViewModel ViewModel { get; } = new ShellViewModel();
+ public ShellViewModel ViewModel { get; }
///
/// Gets a collection of functions that handle IPC responses.
@@ -134,6 +135,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
InitializeComponent();
+ var settingsUtils = new SettingsUtils();
+ ViewModel = new ShellViewModel(SettingsRepository.GetInstance(settingsUtils));
DataContext = ViewModel;
ShellHandler = this;
ViewModel.Initialize(shellFrame, navigationView, KeyboardAccelerators);
@@ -461,17 +464,22 @@ namespace Microsoft.PowerToys.Settings.UI.Views
navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
}
- private void ExitPTItem_Tapped(object sender, RoutedEventArgs e)
+ private async void Close_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
+ {
+ await CloseDialog.ShowAsync();
+ }
+
+ private void CloseDialog_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
const string ptTrayIconWindowClass = "PToyTrayIconWindow"; // Defined in runner/tray_icon.h
- const nuint ID_EXIT_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc
+ const nuint ID_CLOSE_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc
// Exit the XAML application
Application.Current.Exit();
// Invoke the exit command from the tray icon
IntPtr hWnd = NativeMethods.FindWindow(ptTrayIconWindowClass, ptTrayIconWindowClass);
- NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_EXIT_MENU_COMMAND, 0);
+ NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_CLOSE_MENU_COMMAND, 0);
}
}
}
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index 7eede397b3..8834d22600 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -1,4 +1,4 @@
-
+