mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Win arrows revisited (#5932)
* Added the setting * Refactored existing code, the main feature isn't implemented yet * Renamed a method * Updated a comment in IZoneWindow * Added the zone selection algorithm, didn't test it * Basic features work * Single monitor cycling works * Seems that the feature works well * Polished the settings page * Rebase fix * Fixed a null pointer dereference * Use classic if syntax * Fixed bad indentation How did these lines unindent themselves? * Removed TODO comment * Rebase fix * Another rebase fix
This commit is contained in:
@@ -17,6 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
FancyzonesOverrideSnapHotkeys = new BoolProperty();
|
||||
FancyzonesMouseSwitch = new BoolProperty();
|
||||
FancyzonesMoveWindowsAcrossMonitors = new BoolProperty();
|
||||
FancyzonesMoveWindowsBasedOnPosition = new BoolProperty();
|
||||
FancyzonesDisplayChangeMoveWindows = new BoolProperty();
|
||||
FancyzonesZoneSetChangeMoveWindows = new BoolProperty();
|
||||
FancyzonesAppLastZoneMoveWindows = new BoolProperty();
|
||||
@@ -46,6 +47,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
[JsonPropertyName("fancyzones_moveWindowAcrossMonitors")]
|
||||
public BoolProperty FancyzonesMoveWindowsAcrossMonitors { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_moveWindowsBasedOnPosition")]
|
||||
public BoolProperty FancyzonesMoveWindowsBasedOnPosition { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_displayChange_moveWindows")]
|
||||
public BoolProperty FancyzonesDisplayChangeMoveWindows { get; set; }
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value;
|
||||
_overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
|
||||
_moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
|
||||
_moveWindowsBasedOnPosition = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value;
|
||||
_displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
|
||||
_zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
|
||||
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
|
||||
@@ -84,6 +85,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
private bool _mouseSwitch;
|
||||
private bool _overrideSnapHotkeys;
|
||||
private bool _moveWindowsAcrossMonitors;
|
||||
private bool _moveWindowsBasedOnPosition;
|
||||
private bool _displayChangemoveWindows;
|
||||
private bool _zoneSetChangeMoveWindows;
|
||||
private bool _appLastZoneMoveWindows;
|
||||
@@ -119,10 +121,19 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
|
||||
SendConfigMSG(snd.ToString());
|
||||
OnPropertyChanged("IsEnabled");
|
||||
OnPropertyChanged("SnapHotkeysCategoryEnabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool SnapHotkeysCategoryEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isEnabled && _overrideSnapHotkeys;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShiftDrag
|
||||
{
|
||||
get
|
||||
@@ -178,6 +189,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_overrideSnapHotkeys = value;
|
||||
Settings.Properties.FancyzonesOverrideSnapHotkeys.Value = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("SnapHotkeysCategoryEnabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,6 +212,24 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveWindowsBasedOnPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return _moveWindowsBasedOnPosition;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _moveWindowsBasedOnPosition)
|
||||
{
|
||||
_moveWindowsBasedOnPosition = value;
|
||||
Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool DisplayChangeMoveWindows
|
||||
{
|
||||
get
|
||||
|
||||
@@ -107,6 +107,25 @@ namespace ViewModelTests
|
||||
viewModel.OverrideSnapHotkeys = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MoveWindowsBasedOnPosition_ShouldSetValue2True_WhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> SendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize<FancyZonesSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.FancyZones.Properties.FancyzonesMoveWindowsBasedOnPosition.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(SendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.MoveWindowsBasedOnPosition); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.MoveWindowsBasedOnPosition = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ZoneSetChangeFlashZones_ShouldSetValue2False_WhenSuccessful()
|
||||
{
|
||||
|
||||
@@ -319,7 +319,7 @@
|
||||
<value>Use a non-primary mouse button to toggle zone activation</value>
|
||||
</data>
|
||||
<data name="FancyZones_MoveWindowsAcrossAllMonitorsCheckBoxControl.Content" xml:space="preserve">
|
||||
<value>Move windows between zones across all monitors when snapping with (Win + Arrow)</value>
|
||||
<value>Move windows between zones across all monitors</value>
|
||||
</data>
|
||||
<data name="FancyZones_OverrideSnapHotkeysCheckBoxControl.Content" xml:space="preserve">
|
||||
<value>Override Windows Snap shortcut (Win + Arrow) to move windows between zones</value>
|
||||
@@ -666,4 +666,7 @@
|
||||
<data name="ImageResizer_Formatting_Sizename.Text" xml:space="preserve">
|
||||
<value>Size name</value>
|
||||
</data>
|
||||
<data name="FancyZones_MoveWindowsBasedOnPositionCheckBoxControl.Content" xml:space="preserve">
|
||||
<value>Move windows based on their position</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -100,10 +100,15 @@
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
|
||||
|
||||
<CheckBox x:Uid="FancyZones_MoveWindowsBasedOnPositionCheckBoxControl"
|
||||
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsBasedOnPosition}"
|
||||
Margin="24,12,0,0"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SnapHotkeysCategoryEnabled}"/>
|
||||
|
||||
<CheckBox x:Uid="FancyZones_MoveWindowsAcrossAllMonitorsCheckBoxControl"
|
||||
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsAcrossMonitors}"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
|
||||
Margin="24,12,0,0"
|
||||
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SnapHotkeysCategoryEnabled}"/>
|
||||
|
||||
<CheckBox x:Uid="FancyZones_DisplayChangeMoveWindowsCheckBoxControl"
|
||||
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.DisplayChangeMoveWindows}"
|
||||
|
||||
Reference in New Issue
Block a user