Skip to content

Commit 874fca3

Browse files
authored
Added an option to disable recent tools (#1433)
1 parent 003e38b commit 874fca3

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

src/app/dev/DevToys.Blazor/BuiltInTools/Settings/Settings.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/BuiltInTools/Settings/Settings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@
224224
<data name="PasteClearsTextStateDescriptionWhenOn" xml:space="preserve">
225225
<value>Replace text when pasting</value>
226226
</data>
227+
<data name="RecentTools" xml:space="preserve">
228+
<value>Show most recent used tools</value>
229+
</data>
230+
<data name="RecentToolsDescription" xml:space="preserve">
231+
<value>Display the last 3 used tools in the menu. The change will take effect after restarting the app.</value>
232+
</data>
227233
<data name="RenderWhitespace" xml:space="preserve">
228234
<value>Render white space</value>
229235
</data>

src/app/dev/DevToys.Blazor/BuiltInTools/Settings/SettingsGuiTool.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ public UIToolView View
129129
_settingsProvider,
130130
PredefinedSettings.CheckForUpdate),
131131

132+
Setting("recenttools-setting")
133+
.Icon("FluentSystemIcons", '\uED83')
134+
.Title(Settings.RecentTools)
135+
.Description(Settings.RecentToolsDescription)
136+
.Handle(
137+
_settingsProvider,
138+
PredefinedSettings.ShowMostRecentTools),
139+
132140
SettingGroup("smart-detection-settings")
133141
.Icon("FluentSystemIcons", '\uF4D5')
134142
.Title(Settings.SmartDetection)

src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public static readonly SettingDefinition<string> RecentTool3
9494
name: nameof(RecentTool3),
9595
defaultValue: string.Empty);
9696

97+
/// <summary>
98+
/// Whether the most recent tools should be displayed.
99+
/// </summary>
100+
public static readonly SettingDefinition<bool> ShowMostRecentTools
101+
= new(
102+
name: nameof(ShowMostRecentTools),
103+
defaultValue: true);
104+
97105
/// <summary>
98106
/// Whether the app should automatically check for updates.
99107
/// </summary>

src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,26 @@ public void SetMostRecentUsedTool(GuiToolInstance guiToolInstance)
158158
/// </summary>
159159
public IEnumerable<GuiToolInstance> GetMostRecentUsedTools()
160160
{
161-
GuiToolInstance? recentTool1 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool1));
162-
GuiToolInstance? recentTool2 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool2));
163-
GuiToolInstance? recentTool3 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool3));
164-
165-
if (recentTool1 is not null)
161+
if (_settingsProvider.GetSetting(PredefinedSettings.ShowMostRecentTools))
166162
{
167-
yield return recentTool1;
168-
}
163+
GuiToolInstance? recentTool1 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool1));
164+
GuiToolInstance? recentTool2 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool2));
165+
GuiToolInstance? recentTool3 = GetToolFromInternalName(_settingsProvider.GetSetting(PredefinedSettings.RecentTool3));
169166

170-
if (recentTool2 is not null)
171-
{
172-
yield return recentTool2;
173-
}
167+
if (recentTool1 is not null)
168+
{
169+
yield return recentTool1;
170+
}
174171

175-
if (recentTool3 is not null)
176-
{
177-
yield return recentTool3;
172+
if (recentTool2 is not null)
173+
{
174+
yield return recentTool2;
175+
}
176+
177+
if (recentTool3 is not null)
178+
{
179+
yield return recentTool3;
180+
}
178181
}
179182
}
180183

0 commit comments

Comments
 (0)