[FZ Settings] replaced checkbox with radiobuttons (#9438)

This commit is contained in:
Seraphima Zykova
2021-02-03 14:12:53 +03:00
committed by GitHub
parent 4cffc825c8
commit 32d164a786
3 changed files with 48 additions and 9 deletions

View File

@@ -26,6 +26,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private string settingsConfigFileFolder = string.Empty; private string settingsConfigFileFolder = string.Empty;
private enum MoveWindowBehaviour
{
MoveWindowBasedOnZoneIndex = 0,
MoveWindowBasedOnPosition,
}
public FancyZonesViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<FancyZonesSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") public FancyZonesViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<FancyZonesSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{ {
// To obtain the general settings configurations of PowerToys Settings. // To obtain the general settings configurations of PowerToys Settings.
@@ -51,7 +57,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value;
_overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
_moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
_moveWindowsBasedOnPosition = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value; _moveWindowBehaviour = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value ? MoveWindowBehaviour.MoveWindowBasedOnPosition : MoveWindowBehaviour.MoveWindowBasedOnZoneIndex;
_displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
_zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
@@ -85,7 +91,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _mouseSwitch; private bool _mouseSwitch;
private bool _overrideSnapHotkeys; private bool _overrideSnapHotkeys;
private bool _moveWindowsAcrossMonitors; private bool _moveWindowsAcrossMonitors;
private bool _moveWindowsBasedOnPosition; private MoveWindowBehaviour _moveWindowBehaviour;
private bool _displayChangemoveWindows; private bool _displayChangemoveWindows;
private bool _zoneSetChangeMoveWindows; private bool _zoneSetChangeMoveWindows;
private bool _appLastZoneMoveWindows; private bool _appLastZoneMoveWindows;
@@ -217,20 +223,40 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{ {
get get
{ {
return _moveWindowsBasedOnPosition; return _moveWindowBehaviour == MoveWindowBehaviour.MoveWindowBasedOnPosition;
} }
set set
{ {
if (value != _moveWindowsBasedOnPosition) var settingsValue = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value;
if (value != settingsValue)
{ {
_moveWindowsBasedOnPosition = value; _moveWindowBehaviour = value ? MoveWindowBehaviour.MoveWindowBasedOnPosition : MoveWindowBehaviour.MoveWindowBasedOnZoneIndex;
Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = value; Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
} }
public bool MoveWindowsBasedOnZoneIndex
{
get
{
return _moveWindowBehaviour == MoveWindowBehaviour.MoveWindowBasedOnZoneIndex;
}
set
{
var settingsValue = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value;
if (value == settingsValue)
{
_moveWindowBehaviour = value ? MoveWindowBehaviour.MoveWindowBasedOnZoneIndex : MoveWindowBehaviour.MoveWindowBasedOnPosition;
Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = !value;
NotifyPropertyChanged();
}
}
}
public bool DisplayChangeMoveWindows public bool DisplayChangeMoveWindows
{ {
get get

View File

@@ -928,6 +928,12 @@
<value>https://aka.ms/PowerToysOverview_ShortcutGuide</value> <value>https://aka.ms/PowerToysOverview_ShortcutGuide</value>
<comment>URL. Do not loc</comment> <comment>URL. Do not loc</comment>
</data> </data>
<data name="FancyZones_MoveWindowBasedOnRelativePosition.Content" xml:space="preserve">
<value>Win + Up/Down/Left/Right to move windows based on relative position</value>
</data>
<data name="FancyZones_MoveWindowLeftRightBasedOnZoneIndex.Content" xml:space="preserve">
<value>Win + Left/Right to move windows based on zone index</value>
</data>
<data name="ColorPicker_Editor.Text" xml:space="preserve"> <data name="ColorPicker_Editor.Text" xml:space="preserve">
<value>Editor</value> <value>Editor</value>
</data> </data>

View File

@@ -135,10 +135,17 @@
Margin="{StaticResource XSmallTopMargin}" Margin="{StaticResource XSmallTopMargin}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/> IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>
<CheckBox x:Uid="FancyZones_MoveWindowsBasedOnPositionCheckBoxControl" <RadioButton x:Uid="FancyZones_MoveWindowLeftRightBasedOnZoneIndex"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsBasedOnPosition}" GroupName="FancyZones_MoveWindowGroup"
Margin="24,8,0,0" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsBasedOnZoneIndex}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SnapHotkeysCategoryEnabled}"/> Margin="24,8,0,0"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SnapHotkeysCategoryEnabled}"/>
<RadioButton x:Uid="FancyZones_MoveWindowBasedOnRelativePosition"
GroupName="FancyZones_MoveWindowGroup"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsBasedOnPosition}"
Margin="24,8,0,0"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SnapHotkeysCategoryEnabled}"/>
<CheckBox x:Uid="FancyZones_MoveWindowsAcrossAllMonitorsCheckBoxControl" <CheckBox x:Uid="FancyZones_MoveWindowsAcrossAllMonitorsCheckBoxControl"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsAcrossMonitors}" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MoveWindowsAcrossMonitors}"