Remove "video output" from settings + use listview for name list

(mpv video output should just be blank default - advanced users can edit settings.xml)
This commit is contained in:
Nikolaj Olsson 2020-12-27 20:14:21 +01:00
parent 4f6eeeabab
commit 97d27faf04
8 changed files with 1446 additions and 1435 deletions

View File

@ -2333,7 +2333,6 @@ Continue?</RestoreDefaultSettingsMsg>
<UseXAsNewGap>Use "{0}" milliseconds as new minimum gap?</UseXAsNewGap>
</Settings>
<SettingsMpv>
<Title>Settings for mpv</Title>
<DownloadMpv>Download mpv lib</DownloadMpv>
<DownloadMpvFailed>Unable to download mpv - please re-try later!</DownloadMpvFailed>
<DownloadMpvOk>The mpv lib was downloaded and is ready for use.</DownloadMpvOk>

View File

@ -2641,7 +2641,6 @@ can edit in same subtitle file (collaboration)",
SettingsMpv = new LanguageStructure.SettingsMpv
{
Title = "Settings for mpv",
DownloadMpv = "Download mpv lib",
DownloadMpvFailed = "Unable to download mpv - please re-try later!",
DownloadMpvOk = "The mpv lib was downloaded and is ready for use.",

View File

@ -6403,9 +6403,6 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/UseXAsNewGap":
language.Settings.UseXAsNewGap = reader.Value;
break;
case "SettingsMpv/Title":
language.SettingsMpv.Title = reader.Value;
break;
case "SettingsMpv/DownloadMpv":
language.SettingsMpv.DownloadMpv = reader.Value;
break;

View File

@ -2498,7 +2498,6 @@
public class SettingsMpv
{
public string Title { get; set; }
public string DownloadMpv { get; set; }
public string DownloadMpvFailed { get; set; }
public string DownloadMpvOk { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
private double _ssaFontSize;
private int _ssaFontColor;
private string _listBoxSearchString = string.Empty;
private DateTime _listBoxSearchStringLastUsed = DateTime.Now;
private DateTime _listBoxSearchStringLastUsed = DateTime.UtcNow;
private List<string> _wordListNames = new List<string>();
private List<string> _userWordList = new List<string>();
private OcrFixReplaceList _ocrFixReplaceList;
@ -879,7 +879,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
float fontSize = comboBoxToolsMusicSymbol.Font.Size;
const string unicodeFontName = Utilities.WinXP2KUnicodeFontName;
listBoxNames.Font = new Font(unicodeFontName, fontSize);
listViewNames.Font = new Font(unicodeFontName, fontSize);
listBoxUserWordLists.Font = new Font(unicodeFontName, fontSize);
listBoxOcrFixList.Font = new Font(unicodeFontName, fontSize);
comboBoxToolsMusicSymbol.Font = new Font(unicodeFontName, fontSize);
@ -2075,7 +2075,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
buttonAddUserWord.Enabled = false;
buttonRemoveOcrFix.Enabled = false;
buttonAddOcrFix.Enabled = false;
listBoxNames.Items.Clear();
listViewNames.Items.Clear();
listBoxUserWordLists.Items.Clear();
listBoxOcrFixList.Items.Clear();
if (comboBoxWordListLanguage.Items.Count > 0 && comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage)
@ -2145,10 +2145,15 @@ namespace Nikse.SubtitleEdit.Forms.Options
var uiContext = TaskScheduler.FromCurrentSynchronizationContext();
task.ContinueWith(originalTask =>
{
listBoxNames.BeginUpdate();
listBoxNames.Items.Clear();
listBoxNames.Items.AddRange(originalTask.Result.ToArray<object>());
listBoxNames.EndUpdate();
listViewNames.BeginUpdate();
listViewNames.Items.Clear();
var list = new List<ListViewItem>();
foreach (var item in originalTask.Result)
{
list.Add(new ListViewItem(item));
}
listViewNames.Items.AddRange(list.ToArray());
listViewNames.EndUpdate();
}, uiContext);
}
}
@ -2183,18 +2188,19 @@ namespace Nikse.SubtitleEdit.Forms.Options
labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text);
textBoxNameEtc.Text = string.Empty;
textBoxNameEtc.Focus();
for (int i = 0; i < listBoxNames.Items.Count; i++)
for (int i = 0; i < listViewNames.Items.Count; i++)
{
if (listBoxNames.Items[i].ToString() == text)
if (listViewNames.Items[i].ToString() == text)
{
listBoxNames.SelectedIndex = i;
listViewNames.Items[i].Selected = true;
listViewNames.Items[i].Focused = true;
int top = i - 5;
if (top < 0)
{
top = 0;
}
listBoxNames.TopIndex = top;
listViewNames.EnsureVisible(top);
break;
}
}
@ -2207,20 +2213,20 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void ListBoxNamesSelectedIndexChanged(object sender, EventArgs e)
{
buttonRemoveNameEtc.Enabled = listBoxNames.SelectedIndex >= 0;
buttonRemoveNameEtc.Enabled = listViewNames.SelectedItems.Count >= 1;
}
private void ButtonRemoveNameEtcClick(object sender, EventArgs e)
{
if (listBoxNames.SelectedIndices.Count == 0)
if (listViewNames.SelectedItems.Count == 0)
{
return;
}
string language = GetCurrentWordListLanguage();
int index = listBoxNames.SelectedIndex;
string text = listBoxNames.Items[index].ToString();
int itemsToRemoveCount = listBoxNames.SelectedIndices.Count;
int index = listViewNames.SelectedItems[0].Index;
string text = listViewNames.Items[index].Text;
int itemsToRemoveCount = listViewNames.SelectedIndices.Count;
if (!string.IsNullOrEmpty(language) && index >= 0)
{
DialogResult result;
@ -2237,29 +2243,29 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
int removeCount = 0;
var namesList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);
for (int idx = listBoxNames.SelectedIndices.Count - 1; idx >= 0; idx--)
for (int idx = listViewNames.SelectedIndices.Count - 1; idx >= 0; idx--)
{
index = listBoxNames.SelectedIndices[idx];
text = listBoxNames.Items[index].ToString();
index = listViewNames.SelectedIndices[idx];
text = listViewNames.Items[index].Text;
namesList.Remove(text);
removeCount++;
listBoxNames.Items.RemoveAt(index);
listViewNames.Items.RemoveAt(index);
}
if (removeCount > 0)
{
LoadNames(language, true); // reload
if (index < listBoxNames.Items.Count)
if (index < listViewNames.Items.Count)
{
listBoxNames.SelectedIndex = index;
listViewNames.Items[index].Selected = true;
}
else if (listBoxNames.Items.Count > 0)
else if (listViewNames.Items.Count > 0)
{
listBoxNames.SelectedIndex = index - 1;
listViewNames.Items[index - 1].Selected = true;
}
listBoxNames.Focus();
listViewNames.Focus();
buttonRemoveNameEtc.Enabled = false;
return;
@ -2621,7 +2627,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
}
if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 <
TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds)
TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalMilliseconds)
{
_listBoxSearchString = string.Empty;
}
@ -2638,7 +2644,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
_listBoxSearchString += e.KeyCode.ToString();
}
_listBoxSearchStringLastUsed = DateTime.Now;
_listBoxSearchStringLastUsed = DateTime.UtcNow;
FindAndSelectListBoxItem(sender as ListBox);
e.SuppressKeyPress = true;
}
@ -2657,6 +2663,22 @@ namespace Nikse.SubtitleEdit.Forms.Options
}
}
private void FindAndSelectListViewItem(ListView listView)
{
listView.SelectedItems.Clear();
int i = 0;
foreach (ListViewItem s in listView.Items)
{
if (s.Text.StartsWith(_listBoxSearchString, StringComparison.OrdinalIgnoreCase))
{
listView.Items[i].Selected = true;
listView.EnsureVisible(i);
break;
}
i++;
}
}
private void ListBoxSearchReset(object sender, EventArgs e)
{
_listBoxSearchString = string.Empty;
@ -3181,7 +3203,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void buttonMpvSettings_Click(object sender, EventArgs e)
{
using (var form = new SettingsMpv(LibMpvDynamic.IsInstalled))
using (var form = new SettingsMpv(!LibMpvDynamic.IsInstalled))
{
var oldMpvEnabled = radioButtonVideoPlayerMPV.Enabled;
if (form.ShowDialog(this) == DialogResult.OK)
@ -3430,10 +3452,15 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void listBoxNames_DoubleClick(object sender, EventArgs e)
{
var idx = listBoxNames.SelectedIndex;
if (listViewNames.SelectedItems.Count == 0)
{
return;
}
var idx = listViewNames.SelectedItems[0].Index;
if (idx >= 0)
{
textBoxNameEtc.Text = (string)listBoxNames.Items[idx];
textBoxNameEtc.Text = (string)listViewNames.Items[idx].Text;
}
}
@ -3612,5 +3639,46 @@ namespace Nikse.SubtitleEdit.Forms.Options
// avoid flickering when losing focus
listBoxSection.Update();
}
private void listViewNames_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape ||
e.KeyCode == Keys.Tab ||
e.KeyCode == Keys.Return ||
e.KeyCode == Keys.Enter ||
e.KeyCode == Keys.Down ||
e.KeyCode == Keys.Up ||
e.KeyCode == Keys.PageDown ||
e.KeyCode == Keys.PageUp ||
e.KeyCode == Keys.None ||
e.KeyCode == UiUtil.HelpKeys ||
e.KeyCode == Keys.Home ||
e.KeyCode == Keys.End)
{
return;
}
if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 <
TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalMilliseconds)
{
_listBoxSearchString = string.Empty;
}
if (e.KeyCode == Keys.Delete)
{
if (_listBoxSearchString.Length > 0)
{
_listBoxSearchString = _listBoxSearchString.Remove(_listBoxSearchString.Length - 1, 1);
}
}
else
{
_listBoxSearchString += e.KeyCode.ToString();
}
_listBoxSearchStringLastUsed = DateTime.UtcNow;
FindAndSelectListViewItem(sender as ListView);
e.SuppressKeyPress = true;
}
}
}

