-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Settings deep link logic to Microsoft.PowerToys.Common.UI (#13749)
* Move Settings deep link logic to Microsoft.PowerToys.Common.UI * Spellcheck * Introduce enum * Remove PT path arg
- Loading branch information
1 parent
0ca9b1b
commit 7e8e954
Showing
4 changed files
with
79 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2009,6 +2009,7 @@ stdlib | |
STDMETHODCALLTYPE | ||
STDMETHODIMP | ||
stdout | ||
stefan | ||
STEPIT | ||
stgm | ||
STGMEDIUM | ||
|
74 changes: 74 additions & 0 deletions
74
src/common/Microsoft.PowerToys.Common.UI/SettingsDeepLink.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Microsoft.PowerToys.Common.UI | ||
{ | ||
public static class SettingsDeepLink | ||
{ | ||
public enum SettingsWindow | ||
{ | ||
Overview = 0, | ||
Awake, | ||
ColorPicker, | ||
FancyZones, | ||
Run, | ||
ImageResizer, | ||
KBM, | ||
PowerRename, | ||
FileExplorer, | ||
ShortcutGuide, | ||
VideoConference, | ||
} | ||
|
||
private static string SettingsWindowNameToString(SettingsWindow value) | ||
{ | ||
switch (value) | ||
{ | ||
case SettingsWindow.Overview: | ||
return "Overview"; | ||
case SettingsWindow.Awake: | ||
return "Awake"; | ||
case SettingsWindow.ColorPicker: | ||
return "ColorPicker"; | ||
case SettingsWindow.FancyZones: | ||
return "FancyZones"; | ||
case SettingsWindow.Run: | ||
return "Run"; | ||
case SettingsWindow.ImageResizer: | ||
return "ImageResizer"; | ||
case SettingsWindow.KBM: | ||
return "KBM"; | ||
case SettingsWindow.PowerRename: | ||
return "PowerRename"; | ||
case SettingsWindow.FileExplorer: | ||
return "FileExplorer"; | ||
case SettingsWindow.ShortcutGuide: | ||
return "ShortcutGuide"; | ||
case SettingsWindow.VideoConference: | ||
return "VideoConference"; | ||
default: | ||
{ | ||
return string.Empty; | ||
} | ||
} | ||
} | ||
|
||
public static void OpenSettings(SettingsWindow window) | ||
{ | ||
try | ||
{ | ||
Process.Start(new ProcessStartInfo(Environment.CurrentDirectory + "\\PowerToys.exe") { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); | ||
} | ||
#pragma warning disable CA1031 // Do not catch general exception types | ||
catch | ||
#pragma warning restore CA1031 // Do not catch general exception types | ||
{ | ||
// TODO(stefan): Log exception once unified logging is implemented | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters