mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[CmdPal] Open CmdPal settings from PT settings (#39262)
* Turning description into a hyperlink * Update expect.txt * Update CmdPalPage.xaml.cs * update xaml format. Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> * update. Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> * Added logger Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> * update Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> --------- Signed-off-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Shawn Yuan <shuai.yuan.zju@gmail.com> Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
This commit is contained in:
@@ -2,6 +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 System.Diagnostics;
|
||||
using System.IO;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
@@ -29,5 +33,37 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void LaunchApp(string appPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
string dir = Path.GetDirectoryName(appPath);
|
||||
|
||||
var processStartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = appPath,
|
||||
Arguments = string.Empty,
|
||||
WorkingDirectory = dir,
|
||||
UseShellExecute = true,
|
||||
Verb = "open",
|
||||
CreateNoWindow = false,
|
||||
};
|
||||
|
||||
Process process = Process.Start(processStartInfo) ?? throw new InvalidOperationException("Failed to start the process.");
|
||||
process.WaitForInputIdle();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException($"Failed to launch CmdPal settings: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void CmdPalSettingsDeeplink_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
// Launch CmdPal settings window
|
||||
string launchPath = "x-cmdpal://settings";
|
||||
LaunchApp(launchPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user