[FancyZones] Overlapping zones selection algorithm - settings (#9874)

* Started work

* Removed bools in favor of an enum, renamed some

* Done something but it still doesn't work

* Settings are now correctly saved

* I'm getting a crash, I need to rebuild from scratch

* Settings page looks alright

* Completed work. Unit tests?

* Use ComboBox instead

* Add telemetry

* Update text
This commit is contained in:
Ivan Stošić
2021-02-25 16:23:05 +01:00
committed by GitHub
parent 889360b5e4
commit f839a408de
15 changed files with 114 additions and 21 deletions

View File

@@ -18,6 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
FancyzonesMouseSwitch = new BoolProperty();
FancyzonesMoveWindowsAcrossMonitors = new BoolProperty();
FancyzonesMoveWindowsBasedOnPosition = new BoolProperty();
FancyzonesOverlappingZonesAlgorithm = new IntProperty();
FancyzonesDisplayChangeMoveWindows = new BoolProperty();
FancyzonesZoneSetChangeMoveWindows = new BoolProperty();
FancyzonesAppLastZoneMoveWindows = new BoolProperty();
@@ -50,6 +51,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("fancyzones_moveWindowsBasedOnPosition")]
public BoolProperty FancyzonesMoveWindowsBasedOnPosition { get; set; }
[JsonPropertyName("fancyzones_overlappingZonesAlgorithm")]
public IntProperty FancyzonesOverlappingZonesAlgorithm { get; set; }
[JsonPropertyName("fancyzones_displayChange_moveWindows")]
public BoolProperty FancyzonesDisplayChangeMoveWindows { get; set; }

View File

@@ -32,6 +32,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
MoveWindowBasedOnPosition,
}
private enum OverlappingZonesAlgorithm
{
Smallest = 0,
Largest = 1,
Positional = 2,
}
public FancyZonesViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<FancyZonesSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{
// To obtain the general settings configurations of PowerToys Settings.
@@ -58,6 +65,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
_moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
_moveWindowBehaviour = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value ? MoveWindowBehaviour.MoveWindowBasedOnPosition : MoveWindowBehaviour.MoveWindowBasedOnZoneIndex;
_overlappingZonesAlgorithm = (OverlappingZonesAlgorithm)Settings.Properties.FancyzonesOverlappingZonesAlgorithm.Value;
_displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
_zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
@@ -92,6 +100,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _overrideSnapHotkeys;
private bool _moveWindowsAcrossMonitors;
private MoveWindowBehaviour _moveWindowBehaviour;
private OverlappingZonesAlgorithm _overlappingZonesAlgorithm;
private bool _displayChangemoveWindows;
private bool _zoneSetChangeMoveWindows;
private bool _appLastZoneMoveWindows;
@@ -257,6 +266,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public int OverlappingZonesAlgorithmIndex
{
get
{
return (int)_overlappingZonesAlgorithm;
}
set
{
if (value != (int)_overlappingZonesAlgorithm)
{
_overlappingZonesAlgorithm = (OverlappingZonesAlgorithm)value;
Settings.Properties.FancyzonesOverlappingZonesAlgorithm.Value = value;
NotifyPropertyChanged();
}
}
}
public bool DisplayChangeMoveWindows
{
get

View File

@@ -937,4 +937,16 @@
<data name="ColorPicker_Editor.Text" xml:space="preserve">
<value>Editor</value>
</data>
<data name="FancyZones_OverlappingZonesLargest.Content" xml:space="preserve">
<value>Activate the largest zone by area</value>
</data>
<data name="FancyZones_OverlappingZonesPositional.Content" xml:space="preserve">
<value>Split the overlapped area into multiple activation targets</value>
</data>
<data name="FancyZones_OverlappingZonesSmallest.Content" xml:space="preserve">
<value>Activate the smallest zone by area</value>
</data>
<data name="FancyZones_OverlappingZonesLabel.Text" xml:space="preserve">
<value>When multiple zones overlap:</value>
</data>
</root>

View File

@@ -19,4 +19,7 @@
<!-- MaxWidth of the content panel, similar to W10 Settings -->
<x:Double x:Key="MaxContentWidth">460</x:Double>
<!-- Maximum Width of a combo box inside the content panel -->
<x:Double x:Key="MaxComboBoxWidth">444</x:Double>
</ResourceDictionary>

View File

@@ -125,6 +125,20 @@
Margin="{StaticResource XSmallTopMargin}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
<TextBlock x:Uid="FancyZones_OverlappingZonesLabel"
Margin="{StaticResource SmallTopMargin}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled, Converter={StaticResource ModuleEnabledToForegroundConverter}}"/>
<ComboBox Name="FancyZones_OverlappingZonesComboBox"
x:Uid="FancyZones_OverlappingZonesComboBox"
SelectedIndex="{x:Bind Path=ViewModel.OverlappingZonesAlgorithmIndex, Mode=TwoWay}"
VerticalAlignment="Center"
Width="{StaticResource MaxComboBoxWidth}"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem x:Uid="FancyZones_OverlappingZonesSmallest" />
<ComboBoxItem x:Uid="FancyZones_OverlappingZonesLargest" />
<ComboBoxItem x:Uid="FancyZones_OverlappingZonesPositional" />
</ComboBox>
<TextBlock x:Uid="FancyZones_WindowBehavior_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"