mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Add keyboard shortcuts (without GUI) for switching windows in the same zone (tabs) (#13973)
Authored-by: float4 <float4-unspecified-mail>
This commit is contained in:
@@ -10,7 +10,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
public class FZConfigProperties
|
||||
{
|
||||
// in reality, this file needs to be kept in sync currently with src\modules\fancyzones\lib\Settings.h
|
||||
public static readonly HotkeySettings DefaultHotkeyValue = new HotkeySettings(true, false, false, true, 0xc0);
|
||||
public const int VkOem3 = 0xc0;
|
||||
public const int VkNext = 0x22;
|
||||
public const int VkPrior = 0x21;
|
||||
|
||||
public static readonly HotkeySettings DefaultEditorHotkeyValue = new HotkeySettings(true, false, false, true, VkOem3);
|
||||
public static readonly HotkeySettings DefaultNextTabHotkeyValue = new HotkeySettings(true, false, false, false, VkNext);
|
||||
public static readonly HotkeySettings DefaultPrevTabHotkeyValue = new HotkeySettings(true, false, false, false, VkPrior);
|
||||
|
||||
public FZConfigProperties()
|
||||
{
|
||||
@@ -32,7 +38,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
FancyzonesSpanZonesAcrossMonitors = new BoolProperty();
|
||||
FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor);
|
||||
FancyzonesHighlightOpacity = new IntProperty(50);
|
||||
FancyzonesEditorHotkey = new KeyboardKeysProperty(DefaultHotkeyValue);
|
||||
FancyzonesEditorHotkey = new KeyboardKeysProperty(DefaultEditorHotkeyValue);
|
||||
FancyzonesWindowSwitching = new BoolProperty(true);
|
||||
FancyzonesNextTabHotkey = new KeyboardKeysProperty(DefaultNextTabHotkeyValue);
|
||||
FancyzonesPrevTabHotkey = new KeyboardKeysProperty(DefaultPrevTabHotkeyValue);
|
||||
FancyzonesMakeDraggedWindowTransparent = new BoolProperty();
|
||||
FancyzonesExcludedApps = new StringProperty();
|
||||
FancyzonesInActiveColor = new StringProperty(ConfigDefaults.DefaultFancyZonesInActiveColor);
|
||||
@@ -99,6 +108,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
[JsonPropertyName("fancyzones_editor_hotkey")]
|
||||
public KeyboardKeysProperty FancyzonesEditorHotkey { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_windowSwitching")]
|
||||
public BoolProperty FancyzonesWindowSwitching { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_nextTab_hotkey")]
|
||||
public KeyboardKeysProperty FancyzonesNextTabHotkey { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_prevTab_hotkey")]
|
||||
public KeyboardKeysProperty FancyzonesPrevTabHotkey { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_excluded_apps")]
|
||||
public StringProperty FancyzonesExcludedApps { get; set; }
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
_highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
|
||||
_excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
|
||||
EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
|
||||
_windowSwitching = Settings.Properties.FancyzonesWindowSwitching.Value;
|
||||
NextTabHotkey = Settings.Properties.FancyzonesNextTabHotkey.Value;
|
||||
PrevTabHotkey = Settings.Properties.FancyzonesPrevTabHotkey.Value;
|
||||
|
||||
// set the callback functions value to hangle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
@@ -127,6 +130,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
private int _highlightOpacity;
|
||||
private string _excludedApps;
|
||||
private HotkeySettings _editorHotkey;
|
||||
private bool _windowSwitching;
|
||||
private HotkeySettings _nextTabHotkey;
|
||||
private HotkeySettings _prevTabHotkey;
|
||||
private string _zoneInActiveColor;
|
||||
private string _zoneBorderColor;
|
||||
private string _zoneHighlightColor;
|
||||
@@ -152,6 +158,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
|
||||
OnPropertyChanged(nameof(QuickSwitchEnabled));
|
||||
OnPropertyChanged(nameof(WindowSwitchingCategoryEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,6 +179,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool WindowSwitchingCategoryEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isEnabled && _windowSwitching;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShiftDrag
|
||||
{
|
||||
get
|
||||
@@ -604,7 +619,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
if (value == null || value.IsEmpty())
|
||||
{
|
||||
_editorHotkey = FZConfigProperties.DefaultHotkeyValue;
|
||||
_editorHotkey = FZConfigProperties.DefaultEditorHotkeyValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -617,6 +632,78 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool WindowSwitching
|
||||
{
|
||||
get
|
||||
{
|
||||
return _windowSwitching;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _windowSwitching)
|
||||
{
|
||||
_windowSwitching = value;
|
||||
|
||||
Settings.Properties.FancyzonesWindowSwitching.Value = _windowSwitching;
|
||||
NotifyPropertyChanged();
|
||||
OnPropertyChanged(nameof(WindowSwitchingCategoryEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HotkeySettings NextTabHotkey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nextTabHotkey;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _nextTabHotkey)
|
||||
{
|
||||
if (value == null || value.IsEmpty())
|
||||
{
|
||||
_nextTabHotkey = FZConfigProperties.DefaultNextTabHotkeyValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nextTabHotkey = value;
|
||||
}
|
||||
|
||||
Settings.Properties.FancyzonesNextTabHotkey.Value = _nextTabHotkey;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HotkeySettings PrevTabHotkey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _prevTabHotkey;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _prevTabHotkey)
|
||||
{
|
||||
if (value == null || value.IsEmpty())
|
||||
{
|
||||
_prevTabHotkey = FZConfigProperties.DefaultPrevTabHotkeyValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_prevTabHotkey = value;
|
||||
}
|
||||
|
||||
Settings.Properties.FancyzonesPrevTabHotkey.Value = _prevTabHotkey;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ExcludedApps
|
||||
{
|
||||
get
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace ViewModelTests
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesBorderColor.Value, viewModel.ZoneBorderColor);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesDisplayChangeMoveWindows.Value, viewModel.DisplayChangeMoveWindows);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesEditorHotkey.Value.ToString(), viewModel.EditorHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesWindowSwitching.Value, viewModel.WindowSwitching);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesNextTabHotkey.Value.ToString(), viewModel.NextTabHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesPrevTabHotkey.Value.ToString(), viewModel.PrevTabHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesExcludedApps.Value, viewModel.ExcludedApps);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesHighlightOpacity.Value, viewModel.HighlightOpacity);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesInActiveColor.Value, viewModel.ZoneInActiveColor);
|
||||
|
||||
@@ -449,6 +449,24 @@
|
||||
<data name="FancyZones_HotkeyEditorControl.Header" xml:space="preserve">
|
||||
<value>Open layout editor</value>
|
||||
<comment>Shortcut to launch the FancyZones layout editor application</comment>
|
||||
</data>
|
||||
<data name="FancyZones_WindowSwitching_GroupSettings.Header" xml:space="preserve">
|
||||
<value>Window switching</value>
|
||||
</data>
|
||||
<data name="FancyZones_WindowSwitching_GroupSettings.Description" xml:space="preserve">
|
||||
<value>Shortcuts for switching between windows in the current zone</value>
|
||||
</data>
|
||||
<data name="FancyZones_HotkeyNextTabControl.Header" xml:space="preserve">
|
||||
<value>Next window</value>
|
||||
</data>
|
||||
<data name="FancyZones_HotkeyNextTabControl.Description" xml:space="preserve">
|
||||
<value>Shortcut for switching to the next window in the current zone</value>
|
||||
</data>
|
||||
<data name="FancyZones_HotkeyPrevTabControl.Header" xml:space="preserve">
|
||||
<value>Previous window</value>
|
||||
</data>
|
||||
<data name="FancyZones_HotkeyPrevTabControl.Description" xml:space="preserve">
|
||||
<value>Shortcut for switching to the previous window in the current zone</value>
|
||||
</data>
|
||||
<data name="SettingsPage_SetShortcut.AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Shortcut setting</value>
|
||||
|
||||
@@ -148,6 +148,31 @@
|
||||
</controls:SettingExpander.Content>
|
||||
</controls:SettingExpander>
|
||||
|
||||
<controls:SettingExpander IsExpanded="True">
|
||||
<controls:SettingExpander.Header>
|
||||
<controls:Setting x:Uid="FancyZones_WindowSwitching_GroupSettings" Icon="⎘" Style="{StaticResource ExpanderHeaderSettingStyle}">
|
||||
<controls:Setting.ActionContent>
|
||||
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.WindowSwitching}"/>
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
</controls:SettingExpander.Header>
|
||||
<controls:SettingExpander.Content>
|
||||
<StackPanel>
|
||||
<controls:Setting x:Uid="FancyZones_HotkeyNextTabControl" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.WindowSwitchingCategoryEnabled}" Icon="⎘" Style="{StaticResource ExpanderContentSettingStyle}">
|
||||
<controls:Setting.ActionContent>
|
||||
<controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.NextTabHotkey, Mode=TwoWay}" MinWidth="{StaticResource SettingActionControlMinWidth}"/>
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
<Rectangle Style="{StaticResource ExpanderSeparatorStyle}" />
|
||||
<controls:Setting x:Uid="FancyZones_HotkeyPrevTabControl" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.WindowSwitchingCategoryEnabled}" Icon="⎗" Style="{StaticResource ExpanderContentSettingStyle}">
|
||||
<controls:Setting.ActionContent>
|
||||
<controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.PrevTabHotkey, Mode=TwoWay}" MinWidth="{StaticResource SettingActionControlMinWidth}"/>
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
</StackPanel>
|
||||
</controls:SettingExpander.Content>
|
||||
</controls:SettingExpander>
|
||||
|
||||
<controls:SettingExpander IsExpanded="True">
|
||||
<controls:SettingExpander.Header>
|
||||
<controls:Setting x:Uid="FancyZones_OverrideSnapHotkeys" Icon="" Style="{StaticResource ExpanderHeaderSettingStyle}">
|
||||
|
||||
Reference in New Issue
Block a user