View File

@ -29,8 +29,6 @@
private void InitializeComponent()
{
this.buttonDownload = new System.Windows.Forms.Button();
this.comboBoxVideoOutput = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelPleaseWait = new System.Windows.Forms.Label();
@ -46,35 +44,11 @@
this.buttonDownload.UseVisualStyleBackColor = true;
this.buttonDownload.Click += new System.EventHandler(this.ButtonDownloadClick);
//
// comboBoxVideoOutput
//
this.comboBoxVideoOutput.FormattingEnabled = true;
this.comboBoxVideoOutput.Items.AddRange(new object[] {
"gpu",
"direct3d",
"opengl",
"sdl",
"vaapi",
"vdpau"});
this.comboBoxVideoOutput.Location = new System.Drawing.Point(12, 109);
this.comboBoxVideoOutput.Name = "comboBoxVideoOutput";
this.comboBoxVideoOutput.Size = new System.Drawing.Size(186, 21);
this.comboBoxVideoOutput.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 93);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(67, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Video output";
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(129, 163);
this.buttonOK.Location = new System.Drawing.Point(129, 87);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 4;
@ -87,7 +61,7 @@
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(210, 163);
this.buttonCancel.Location = new System.Drawing.Point(210, 87);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 5;
@ -108,12 +82,10 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(297, 198);
this.ClientSize = new System.Drawing.Size(297, 122);
this.Controls.Add(this.labelPleaseWait);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxVideoOutput);
this.Controls.Add(this.buttonDownload);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
@ -133,8 +105,6 @@
#endregion
private System.Windows.Forms.Button buttonDownload;
private System.Windows.Forms.ComboBox comboBoxVideoOutput;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelPleaseWait;

