Skip to content

Commit

Permalink
Added an option to disable recent tools (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
veler authored Oct 28, 2024
1 parent 003e38b commit 874fca3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@
<data name="PasteClearsTextStateDescriptionWhenOn" xml:space="preserve">
<value>Replace text when pasting</value>
</data>
<data name="RecentTools" xml:space="preserve">
<value>Show most recent used tools</value>
</data>
<data name="RecentToolsDescription" xml:space="preserve">
<value>Display the last 3 used tools in the menu. The change will take effect after restarting the app.</value>
</data>
<data name="RenderWhitespace" xml:space="preserve">
<value>Render white space</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public UIToolView View
_settingsProvider,
PredefinedSettings.CheckForUpdate),

Setting("recenttools-setting")
.Icon("FluentSystemIcons", '\uED83')
.Title(Settings.RecentTools)
.Description(Settings.RecentToolsDescription)
.Handle(
_settingsProvider,
PredefinedSettings.ShowMostRecentTools),

SettingGroup("smart-detection-settings")
.Icon("FluentSystemIcons", '\uF4D5')
.Title(Settings.SmartDetection)
Expand Down
8 changes: 8 additions & 0 deletions src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public static readonly SettingDefinition<string> RecentTool3
name: nameof(RecentTool3),
defaultValue: string.Empty);

/// <summary>
/// Whether the most recent tools should be displayed.
/// </summary>
public static readonly SettingDefinition<bool> ShowMostRecentTools
= new(
name: nameof(ShowMostRecentTools),
defaultValue: true);

/// <summary>
/// Whether the app should automatically check for updates.
/// </summary>
Expand Down
31 changes: 17 additions & 14 deletions src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,26 @@ public void SetMostRecentUsedTool(GuiToolInstance guiToolInstance)
/// </summary>
public IEnumerable<GuiToolInstance> GetMostRecentUsedTools()
{
GuiToolInstance? recentTool1 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool1));
GuiToolInstance? recentTool2 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool2));
GuiToolInstance? recentTool3 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool3));

if (recentTool1 is not null)
if (_settingsProvider.GetSetting(PredefinedSettings.ShowMostRecentTools))
{
yield return recentTool1;
}
GuiToolInstance? recentTool1 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool1));
GuiToolInstance? recentTool2 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool2));
GuiToolInstance? recentTool3 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool3));

if (recentTool2 is not null)
{
yield return recentTool2;
}
if (recentTool1 is not null)
{
yield return recentTool1;
}

if (recentTool3 is not null)
{
yield return recentTool3;
if (recentTool2 is not null)
{
yield return recentTool2;
}

if (recentTool3 is not null)
{
yield return recentTool3;
}
}
}

Expand Down

0 comments on commit 874fca3

Please sign in to comment.