Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FZ Settings] Options for layout quick swap: on/off keyboard hook #10265

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ finalizer
findstr
FIXEDFILEINFO
FLASHZONES
FLASHZONESONQUICKSWITCH
Fle
fluentui
flyout
Expand Down Expand Up @@ -1732,6 +1733,7 @@ QUERYENDSESSION
queryfocus
QUERYOPEN
QUEUESYNC
QUICKLAYOUTSWITCH
qwertyuiopasdfghjklzxcvbnm
qword
qwrtyuiopsghjklzxvnm
Expand Down
6 changes: 6 additions & 0 deletions src/modules/fancyzones/lib/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,10 @@
<value>Failed to save the FancyZones settings. Please retry again later, if the problem persists report the bug to</value>
<comment>"Report bug to" will have a URL after. FancyZone is a product name, keep as is.</comment>
</data>
<data name="Setting_Description_QuickLayoutSwitch" xml:space="preserve">
<value>Enable quick layout switch</value>
</data>
<data name="Setting_Description_FlashZonesOnQuickSwitch" xml:space="preserve">
<value>Flash zones when switching layout</value>
</data>
</root>
6 changes: 5 additions & 1 deletion src/modules/fancyzones/lib/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace NonLocalizable
const wchar_t AppLastZoneMoveWindowsID[] = L"fancyzones_appLastZone_moveWindows";
const wchar_t OpenWindowOnActiveMonitorID[] = L"fancyzones_openWindowOnActiveMonitor";
const wchar_t RestoreSizeID[] = L"fancyzones_restoreSize";
const wchar_t QuickLayoutSwitch[] = L"fancyzones_quickLayoutSwitch";
const wchar_t FlashZonesOnQuickSwitch[] = L"fancyzones_flashZonesOnQuickSwitch";
const wchar_t UseCursorPosEditorStartupScreenID[] = L"use_cursorpos_editor_startupscreen";
const wchar_t ShowOnAllMonitorsID[] = L"fancyzones_show_on_all_monitors";
const wchar_t SpanZonesAcrossMonitorsID[] = L"fancyzones_span_zones_across_monitors";
Expand Down Expand Up @@ -80,7 +82,7 @@ struct FancyZonesSettings : winrt::implements<FancyZonesSettings, IFancyZonesSet
PCWSTR name;
bool* value;
int resourceId;
} m_configBools[14] = {
} m_configBools[16] = {
{ NonLocalizable::ShiftDragID, &m_settings.shiftDrag, IDS_SETTING_DESCRIPTION_SHIFTDRAG },
{ NonLocalizable::MouseSwitchID, &m_settings.mouseSwitch, IDS_SETTING_DESCRIPTION_MOUSESWITCH },
{ NonLocalizable::OverrideSnapHotKeysID, &m_settings.overrideSnapHotkeys, IDS_SETTING_DESCRIPTION_OVERRIDE_SNAP_HOTKEYS },
Expand All @@ -91,6 +93,8 @@ struct FancyZonesSettings : winrt::implements<FancyZonesSettings, IFancyZonesSet
{ NonLocalizable::AppLastZoneMoveWindowsID, &m_settings.appLastZone_moveWindows, IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS },
{ NonLocalizable::OpenWindowOnActiveMonitorID, &m_settings.openWindowOnActiveMonitor, IDS_SETTING_DESCRIPTION_OPEN_WINDOW_ON_ACTIVE_MONITOR },
{ NonLocalizable::RestoreSizeID, &m_settings.restoreSize, IDS_SETTING_DESCRIPTION_RESTORESIZE },
{ NonLocalizable::QuickLayoutSwitch, &m_settings.quickLayoutSwitch, IDS_SETTING_DESCRIPTION_QUICKLAYOUTSWITCH },
{ NonLocalizable::FlashZonesOnQuickSwitch, &m_settings.flashZonesOnQuickSwitch, IDS_SETTING_DESCRIPTION_FLASHZONESONQUICKSWITCH },
{ NonLocalizable::UseCursorPosEditorStartupScreenID, &m_settings.use_cursorpos_editor_startupscreen, IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN },
{ NonLocalizable::ShowOnAllMonitorsID, &m_settings.showZonesOnAllMonitors, IDS_SETTING_DESCRIPTION_SHOW_FANCY_ZONES_ON_ALL_MONITORS },
{ NonLocalizable::SpanZonesAcrossMonitorsID, &m_settings.spanZonesAcrossMonitors, IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS },
Expand Down
2 changes: 2 additions & 0 deletions src/modules/fancyzones/lib/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct Settings
bool appLastZone_moveWindows = false;
bool openWindowOnActiveMonitor = false;
bool restoreSize = false;
bool quickLayoutSwitch = true;
bool flashZonesOnQuickSwitch = true;
bool use_cursorpos_editor_startupscreen = true;
bool showZonesOnAllMonitors = false;
bool spanZonesAcrossMonitors = false;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/fancyzones/tests/UnitTests/FancyZones.Spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ namespace FancyZonesUnitTests
ptSettings.add_bool_toggle(L"fancyzones_zoneSetChange_moveWindows", IDS_SETTING_DESCRIPTION_ZONESETCHANGE_MOVEWINDOWS, settings.zoneSetChange_moveWindows);
ptSettings.add_bool_toggle(L"fancyzones_appLastZone_moveWindows", IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS, settings.appLastZone_moveWindows);
ptSettings.add_bool_toggle(L"fancyzones_restoreSize", IDS_SETTING_DESCRIPTION_RESTORESIZE, settings.restoreSize);
ptSettings.add_bool_toggle(L"fancyzones_quickLayoutSwitch", IDS_SETTING_DESCRIPTION_QUICKLAYOUTSWITCH, settings.quickLayoutSwitch);
ptSettings.add_bool_toggle(L"fancyzones_flashZonesOnQuickSwitch", IDS_SETTING_DESCRIPTION_FLASHZONESONQUICKSWITCH, settings.flashZonesOnQuickSwitch);
ptSettings.add_bool_toggle(L"use_cursorpos_editor_startupscreen", IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN, settings.use_cursorpos_editor_startupscreen);
ptSettings.add_bool_toggle(L"fancyzones_show_on_all_monitors", IDS_SETTING_DESCRIPTION_SHOW_FANCY_ZONES_ON_ALL_MONITORS, settings.showZonesOnAllMonitors);
ptSettings.add_bool_toggle(L"fancyzones_multi_monitor_mode", IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS, settings.spanZonesAcrossMonitors);
Expand Down Expand Up @@ -303,6 +305,8 @@ namespace FancyZonesUnitTests
ptSettings.add_bool_toggle(L"fancyzones_zoneSetChange_moveWindows", IDS_SETTING_DESCRIPTION_ZONESETCHANGE_MOVEWINDOWS, settings.zoneSetChange_moveWindows);
ptSettings.add_bool_toggle(L"fancyzones_appLastZone_moveWindows", IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS, settings.appLastZone_moveWindows);
ptSettings.add_bool_toggle(L"fancyzones_restoreSize", IDS_SETTING_DESCRIPTION_RESTORESIZE, settings.restoreSize);
ptSettings.add_bool_toggle(L"fancyzones_quickLayoutSwitch", IDS_SETTING_DESCRIPTION_QUICKLAYOUTSWITCH, settings.quickLayoutSwitch);
ptSettings.add_bool_toggle(L"fancyzones_flashZonesOnQuickSwitch", IDS_SETTING_DESCRIPTION_FLASHZONESONQUICKSWITCH, settings.flashZonesOnQuickSwitch);
ptSettings.add_bool_toggle(L"use_cursorpos_editor_startupscreen", IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN, settings.use_cursorpos_editor_startupscreen);
ptSettings.add_bool_toggle(L"fancyzones_show_on_all_monitors", IDS_SETTING_DESCRIPTION_SHOW_FANCY_ZONES_ON_ALL_MONITORS, settings.showZonesOnAllMonitors);
ptSettings.add_bool_toggle(L"fancyzones_multi_monitor_mode", IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS, settings.spanZonesAcrossMonitors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public static class ConfigDefaults
// Fancy Zones Default Flags.
public static readonly bool DefaultFancyzonesShiftDrag = true;
public static readonly bool DefaultUseCursorposEditorStartupscreen = true;
public static readonly bool DefaultFancyzonesQuickLayoutSwitch = true;
public static readonly bool DefaultFancyzonesFlashZonesOnQuickSwitch = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public FZConfigProperties()
FancyzonesAppLastZoneMoveWindows = new BoolProperty();
FancyzonesOpenWindowOnActiveMonitor = new BoolProperty();
FancyzonesRestoreSize = new BoolProperty();
FancyzonesQuickLayoutSwitch = new BoolProperty(ConfigDefaults.DefaultFancyzonesQuickLayoutSwitch);
FancyzonesFlashZonesOnQuickSwitch = new BoolProperty(ConfigDefaults.DefaultFancyzonesFlashZonesOnQuickSwitch);
UseCursorposEditorStartupscreen = new BoolProperty(ConfigDefaults.DefaultUseCursorposEditorStartupscreen);
FancyzonesShowOnAllMonitors = new BoolProperty();
FancyzonesSpanZonesAcrossMonitors = new BoolProperty();
Expand Down Expand Up @@ -69,6 +71,12 @@ public FZConfigProperties()
[JsonPropertyName("fancyzones_restoreSize")]
public BoolProperty FancyzonesRestoreSize { get; set; }

[JsonPropertyName("fancyzones_quickLayoutSwitch")]
public BoolProperty FancyzonesQuickLayoutSwitch { get; set; }

[JsonPropertyName("fancyzones_flashZonesOnQuickSwitch")]
public BoolProperty FancyzonesFlashZonesOnQuickSwitch { get; set; }

[JsonPropertyName("use_cursorpos_editor_startupscreen")]
public BoolProperty UseCursorposEditorStartupscreen { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public FancyZonesViewModel(ISettingsRepository<GeneralSettings> settingsReposito
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
_openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
_restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
_quickLayoutSwitch = Settings.Properties.FancyzonesQuickLayoutSwitch.Value;
_flashZonesOnQuickLayoutSwitch = Settings.Properties.FancyzonesFlashZonesOnQuickSwitch.Value;
_useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
_showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
_spanZonesAcrossMonitors = Settings.Properties.FancyzonesSpanZonesAcrossMonitors.Value;
Expand Down Expand Up @@ -107,6 +109,8 @@ public FancyZonesViewModel(ISettingsRepository<GeneralSettings> settingsReposito
private bool _openWindowOnActiveMonitor;
private bool _spanZonesAcrossMonitors;
private bool _restoreSize;
private bool _quickLayoutSwitch;
private bool _flashZonesOnQuickLayoutSwitch;
private bool _useCursorPosEditorStartupScreen;
private bool _showOnAllMonitors;
private bool _makeDraggedWindowTransparent;
Expand Down Expand Up @@ -138,6 +142,7 @@ public bool IsEnabled
SendConfigMSG(snd.ToString());
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
OnPropertyChanged(nameof(QuickSwitchEnabled));
}
}
}
Expand All @@ -150,6 +155,14 @@ public bool SnapHotkeysCategoryEnabled
}
}

