mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
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:
committed by
GitHub
parent
1ecedd5566
commit
585c66a4d0
@@ -38,6 +38,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
{
|
{
|
||||||
_maxSize = 0;
|
_maxSize = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_maxSize = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,7 @@
|
|||||||
<data name="PowerRename_Toggle_EnableOnExtendedContextMenu.Header" xml:space="preserve">
|
<data name="PowerRename_Toggle_EnableOnExtendedContextMenu.Header" xml:space="preserve">
|
||||||
<value>Appear only in extended context menu (Shift + Right-click)</value>
|
<value>Appear only in extended context menu (Shift + Right-click)</value>
|
||||||
</data>
|
</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>
|
<value>Maximum numbers of items to show in recently used list for autocomplete dropdown</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PowerRename_Toggle_RestoreFlagsOnLaunch.Header" xml:space="preserve">
|
<data name="PowerRename_Toggle_RestoreFlagsOnLaunch.Header" xml:space="preserve">
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
|
|
||||||
_powerRenameEnabled = value;
|
_powerRenameEnabled = value;
|
||||||
OnPropertyChanged("IsEnabled");
|
OnPropertyChanged("IsEnabled");
|
||||||
|
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,10 +96,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
_autoComplete = value;
|
_autoComplete = value;
|
||||||
Settings.properties.MRUEnabled.Value = value;
|
Settings.properties.MRUEnabled.Value = value;
|
||||||
RaisePropertyChanged();
|
RaisePropertyChanged();
|
||||||
|
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool GlobalAndMruEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _autoComplete && _powerRenameEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool EnabledOnContextMenu
|
public bool EnabledOnContextMenu
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -53,12 +53,6 @@
|
|||||||
<TextBlock x:Uid="PowerRename_ShellIntergration"
|
<TextBlock x:Uid="PowerRename_ShellIntergration"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
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"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnContextMenu"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextMenu}"
|
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextMenu}"
|
||||||
@@ -80,20 +74,22 @@
|
|||||||
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
||||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
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"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_RestoreFlagsOnLaunch"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
IsOn="{Binding Mode=TwoWay, Path=RestoreFlagsOnLaunch}"
|
IsOn="{Binding Mode=TwoWay, Path=RestoreFlagsOnLaunch}"
|
||||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
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>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,55 @@ namespace ViewModelTests
|
|||||||
viewModel.MRUEnabled = true;
|
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]
|
[TestMethod]
|
||||||
public void EnabledOnContextMenu_ShouldSetValue2True_WhenSuccessful()
|
public void EnabledOnContextMenu_ShouldSetValue2True_WhenSuccessful()
|
||||||
{
|
{
|
||||||
@@ -141,7 +190,7 @@ namespace ViewModelTests
|
|||||||
ShellPage.DefaultSndMSGCallback = msg =>
|
ShellPage.DefaultSndMSGCallback = msg =>
|
||||||
{
|
{
|
||||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(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
|
// act
|
||||||
|
|||||||
Reference in New Issue
Block a user