[Settings] 'Check for updates' button behavior changed (#4385)

This commit is contained in:
Seraphima Zykova
2020-06-23 15:53:02 +03:00
committed by GitHub
parent 87f0fcfd52
commit 5c1999b3d0
18 changed files with 460 additions and 87 deletions

View File

@@ -50,6 +50,12 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
System.Windows.Application.Current.Shutdown(); // close application
});
// send IPC Message
shellPage.SetCheckForUpdatesMessageCallback(msg =>
{
Program.GetTwoWayIPCManager().Send(msg);
});
shellPage.SetElevationStatus(Program.IsElevated);
shellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin);
shellPage.Refresh();

View File

@@ -352,7 +352,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
// callback function to launch the URL to check for updates.
private async void CheckForUpdates_Click()
{
await Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/PowerToys/releases"));
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
settings.CustomActionName = "check_for_updates";
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
if (ShellPage.CheckForUpdatesMsgCallback != null)
{
ShellPage.CheckForUpdatesMsgCallback(customaction.ToString());
}
}
public void Restart_Elevated()

View File

@@ -33,6 +33,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public static IPCMessageCallback SndRestartAsAdminMsgCallback { get; set; }
/// <summary>
/// Gets or sets iPC callback function for checking updates.
/// </summary>
public static IPCMessageCallback CheckForUpdatesMsgCallback { get; set; }
/// <summary>
/// Gets view model.
/// </summary>
@@ -74,6 +79,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
SndRestartAsAdminMsgCallback = implementation;
}
/// <summary>
/// Set check for updates IPC callback function.
/// </summary>
/// <param name="implementation">delegate function implementation.</param>
public void SetCheckForUpdatesMessageCallback(IPCMessageCallback implementation)
{
CheckForUpdatesMsgCallback = implementation;
}
public void SetElevationStatus(bool isElevated)
{
IsElevated = isElevated;