Merge pull request #4963 from OmrSi/add-clear-recent-files

Add `Clear` option to recent files menu
This commit is contained in:
Nikolaj Olsson 2021-04-08 16:31:40 +02:00 committed by GitHub
commit fce3f004c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3791,6 +3791,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
{
@ -3835,12 +3848,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);
}
}
}
}
@ -7731,9 +7752,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();