[Settings]Add a link to the OOBE What's New page in the Settings menu (#29028)

* Adds a link to the OOBE What's New Section in the ShellPage Navigation

* Updated verbiage to code as per recommendation

* Updated so that if the Oobe Window is active, clicking on the What's New option in the ShellPage navigates to the What's New page.

Added a "SetActiveWindow" Method the OobeWindow to easily open an active window of a set PowerToysModule type - this is to support being able to open the What's New Page without having to close the Oobe Window and close it every time.

* Renamed SetActiveWindow to SetAppWindow

* Adjusted method and property names for naming consistency across the application

* Fixed an oversight.

---------

Co-authored-by: Ian Kraynak <iakrayna@microsoft.com>
This commit is contained in:
Ian Kraynak
2023-11-21 14:19:11 -05:00
committed by GitHub
parent 949b9a6185
commit 1a8007ca0a
5 changed files with 55 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ using ManagedCommon;
using Microsoft.PowerLauncher.Telemetry; using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.UI; using Microsoft.UI;
@@ -112,6 +113,21 @@ namespace Microsoft.PowerToys.Settings.UI
App.GetOobeWindow().Activate(); App.GetOobeWindow().Activate();
}); });
// open whats new window
ShellPage.SetOpenWhatIsNewCallback(() =>
{
if (App.GetOobeWindow() == null)
{
App.SetOobeWindow(new OobeWindow(Microsoft.PowerToys.Settings.UI.OOBE.Enums.PowerToysModules.WhatsNew, App.IsDarkTheme()));
}
else
{
App.GetOobeWindow().SetAppWindow(OOBE.Enums.PowerToysModules.WhatsNew);
}
App.GetOobeWindow().Activate();
});
// open flyout // open flyout
ShellPage.SetOpenFlyoutCallback((POINT? p) => ShellPage.SetOpenFlyoutCallback((POINT? p) =>
{ {

View File

@@ -105,6 +105,14 @@ namespace Microsoft.PowerToys.Settings.UI
}); });
} }
public void SetAppWindow(PowerToysModules module)
{
if (shellPage != null)
{
shellPage.NavigateToModule(module);
}
}
private void OobeWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args) private void OobeWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args)
{ {
var dpi = NativeMethods.GetDpiForWindow(_hWnd); var dpi = NativeMethods.GetDpiForWindow(_hWnd);

View File

@@ -215,6 +215,10 @@
x:Uid="OOBE_NavViewItem" x:Uid="OOBE_NavViewItem"
Icon="{ui:FontIcon Glyph=&#xF133;}" Icon="{ui:FontIcon Glyph=&#xF133;}"
Tapped="OOBEItem_Tapped" /> Tapped="OOBEItem_Tapped" />
<NavigationViewItem
x:Uid="WhatIsNew_NavViewItem"
Icon="{ui:FontIcon Glyph=&#xF133;}"
Tapped="WhatIsNewItem_Tapped" />
<NavigationViewItem <NavigationViewItem
x:Uid="Feedback_NavViewItem" x:Uid="Feedback_NavViewItem"
Icon="{ui:FontIcon Glyph=&#xED15;}" Icon="{ui:FontIcon Glyph=&#xED15;}"

View File

@@ -42,6 +42,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary> /// </summary>
public delegate void OobeOpeningCallback(); public delegate void OobeOpeningCallback();
/// <summary>
/// Declaration for the opening whats new window callback function.
/// </summary>
public delegate void WhatIsNewOpeningCallback();
/// <summary> /// <summary>
/// Declaration for the opening flyout window callback function. /// Declaration for the opening flyout window callback function.
/// </summary> /// </summary>
@@ -87,6 +92,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary> /// </summary>
public static OobeOpeningCallback OpenOobeWindowCallback { get; set; } public static OobeOpeningCallback OpenOobeWindowCallback { get; set; }
/// <summary>
/// Gets or sets callback function for opening oobe window
/// </summary>
public static WhatIsNewOpeningCallback OpenWhatIsNewWindowCallback { get; set; }
/// <summary> /// <summary>
/// Gets or sets callback function for opening flyout window /// Gets or sets callback function for opening flyout window
/// </summary> /// </summary>
@@ -202,6 +212,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
OpenOobeWindowCallback = implementation; OpenOobeWindowCallback = implementation;
} }
/// <summary>
/// Set whats new opening callback function
/// </summary>
/// <param name="implementation">delegate function implementation.</param>
public static void SetOpenWhatIsNewCallback(WhatIsNewOpeningCallback implementation)
{
OpenWhatIsNewWindowCallback = implementation;
}
/// <summary> /// <summary>
/// Set flyout opening callback function /// Set flyout opening callback function
/// </summary> /// </summary>
@@ -317,6 +336,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
await Launcher.LaunchUriAsync(new Uri("https://aka.ms/powerToysGiveFeedback")); await Launcher.LaunchUriAsync(new Uri("https://aka.ms/powerToysGiveFeedback"));
} }
private void WhatIsNewItem_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
OpenWhatIsNewWindowCallback();
}
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{ {
NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem; NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem;

View File

@@ -2182,6 +2182,9 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="Oobe_NavViewItem.Content" xml:space="preserve"> <data name="Oobe_NavViewItem.Content" xml:space="preserve">
<value>Welcome to PowerToys</value> <value>Welcome to PowerToys</value>
<comment>Don't loc "PowerToys"</comment> <comment>Don't loc "PowerToys"</comment>
</data>
<data name="WhatIsNew_NavViewItem.Content" xml:space="preserve">
<value>What's New</value>
</data> </data>
<data name="Feedback_NavViewItem.Content" xml:space="preserve"> <data name="Feedback_NavViewItem.Content" xml:space="preserve">
<value>Give feedback</value> <value>Give feedback</value>