[Peek]Create Setting to run not elevated (#26308)

* [Peek]Create Setting to run not elevated

* Optionally add access permissions to the handles
This commit is contained in:
Jaime Bernardo
2023-05-25 17:39:52 +01:00
committed by GitHub
parent 4560abe557
commit 42e707966d
7 changed files with 105 additions and 23 deletions

View File

@@ -11,10 +11,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public PeekProperties()
{
ActivationShortcut = new HotkeySettings(false, true, false, false, 0x20);
AlwaysRunNotElevated = new BoolProperty(true);
}
public HotkeySettings ActivationShortcut { get; set; }
public BoolProperty AlwaysRunNotElevated { get; set; }
public override string ToString() => JsonSerializer.Serialize(this);
}
}

View File

@@ -2833,6 +2833,16 @@ From there, simply click on one of the supported files in the File Explorer and
<value>Enable Peek</value>
<comment>Peek is a product name, do not loc</comment>
</data>
<data name="Peek_BehaviorHeader.Header" xml:space="preserve">
<value>Behavior</value>
</data>
<data name="Peek_AlwaysRunNotElevated.Header" xml:space="preserve">
<value>Always run not elevated, even when PowerToys is elevated</value>
</data>
<data name="Peek_AlwaysRunNotElevated.Description" xml:space="preserve">
<value>Tries to run Peek without elevated permissions, to fix access to network shares. You need to disable and re-enable Peek for changes to this value to take effect.</value>
<comment>Peek is a product name, do not loc</comment>
</data>
<data name="FancyZones_DisableRoundCornersOnWindowSnap.Content" xml:space="preserve">
<value>Disable round corners when window is snapped</value>
</data>

View File

@@ -109,6 +109,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool AlwaysRunNotElevated
{
get => _peekSettings.Properties.AlwaysRunNotElevated.Value;
set
{
if (_peekSettings.Properties.AlwaysRunNotElevated.Value != value)
{
_peekSettings.Properties.AlwaysRunNotElevated.Value = value;
OnPropertyChanged(nameof(AlwaysRunNotElevated));
NotifySettingsChanged();
}
}
}
private void NotifySettingsChanged()
{
// Using InvariantCulture as this is an IPC message

View File

@@ -31,6 +31,14 @@
<controls:ShortcutControl MinWidth="{StaticResource SettingActionControlMinWidth}" HotkeySettings="{x:Bind Path=ViewModel.ActivationShortcut, Mode=TwoWay}" />
</labs:SettingsCard>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="Peek_BehaviorHeader" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">
<labs:SettingsCard x:Uid="Peek_AlwaysRunNotElevated" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xE7EF;}">
<ToggleSwitch
x:Uid="ToggleSwitch"
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.AlwaysRunNotElevated}" />
</labs:SettingsCard>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>
<controls:SettingsPageControl.PrimaryLinks>