mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[Settings] Temporary string showing the latest available version (#6254)
This commit is contained in:
@@ -106,6 +106,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
private bool _isSystemThemeRadioButtonChecked = false;
|
||||
private bool _autoDownloadUpdates = false;
|
||||
|
||||
private string _latestAvailableVersion = string.Empty;
|
||||
|
||||
// Gets or sets a value indicating whether packaged.
|
||||
public bool Packaged
|
||||
{
|
||||
@@ -328,11 +330,28 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// Temp string. Appears when a user clicks "Check for updates" button and shows latest version available on the Github.
|
||||
public string LatestAvailableVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _latestAvailableVersion;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_latestAvailableVersion != value)
|
||||
{
|
||||
_latestAvailableVersion = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
// Notify UI of property change
|
||||
OnPropertyChanged(propertyName);
|
||||
|
||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfigs);
|
||||
|
||||
SendConfigMSG(outsettings.ToString());
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.PowerLauncher.Telemetry;
|
||||
using Microsoft.PowerToys.Settings.UI.Views;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Data.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||
{
|
||||
@@ -56,6 +56,25 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||
Program.GetTwoWayIPCManager().Send(msg);
|
||||
});
|
||||
|
||||
// receive IPC Message
|
||||
Program.IPCMessageReceivedCallback = (string msg) =>
|
||||
{
|
||||
if (ShellPage.ShellHandler.IPCResponseHandleList != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonObject json = JsonObject.Parse(msg);
|
||||
foreach (Action<JsonObject> handle in ShellPage.ShellHandler.IPCResponseHandleList)
|
||||
{
|
||||
handle(json);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
shellPage.SetElevationStatus(Program.IsElevated);
|
||||
shellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin);
|
||||
shellPage.Refresh();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||
|
||||
public static int PowerToysPID { get; set; }
|
||||
|
||||
public static Action<string> IPCMessageReceivedCallback { get; set; }
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -63,7 +65,16 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||
Environment.Exit(0);
|
||||
});
|
||||
|
||||
ipcmanager = new TwoWayPipeMessageIPCManaged(args[1], args[0], null);
|
||||
ipcmanager = new TwoWayPipeMessageIPCManaged(args[1], args[0], (string message) =>
|
||||
{
|
||||
if (IPCMessageReceivedCallback != null && message.Length > 0)
|
||||
{
|
||||
Application.Current.Dispatcher.BeginInvoke(new System.Action(() =>
|
||||
{
|
||||
IPCMessageReceivedCallback(message);
|
||||
}));
|
||||
}
|
||||
});
|
||||
ipcmanager.Start();
|
||||
app.Run();
|
||||
}
|
||||
|
||||
@@ -723,4 +723,10 @@
|
||||
<data name="FancyZones_MoveWindowsBasedOnPositionCheckBoxControl.Content" xml:space="preserve">
|
||||
<value>Move windows based on their position</value>
|
||||
</data>
|
||||
<data name="GeneralSettings_NewVersionIsAvailable" xml:space="preserve">
|
||||
<value>New update available</value>
|
||||
</data>
|
||||
<data name="GeneralSettings_VersionIsLatest" xml:space="preserve">
|
||||
<value>You have the latest available version.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -116,6 +116,9 @@
|
||||
<HyperlinkButton NavigateUri="https://github.com/microsoft/PowerToys/releases" Margin="4,-6,0,0">
|
||||
<TextBlock Text="{x:Bind ViewModel.PowerToysVersion }" />
|
||||
</HyperlinkButton>
|
||||
<TextBlock Text="{x:Bind ViewModel.LatestAvailableVersion, Mode=OneWay}"
|
||||
Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}"
|
||||
Margin="16,0,0,0" />
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Lib.ViewModels;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Data.Json;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
@@ -40,6 +42,34 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
ShellPage.SendRestartAdminIPCMessage,
|
||||
ShellPage.SendCheckForUpdatesIPCMessage);
|
||||
|
||||
ShellPage.ShellHandler.IPCResponseHandleList.Add((JsonObject json) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string version = json.GetNamedString("version");
|
||||
bool isLatest = json.GetNamedBoolean("isVersionLatest");
|
||||
|
||||
var str = string.Empty;
|
||||
if (isLatest)
|
||||
{
|
||||
str = ResourceLoader.GetForCurrentView().GetString("GeneralSettings_VersionIsLatest");
|
||||
}
|
||||
else if (version != string.Empty)
|
||||
{
|
||||
str = ResourceLoader.GetForCurrentView().GetString("GeneralSettings_NewVersionIsAvailable");
|
||||
if (str != string.Empty)
|
||||
{
|
||||
str += ": " + version;
|
||||
}
|
||||
}
|
||||
|
||||
ViewModel.LatestAvailableVersion = string.Format(str);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
DataContext = ViewModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
using Windows.Data.Json;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
@@ -43,6 +45,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
/// </summary>
|
||||
public ShellViewModel ViewModel { get; } = new ShellViewModel();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of functions that handle IPC responses.
|
||||
/// </summary>
|
||||
public List<System.Action<JsonObject>> IPCResponseHandleList { get; } = new List<System.Action<JsonObject>>();
|
||||
|
||||
public static bool IsElevated { get; set; }
|
||||
|
||||
public static bool IsUserAnAdmin { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user