From 33aa4d6ef2ea031429deaee77b0a631c9e53fae1 Mon Sep 17 00:00:00 2001 From: OmrSi Date: Tue, 6 Apr 2021 15:29:48 +0300 Subject: [PATCH] Add `Clear` option to recent files menu --- src/ui/Forms/Main.cs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index bcb3eea21..186be0531 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -3790,6 +3790,19 @@ namespace Nikse.SubtitleEdit.Forms reopenToolStripMenuItem.DropDownItems.AddRange(dropDownItems.ToArray()); UiUtil.FixFonts(reopenToolStripMenuItem); + + var tss = new ToolStripSeparator(); + UiUtil.FixFonts(tss); + reopenToolStripMenuItem.DropDownItems.Add(tss); + + var clearHistoryMenuItem = new ToolStripMenuItem(LanguageSettings.Current.DvdSubRip.Clear); + clearHistoryMenuItem.Click += (sender, args) => + { + Configuration.Settings.RecentFiles.Files.Clear(); + UpdateRecentFilesUI(); + }; + UiUtil.FixFonts(clearHistoryMenuItem); + reopenToolStripMenuItem.DropDownItems.Add(clearHistoryMenuItem); } else { @@ -3834,12 +3847,20 @@ namespace Nikse.SubtitleEdit.Forms { Configuration.Settings.RecentFiles.Files = Configuration.Settings.RecentFiles.Files .Where(p => !notExistingFiles.Contains(p.FileName)).ToList(); - for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--) + if (Configuration.Settings.RecentFiles.Files.Count == 0) { - ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index]; - if (notExistingFiles.Contains((string)item.Tag)) + reopenToolStripMenuItem.DropDownItems.Clear(); + reopenToolStripMenuItem.Visible = false; + } + else + { + for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--) { - reopenToolStripMenuItem.DropDownItems.RemoveAt(index); + ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index]; + if (notExistingFiles.Contains((string)item.Tag)) + { + reopenToolStripMenuItem.DropDownItems.RemoveAt(index); + } } } } @@ -7699,9 +7720,11 @@ namespace Nikse.SubtitleEdit.Forms cm.Items.Add(tss); // End time - var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(LanguageSettings.Current.General.EndTime); - contextMenuStripLvHeaderEndTimeToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime; + var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(LanguageSettings.Current.General.EndTime) + { + CheckOnClick = true, + Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime + }; contextMenuStripLvHeaderEndTimeToolStripMenuItem.Click += (sender2, e2) => { SubtitleListview1.BeginUpdate();