View File

@ -11,7 +11,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
public sealed partial class SettingsMpv : Form
{
private readonly bool _justDownload;
private string _downloadUrl;
@ -22,35 +21,16 @@ namespace Nikse.SubtitleEdit.Forms.Options
UiUtil.FixFonts(this);
_justDownload = justDownload;
labelPleaseWait.Text = string.Empty;
if (Configuration.IsRunningOnLinux)
{
comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputLinux;
}
else
{
comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputWindows;
}
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
Text = Configuration.Settings.Language.SettingsMpv.Title;
Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv;
if (!Configuration.IsRunningOnLinux)
{
buttonDownload.Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv;
}
if (Configuration.IsRunningOnLinux)
{
comboBoxVideoOutput.Items.Clear();
comboBoxVideoOutput.Items.AddRange(new object[] { "vaapi", "opengl", "sdl", "vdpau" });
Controls.Remove(buttonDownload);
}
UiUtil.FixLargeFonts(this, buttonOK);
if (justDownload)
{
comboBoxVideoOutput.Enabled = false;
}
}
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
@ -80,7 +60,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
string fileName = Path.GetFileName(entry.FilenameInZip);
string path = Path.Combine(dictionaryFolder, fileName);
try
{
zip.ExtractFile(entry, path);
@ -100,13 +80,9 @@ namespace Nikse.SubtitleEdit.Forms.Options
buttonDownload.Enabled = !Configuration.IsRunningOnLinux;
MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk);
if (_justDownload)
{
DialogResult = DialogResult.OK;
}
DialogResult = DialogResult.OK;
}
private void ButtonDownloadClick(object sender, EventArgs e)
{
try
@ -138,11 +114,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void buttonOK_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(comboBoxVideoOutput.Text))
{
Configuration.Settings.General.MpvVideoOutputWindows = comboBoxVideoOutput.Text;
}
DialogResult = DialogResult.OK;
}
@ -153,7 +124,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void SettingsMpv_Load(object sender, EventArgs e)
{
if (Configuration.IsRunningOnWindows && !LibMpvDynamic.IsInstalled)
if (Configuration.IsRunningOnWindows && (!LibMpvDynamic.IsInstalled || _justDownload))
{
ButtonDownloadClick(null, null);
}