public bool QuickSwitchEnabled
{
get
{
return _isEnabled && _quickLayoutSwitch;
}
}

public bool ShiftDrag
{
get
Expand Down Expand Up @@ -374,6 +387,43 @@ public bool RestoreSize
}
}

public bool QuickLayoutSwitch
{
get
{
return _quickLayoutSwitch;
}

set
{
if (value != _quickLayoutSwitch)
{
_quickLayoutSwitch = value;
Settings.Properties.FancyzonesQuickLayoutSwitch.Value = value;
NotifyPropertyChanged();
OnPropertyChanged(nameof(QuickSwitchEnabled));
}
}
}

public bool FlashZonesOnQuickSwitch
{
get
{
return _flashZonesOnQuickLayoutSwitch;
}

set
{
if (value != _flashZonesOnQuickLayoutSwitch)
{
_flashZonesOnQuickLayoutSwitch = value;
Settings.Properties.FancyzonesFlashZonesOnQuickSwitch.Value = value;
NotifyPropertyChanged();
}
}
}

public bool UseCursorPosEditorStartupScreen
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1167,4 +1167,13 @@ Win + Shift + O to toggle your video</value>
<data name="Run_Radio_Position_Primary_Monitor.Content" xml:space="preserve">
<value>Primary monitor</value>
</data>
</root>
<data name="FancyZones_FlashZonesOnQuickSwitch.Content" xml:space="preserve">
<value>Flash zones when switching layout</value>
</data>
<data name="FancyZones_QuickLayoutSwitch.Content" xml:space="preserve">
<value>Enable quick layout switch</value>
</data>
<data name="FancyZones_QuickLayoutSwitch_GroupSettings.Text" xml:space="preserve">
<value>Quick layout switch</value>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<value>Quick layout switch</value>
<value>Layout features</value>

Suggest the text change for better flexibility on new setting in the feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htcfreek
right now that section is specific for the quick layout switch, we should keep the description as it is.
If in the future the section will be expanded, it will be renamed.

</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>


<TextBlock x:Uid="FancyZones_QuickLayoutSwitch_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled, Converter={StaticResource ModuleEnabledToForegroundConverter}}"/>

<CheckBox x:Uid="FancyZones_QuickLayoutSwitch"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.QuickLayoutSwitch}"
Margin="{StaticResource XSmallTopMargin}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/>

<CheckBox x:Uid="FancyZones_FlashZonesOnQuickSwitch"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.FlashZonesOnQuickSwitch}"
Margin="24,8,0,0"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.QuickSwitchEnabled}"/>

<TextBlock x:Uid="Appearance_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled, Converter={StaticResource ModuleEnabledToForegroundConverter}}"/>
Expand Down