Try to improve disabled edit controls when no sub is loaded - thx darnn :)

Related to #5686
This commit is contained in:
niksedk 2022-01-13 08:50:44 +01:00
parent 56a254e693
commit c61afd21b4
4 changed files with 99 additions and 19 deletions

View File

@ -2569,7 +2569,7 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripMenuItemSelectedLines, this.toolStripMenuItemSelectedLines,
this.toolStripMenuItemGoogleMicrosoftTranslateSelLine}); this.toolStripMenuItemGoogleMicrosoftTranslateSelLine});
this.contextMenuStripListView.Name = "contextMenuStripListView"; this.contextMenuStripListView.Name = "contextMenuStripListView";
this.contextMenuStripListView.Size = new System.Drawing.Size(285, 798); this.contextMenuStripListView.Size = new System.Drawing.Size(285, 776);
this.contextMenuStripListView.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed); this.contextMenuStripListView.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed);
this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListViewOpening); this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListViewOpening);
this.contextMenuStripListView.Opened += new System.EventHandler(this.MenuOpened); this.contextMenuStripListView.Opened += new System.EventHandler(this.MenuOpened);
@ -5483,6 +5483,7 @@ namespace Nikse.SubtitleEdit.Forms
this.ResizeEnd += new System.EventHandler(this.Main_ResizeEnd); this.ResizeEnd += new System.EventHandler(this.Main_ResizeEnd);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainKeyDown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainKeyDown);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainKeyUp); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainKeyUp);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Main_MouseDown);
this.Resize += new System.EventHandler(this.Main_Resize); this.Resize += new System.EventHandler(this.Main_Resize);
this.statusStrip1.ResumeLayout(false); this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout(); this.statusStrip1.PerformLayout();

View File

