PowerRename settings bugfix (#2796)
* PowerRename settings bugfix * Changed visibility to enability of PowerRename_Toggle_MaxDispListNum * Added unit tests and changed maximum value
This commit is contained in:
parent
1ecedd5566
commit
585c66a4d0
|
@ -38,6 +38,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||
{
|
||||
_maxSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_maxSize = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@
|
|||
<data name="PowerRename_Toggle_EnableOnExtendedContextMenu.Header" xml:space="preserve">
|
||||
<value>Appear only in extended context menu (Shift + Right-click)</value>
|
||||
</data>
|
||||
<data name="PowerRename_Toggle_MaxDispListNum.Text" xml:space="preserve">
|
||||
<data name="PowerRename_Toggle_MaxDispListNum.Header" xml:space="preserve">
|
||||
<value>Maximum numbers of items to show in recently used list for autocomplete dropdown</value>
|
||||
</data>
|
||||
<data name="PowerRename_Toggle_RestoreFlagsOnLaunch.Header" xml:space="preserve">
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
_powerRenameEnabled = value;
|
||||
OnPropertyChanged("IsEnabled");
|
||||
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +96,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
_autoComplete = value;
|
||||
Settings.properties.MRUEnabled.Value = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool GlobalAndMruEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _autoComplete && _powerRenameEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool EnabledOnContextMenu
|
||||
{
|
||||
get
|
||||
|
|
|
@ -53,12 +53,6 @@
|
|||
<TextBlock x:Uid="PowerRename_ShellIntergration"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_AutoComplete"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnContextMenu"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextMenu}"
|
||||
|
@ -80,20 +74,22 @@
|
|||
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
|
||||
<muxc:NumberBox x:Uid="PowerRename_Toggle_MaxDispListNum"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Value="{Binding Mode=TwoWay, Path=MaxDispListNum}"
|
||||
Minimum="0"
|
||||
Maximum="20"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=GlobalAndMruEnabled}"
|
||||
/>
|
||||
|
||||
<ToggleSwitch x:Uid="PowerRename_Toggle_RestoreFlagsOnLaunch"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=RestoreFlagsOnLaunch}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
|
||||
<muxc:NumberBox x:Name="PowerRename_Toggle_MaxDispListNum"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Value="{Binding Mode=TwoWay, Path=MaxDispListNum}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
|
|
@ -80,6 +80,55 @@ namespace ViewModelTests
|
|||
viewModel.MRUEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOffAndMRUEnabledIsOffGlobalAndMruShouldBeOff()
|
||||
{
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel();
|
||||
ShellPage.DefaultSndMSGCallback = msg => { };
|
||||
|
||||
viewModel.IsEnabled = false;
|
||||
viewModel.MRUEnabled = false;
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOffAndMRUEnabledIsOnGlobalAndMruShouldBeOff()
|
||||
{
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel();
|
||||
ShellPage.DefaultSndMSGCallback = msg => { };
|
||||
|
||||
viewModel.IsEnabled = false;
|
||||
viewModel.MRUEnabled = true;
|
||||
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOnAndMRUEnabledIsOffGlobalAndMruShouldBeOff()
|
||||
{
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel();
|
||||
ShellPage.DefaultSndMSGCallback = msg => { };
|
||||
|
||||
viewModel.IsEnabled = true;
|
||||
viewModel.MRUEnabled = false;
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOnAndMRUEnabledIsOnGlobalAndMruShouldBeOn()
|
||||
{
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel();
|
||||
ShellPage.DefaultSndMSGCallback = msg => { };
|
||||
|
||||
viewModel.IsEnabled = true;
|
||||
viewModel.MRUEnabled = true;
|
||||
|
||||
Assert.IsTrue(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnabledOnContextMenu_ShouldSetValue2True_WhenSuccessful()
|
||||
{
|
||||
|
@ -141,7 +190,7 @@ namespace ViewModelTests
|
|||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.AreEqual(20,snd.Powertoys.PowerRename.properties.MaxMRUSize.Value);
|
||||
Assert.AreEqual(20, snd.Powertoys.PowerRename.properties.MaxMRUSize.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
|
|
Loading…
Reference in a new issue