@ -557,6 +557,11 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
if (string.IsNullOrEmpty(_fileName))
{
EnableOrDisableEditControls();
}
// Initialize events etc. for audio waveform // Initialize events etc. for audio waveform
audioVisualizer.OnDoubleClickNonParagraph += AudioWaveform_OnDoubleClickNonParagraph; audioVisualizer.OnDoubleClickNonParagraph += AudioWaveform_OnDoubleClickNonParagraph;
audioVisualizer.OnPositionSelected += AudioWaveform_OnPositionSelected; audioVisualizer.OnPositionSelected += AudioWaveform_OnPositionSelected;
@ -5047,15 +5052,16 @@ namespace Nikse.SubtitleEdit.Forms
_sourceViewChange = false; _sourceViewChange = false;
_subtitleListViewIndex = -1; //harboe _subtitleListViewIndex = -1;
textBoxListViewText.Text = string.Empty; //textBoxListViewText.Text = string.Empty;
textBoxListViewTextOriginal.Text = string.Empty; //textBoxListViewTextOriginal.Text = string.Empty;
textBoxListViewText.Enabled = false; //textBoxListViewText.Enabled = false;
textBoxListViewText.BackColor = SystemColors.ActiveBorder; //textBoxListViewText.BackColor = SystemColors.ActiveBorder;
textBoxListViewTextOriginal.BackColor = SystemColors.ActiveBorder; //textBoxListViewTextOriginal.BackColor = SystemColors.ActiveBorder;
labelTextLineLengths.Text = string.Empty; //labelTextLineLengths.Text = string.Empty;
labelCharactersPerSecond.Text = string.Empty; //labelCharactersPerSecond.Text = string.Empty;
labelTextLineTotal.Text = string.Empty; //labelTextLineTotal.Text = string.Empty;
EnableOrDisableEditControls();
_listViewTextUndoLast = null; _listViewTextUndoLast = null;
_listViewOriginalTextUndoLast = null; _listViewOriginalTextUndoLast = null;
@ -6968,8 +6974,9 @@ namespace Nikse.SubtitleEdit.Forms
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
_sourceViewChange = false; _sourceViewChange = false;
_subtitle.Paragraphs.Clear(); _subtitle.Paragraphs.Clear();
textBoxListViewText.Text = string.Empty; //harboe textBoxListViewText.Text = string.Empty;
textBoxListViewText.Enabled = false; //textBoxListViewText.Enabled = false;
EnableOrDisableEditControls();
} }
_subtitleListViewIndex = -1; _subtitleListViewIndex = -1;
@ -6991,8 +6998,9 @@ namespace Nikse.SubtitleEdit.Forms
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
_subtitle.Paragraphs.Clear(); _subtitle.Paragraphs.Clear();
SubtitleListview1.Items.Clear(); SubtitleListview1.Items.Clear();
textBoxListViewText.Text = string.Empty; //textBoxListViewText.Text = string.Empty;
textBoxListViewText.Enabled = false; //textBoxListViewText.Enabled = false;
EnableOrDisableEditControls();
return; return;
} }
@ -7779,6 +7787,7 @@ namespace Nikse.SubtitleEdit.Forms
timerOriginalTextUndo.Start(); timerOriginalTextUndo.Start();
SetTitle(); SetTitle();
SetListViewStateImages(); SetListViewStateImages();
EnableOrDisableEditControls();
} }
} }
@ -9155,14 +9164,14 @@ namespace Nikse.SubtitleEdit.Forms
MakeHistoryForUndo(historyText); MakeHistoryForUndo(historyText);
DeleteSelectedLines(); DeleteSelectedLines();
ResetTextInfoIfEmpty(); EnableOrDisableEditControls();
ShowStatus(statusText); ShowStatus(statusText);
UpdateSourceView(); UpdateSourceView();
} }
} }
private void ResetTextInfoIfEmpty() private void EnableOrDisableEditControls()
{ {
if (_subtitle.Paragraphs.Count == 0) if (_subtitle.Paragraphs.Count == 0)
{ {
@ -9190,6 +9199,55 @@ namespace Nikse.SubtitleEdit.Forms
labelOriginalCharactersPerSecond.Text = string.Empty; labelOriginalCharactersPerSecond.Text = string.Empty;
labelTextOriginalLineLengths.Text = string.Empty; labelTextOriginalLineLengths.Text = string.Empty;
labelTextOriginalLineTotal.Text = string.Empty; labelTextOriginalLineTotal.Text = string.Empty;
numericUpDownDuration.Value = 0;
timeUpDownStartTime.TimeCode = new TimeCode(0);
textBoxListViewText.Enabled = false;
textBoxListViewTextOriginal.Enabled = false;
timeUpDownStartTime.Enabled = false;
numericUpDownDuration.Enabled = false;
buttonPrevious.Enabled = false;
buttonNext.Enabled = false;
buttonUnBreak.Enabled = false;
buttonAutoBreak.Enabled = false;
if (!Configuration.Settings.General.UseDarkTheme)
{
labelText.Enabled = false;
labelStartTime.Enabled = false;
labelDuration.Enabled = false;
}
else
{
var foreColor = Configuration.Settings.General.DarkThemeForeColor;
var slightDarker = Color.FromArgb(Math.Max(0, foreColor.R - 75), Math.Max(0, foreColor.G - 75), Math.Max(0, foreColor.B - 75));
labelText.ForeColor = slightDarker;
labelStartTime.ForeColor = slightDarker;
labelDuration.ForeColor = slightDarker;
}
}
else if (!numericUpDownDuration.Enabled)
{
textBoxListViewText.BackColor = SystemColors.WindowFrame;
textBoxListViewTextOriginal.BackColor = SystemColors.WindowFrame;
textBoxListViewText.Enabled = true;
textBoxListViewTextOriginal.Enabled = true;
timeUpDownStartTime.Enabled = true;
numericUpDownDuration.Enabled = true;
buttonPrevious.Enabled = true;
buttonNext.Enabled = true;
buttonUnBreak.Enabled = true;
buttonAutoBreak.Enabled = true;
labelText.Enabled = true;
labelStartTime.Enabled = true;
labelDuration.Enabled = true;
if (Configuration.Settings.General.UseDarkTheme)
{
var foreColor = Configuration.Settings.General.DarkThemeForeColor;
labelText.ForeColor = foreColor;
labelStartTime.ForeColor = foreColor;
labelDuration.ForeColor = foreColor;
}
} }
} }
@ -9264,7 +9322,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
ResetTextInfoIfEmpty(); EnableOrDisableEditControls();
SetListViewStateImages(); SetListViewStateImages();
} }
@ -12183,6 +12241,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
textBoxListViewText.Enabled = true; textBoxListViewText.Enabled = true;
textBoxListViewText.BackColor = textBoxListViewText.Focused ? SystemColors.Highlight : SystemColors.WindowFrame; textBoxListViewText.BackColor = textBoxListViewText.Focused ? SystemColors.Highlight : SystemColors.WindowFrame;
EnableOrDisableEditControls();
} }
StartUpdateListSyntaxColoring(); StartUpdateListSyntaxColoring();
@ -23427,6 +23486,14 @@ namespace Nikse.SubtitleEdit.Forms
_timerSlow.Start(); _timerSlow.Start();
} }
private void GroupBoxEdit_MouseClick(object sender, MouseEventArgs e)
{
if (!textBoxListViewText.Enabled)
{
InsertLineToolStripMenuItemClick(null, null);
}
}
private void TextBoxListViewText_MouseDown(object sender, MouseEventArgs e) private void TextBoxListViewText_MouseDown(object sender, MouseEventArgs e)
{ {
if (!textBoxListViewText.Enabled) if (!textBoxListViewText.Enabled)
@ -33111,5 +33178,17 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.SelectIndexAndEnsureVisibleFaster(idx); SubtitleListview1.SelectIndexAndEnsureVisibleFaster(idx);
} }
} }
private void Main_MouseDown(object sender, MouseEventArgs e)
{
if (e.X > 72 && e.X <= (122 + textBoxListViewText.Height))
{
if (!textBoxListViewText.Enabled)
{
InsertLineToolStripMenuItemClick(null, null);
return;
}
}
}
} }
} }

View File

@ -791,7 +791,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAeQBLAHkASwBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo CAAAAk1TRnQBSQFMAgEBAgEAARwBLQEcAS0BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -404,7 +404,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
} }
} }
private string[] LoadWordSplitList(string threeLetterIsoLanguageName, NameList nameList) private static string[] LoadWordSplitList(string threeLetterIsoLanguageName, NameList nameList)
{ {
var fileName = $"{Configuration.DictionariesDirectory}{threeLetterIsoLanguageName}_WordSplitList.txt"; var fileName = $"{Configuration.DictionariesDirectory}{threeLetterIsoLanguageName}_WordSplitList.txt";
if (!File.Exists(fileName)) if (!File.Exists(fileName))