Add custom toggle shortcut - thx HadiSparrow :)

Fix #6744
This commit is contained in:
niksedk 2023-03-14 12:19:31 +01:00
parent 34e9cf0078
commit a56932f4ef
7 changed files with 142 additions and 20 deletions

View File

@ -1424,6 +1424,7 @@ $HorzAlign = Center
public bool AutoSave { get; set; }
public string PreviewAssaText { get; set; }
public string TagsInToggleHiTags { get; set; }
public string TagsInToggleCustomTags { get; set; }
public bool ShowProgress { get; set; }
public bool ShowNegativeDurationInfoOnSave { get; set; }
public bool ShowFormatRequiresUtf8Warning { get; set; }
@ -1619,6 +1620,7 @@ $HorzAlign = Center
MeasurementConverterCategories = "Length;Kilometers;Meters";
PreviewAssaText = "ABCDEFGHIJKL abcdefghijkl 123";
TagsInToggleHiTags = "[;]";
TagsInToggleCustomTags = "(Æ)";
SubtitleTextBoxMaxHeight = 300;
ShowBetaStuff = false;
DebugTranslationSync = false;
@ -2396,6 +2398,7 @@ $HorzAlign = Center
public string MainListViewBox { get; set; }
public string MainListViewToggleQuotes { get; set; }
public string MainListViewToggleHiTags { get; set; }
public string MainListViewToggleCustomTags { get; set; }
public string MainListViewSplit { get; set; }
public string MainListViewToggleDashes { get; set; }
public string MainListViewToggleMusicSymbols { get; set; }
@ -4267,6 +4270,12 @@ $HorzAlign = Center
settings.General.TagsInToggleHiTags = subNode.InnerText;
}
subNode = node.SelectSingleNode("TagsInToggleCustomTags");
if (subNode != null)
{
settings.General.TagsInToggleCustomTags = subNode.InnerText;
}
subNode = node.SelectSingleNode("ShowProgress");
if (subNode != null)
{
@ -8965,6 +8974,12 @@ $HorzAlign = Center
shortcuts.MainListViewToggleHiTags = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainListViewToggleCustomTags");
if (subNode != null)
{
shortcuts.MainListViewToggleCustomTags = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainListViewSplit");
if (subNode != null)
{
@ -10282,6 +10297,7 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoSave", settings.General.AutoSave.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("PreviewAssaText", settings.General.PreviewAssaText);
textWriter.WriteElementString("TagsInToggleHiTags", settings.General.TagsInToggleHiTags);
textWriter.WriteElementString("TagsInToggleCustomTags", settings.General.TagsInToggleCustomTags);
textWriter.WriteElementString("ShowProgress", settings.General.ShowProgress.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ShowNegativeDurationInfoOnSave", settings.General.ShowNegativeDurationInfoOnSave.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ShowFormatRequiresUtf8Warning", settings.General.ShowFormatRequiresUtf8Warning.ToString(CultureInfo.InvariantCulture));
@ -11236,6 +11252,7 @@ $HorzAlign = Center
textWriter.WriteElementString("MainListViewBox", shortcuts.MainListViewBox);
textWriter.WriteElementString("MainListViewToggleQuotes", shortcuts.MainListViewToggleQuotes);
textWriter.WriteElementString("MainListViewToggleHiTags", shortcuts.MainListViewToggleHiTags);
textWriter.WriteElementString("MainListViewToggleCustomTags", shortcuts.MainListViewToggleCustomTags);
textWriter.WriteElementString("MainListViewSplit", shortcuts.MainListViewSplit);
textWriter.WriteElementString("MainListViewToggleDashes", shortcuts.MainListViewToggleDashes);
textWriter.WriteElementString("MainListViewToggleMusicSymbols", shortcuts.MainListViewToggleMusicSymbols);

View File

@ -16149,6 +16149,41 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
}
else if (_shortcuts.MainListViewToggleCustomTags == e.KeyData && InListView)
{
var tags = Configuration.Settings.General.TagsInToggleCustomTags.Split('Æ');
string openingTag;
string closingTag;
switch (tags.Length)
{
case 1:
openingTag = tags[0];
closingTag = openingTag;
break;
case 2:
openingTag = tags[0];
closingTag = tags[1];
break;
default:
openingTag = string.Empty;
closingTag = string.Empty;
break;
}
if (!string.IsNullOrEmpty(openingTag) && !string.IsNullOrEmpty(closingTag))
{
if (textBoxListViewText.Focused || textBoxListViewTextOriginal.Focused)
{
SurroundWithTag(openingTag, closingTag, true);
}
else
{
SurroundWithTag(openingTag, closingTag);
}
}
e.SuppressKeyPress = true;
}
else if (!toolStripMenuItemRtlUnicodeControlChars.Visible && _shortcuts.MainEditFixRTLViaUnicodeChars == e.KeyData && InListView)
{
toolStripMenuItemRtlUnicodeControlChars_Click(null, null);

View File

@ -143,6 +143,7 @@
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.importShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAsHtmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelShortcut = new System.Windows.Forms.Label();
this.panelSyntaxColoring = new System.Windows.Forms.Panel();
this.groupBoxListViewSyntaxColoring = new System.Windows.Forms.GroupBox();
@ -415,7 +416,9 @@
this.labelUpdateFileTypeAssociationsStatus = new System.Windows.Forms.Label();
this.imageListFileTypeAssociations = new System.Windows.Forms.ImageList(this.components);
this.toolTipDialogStylePreview = new System.Windows.Forms.ToolTip(this.components);
this.exportAsHtmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelShortcutCustomToggle = new System.Windows.Forms.Label();
this.comboBoxCustomToggleStart = new System.Windows.Forms.ComboBox();
this.comboBoxCustomToggleEnd = new System.Windows.Forms.ComboBox();
this.panelGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
this.groupBoxGeneralRules.SuspendLayout();
@ -1945,34 +1948,41 @@
this.exportShortcutsToolStripMenuItem,
this.exportAsHtmlToolStripMenuItem});
this.contextMenuStripShortcuts.Name = "contextMenuStripShortcuts";
this.contextMenuStripShortcuts.Size = new System.Drawing.Size(181, 120);
this.contextMenuStripShortcuts.Size = new System.Drawing.Size(160, 98);
//
// toolStripMenuItemShortcutsCollapse
//
this.toolStripMenuItemShortcutsCollapse.Name = "toolStripMenuItemShortcutsCollapse";
this.toolStripMenuItemShortcutsCollapse.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemShortcutsCollapse.Size = new System.Drawing.Size(159, 22);
this.toolStripMenuItemShortcutsCollapse.Text = "Collapse";
this.toolStripMenuItemShortcutsCollapse.Click += new System.EventHandler(this.toolStripMenuItemShortcutsCollapse_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(156, 6);
//
// importShortcutsToolStripMenuItem
//
this.importShortcutsToolStripMenuItem.Name = "importShortcutsToolStripMenuItem";
this.importShortcutsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.importShortcutsToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
this.importShortcutsToolStripMenuItem.Text = "Import...";
this.importShortcutsToolStripMenuItem.Click += new System.EventHandler(this.importShortcutsToolStripMenuItem_Click);
//
// exportShortcutsToolStripMenuItem
//
this.exportShortcutsToolStripMenuItem.Name = "exportShortcutsToolStripMenuItem";
this.exportShortcutsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exportShortcutsToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
this.exportShortcutsToolStripMenuItem.Text = "Export...";
this.exportShortcutsToolStripMenuItem.Click += new System.EventHandler(this.exportShortcutsToolStripMenuItem_Click);
//
// exportAsHtmlToolStripMenuItem
//
this.exportAsHtmlToolStripMenuItem.Name = "exportAsHtmlToolStripMenuItem";
this.exportAsHtmlToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
this.exportAsHtmlToolStripMenuItem.Text = "Export as html...";
this.exportAsHtmlToolStripMenuItem.Click += new System.EventHandler(this.exportAsHtmlToolStripMenuItem_Click);
//
// labelShortcut
//
this.labelShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -3214,6 +3224,9 @@
//
// groupBoxToolsMisc
//
this.groupBoxToolsMisc.Controls.Add(this.comboBoxCustomToggleEnd);
this.groupBoxToolsMisc.Controls.Add(this.comboBoxCustomToggleStart);
this.groupBoxToolsMisc.Controls.Add(this.labelShortcutCustomToggle);
this.groupBoxToolsMisc.Controls.Add(this.checkBoxShortcutsAllowLetterOrNumberInTextBox);
this.groupBoxToolsMisc.Controls.Add(this.comboBoxBDOpensIn);
this.groupBoxToolsMisc.Controls.Add(this.labelBDOpensIn);
@ -3227,7 +3240,7 @@
// checkBoxShortcutsAllowLetterOrNumberInTextBox
//
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.AutoSize = true;
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.Location = new System.Drawing.Point(8, 65);
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.Location = new System.Drawing.Point(6, 52);
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.Name = "checkBoxShortcutsAllowLetterOrNumberInTextBox";
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.Size = new System.Drawing.Size(223, 17);
this.checkBoxShortcutsAllowLetterOrNumberInTextBox.TabIndex = 61;
@ -3241,7 +3254,7 @@
this.comboBoxBDOpensIn.Items.AddRange(new object[] {
"OCR",
"BD SUP EDIIT"});
this.comboBoxBDOpensIn.Location = new System.Drawing.Point(158, 27);
this.comboBoxBDOpensIn.Location = new System.Drawing.Point(158, 25);
this.comboBoxBDOpensIn.Name = "comboBoxBDOpensIn";
this.comboBoxBDOpensIn.Size = new System.Drawing.Size(221, 21);
this.comboBoxBDOpensIn.TabIndex = 1;
@ -3249,7 +3262,7 @@
// labelBDOpensIn
//
this.labelBDOpensIn.AutoSize = true;
this.labelBDOpensIn.Location = new System.Drawing.Point(6, 29);
this.labelBDOpensIn.Location = new System.Drawing.Point(6, 27);
this.labelBDOpensIn.Name = "labelBDOpensIn";
this.labelBDOpensIn.Size = new System.Drawing.Size(146, 13);
this.labelBDOpensIn.TabIndex = 0;
@ -4985,12 +4998,38 @@
this.toolTipDialogStylePreview.InitialDelay = 500;
this.toolTipDialogStylePreview.ReshowDelay = 100;
//
// exportAsHtmlToolStripMenuItem
// labelShortcutCustomToggle
//
this.exportAsHtmlToolStripMenuItem.Name = "exportAsHtmlToolStripMenuItem";
this.exportAsHtmlToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exportAsHtmlToolStripMenuItem.Text = "Export as html...";
this.exportAsHtmlToolStripMenuItem.Click += new System.EventHandler(this.exportAsHtmlToolStripMenuItem_Click);
this.labelShortcutCustomToggle.AutoSize = true;
this.labelShortcutCustomToggle.Location = new System.Drawing.Point(6, 79);
this.labelShortcutCustomToggle.Name = "labelShortcutCustomToggle";
this.labelShortcutCustomToggle.Size = new System.Drawing.Size(169, 13);
this.labelShortcutCustomToggle.TabIndex = 62;
this.labelShortcutCustomToggle.Text = "Shortcut toggle custom start/end";
//
// comboBoxCustomToggleStart
//
this.comboBoxCustomToggleStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCustomToggleStart.FormattingEnabled = true;
this.comboBoxCustomToggleStart.Items.AddRange(new object[] {
"(",
"♪"});
this.comboBoxCustomToggleStart.Location = new System.Drawing.Point(182, 76);
this.comboBoxCustomToggleStart.Name = "comboBoxCustomToggleStart";
this.comboBoxCustomToggleStart.Size = new System.Drawing.Size(42, 21);
this.comboBoxCustomToggleStart.TabIndex = 63;
//
// comboBoxCustomToggleEnd
//
this.comboBoxCustomToggleEnd.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCustomToggleEnd.FormattingEnabled = true;
this.comboBoxCustomToggleEnd.Items.AddRange(new object[] {
")",
"♪"});
this.comboBoxCustomToggleEnd.Location = new System.Drawing.Point(230, 76);
this.comboBoxCustomToggleEnd.Name = "comboBoxCustomToggleEnd";
this.comboBoxCustomToggleEnd.Size = new System.Drawing.Size(42, 21);
this.comboBoxCustomToggleEnd.TabIndex = 64;
//
// Settings
//
@ -4998,9 +5037,9 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1092, 574);
this.Controls.Add(this.labelUpdateFileTypeAssociationsStatus);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.panelShortcuts);
this.Controls.Add(this.panelGeneral);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.panelFont);
this.Controls.Add(this.panelToolBar);
this.Controls.Add(this.panelNetwork);
@ -5517,5 +5556,8 @@
private System.Windows.Forms.Label labelTranslationAutoSuffix;
private System.Windows.Forms.CheckBox checkBoxUseWordSplitListAvoidPropercase;
private System.Windows.Forms.ToolStripMenuItem exportAsHtmlToolStripMenuItem;
private System.Windows.Forms.ComboBox comboBoxCustomToggleEnd;
private System.Windows.Forms.ComboBox comboBoxCustomToggleStart;
private System.Windows.Forms.Label labelShortcutCustomToggle;
}
}

View File

@ -107,17 +107,17 @@ namespace Nikse.SubtitleEdit.Forms.Options
UiUtil.FixLargeFonts(this, buttonOK);
_shortcutsBackgroundWorker = new BackgroundWorker();
Init();
}
public void Init()
{
_shortcutsBackgroundWorker.DoWork += (sender, args) =>
{
MakeShortcutsTreeView(LanguageSettings.Current.Settings);
};
_shortcutsBackgroundWorker.RunWorkerAsync();
Init();
}
public void Init()
{
labelStatus.Text = string.Empty;
_rulesProfiles = new List<RulesProfile>(Configuration.Settings.General.Profiles);
var gs = Configuration.Settings.General;
@ -771,6 +771,22 @@ namespace Nikse.SubtitleEdit.Forms.Options
checkBoxShortcutsAllowLetterOrNumberInTextBox.Text = language.ShortcutsAllowSingleLetterOrNumberInTextBox;
checkBoxShortcutsAllowLetterOrNumberInTextBox.Checked = Configuration.Settings.General.AllowLetterShortcutsInTextBox;
labelShortcutCustomToggle.Text = language.ShortcutCustomToggle;
comboBoxCustomToggleStart.Left = labelShortcutCustomToggle.Right + 5;
comboBoxCustomToggleEnd.Left = comboBoxCustomToggleStart.Right + 5;
var customTags = Configuration.Settings.General.TagsInToggleCustomTags.Split('Æ');
switch (customTags.Length)
{
case 1:
comboBoxCustomToggleStart.Text = customTags[0];
comboBoxCustomToggleEnd.Text = customTags[0];
break;
case 2:
comboBoxCustomToggleStart.Text = customTags[0];
comboBoxCustomToggleEnd.Text = customTags[1];
break;
}
groupBoxGoogleTranslate.Text = language.GoogleTranslate;
labelGoogleTranslateApiKey.Text = language.GoogleTranslateApiKey;
linkLabelGoogleTranslateSignUp.Text = language.HowToSignUp;
@ -1255,6 +1271,9 @@ namespace Nikse.SubtitleEdit.Forms.Options
private void MakeShortcutsTreeView(LanguageStructure.Settings language)
{
treeViewShortcuts.Nodes.Clear();
_newShortcuts.Clear();
_shortcuts = new ShortcutNode("root");
var generalNode = new ShortcutNode(LanguageSettings.Current.General.GeneralText);
@ -1453,6 +1472,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
AddNode(listViewAndTextBoxNode, LanguageSettings.Current.Main.Menu.ContextMenu.Box, nameof(Configuration.Settings.Shortcuts.MainListViewBox), true);
AddNode(listViewAndTextBoxNode, language.ToggleQuotes, nameof(Configuration.Settings.Shortcuts.MainListViewToggleQuotes), true);
AddNode(listViewAndTextBoxNode, language.ToggleHiTags, nameof(Configuration.Settings.Shortcuts.MainListViewToggleHiTags), true);
AddNode(listViewAndTextBoxNode, language.ToggleCustomTags, nameof(Configuration.Settings.Shortcuts.MainListViewToggleCustomTags), false);
AddNode(listViewAndTextBoxNode, LanguageSettings.Current.General.SplitLine.Replace("!", string.Empty), nameof(Configuration.Settings.Shortcuts.MainListViewSplit), true);
AddNode(listViewAndTextBoxNode, language.ToggleMusicSymbols, nameof(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols), true);
AddNode(listViewAndTextBoxNode, language.AlignmentN1, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN1));
@ -2020,6 +2040,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
Configuration.Settings.Tools.BDOpenIn = comboBoxBDOpensIn.SelectedIndex == 0 ? "OCR" : "EDIT";
Configuration.Settings.General.AllowLetterShortcutsInTextBox = checkBoxShortcutsAllowLetterOrNumberInTextBox.Checked;
Configuration.Settings.General.TagsInToggleCustomTags = comboBoxCustomToggleStart.Text + "Æ" + comboBoxCustomToggleEnd.Text;
toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked;
toolsSettings.OcrUseWordSplitList = checkBoxUseWordSplitList.Checked;
@ -2949,6 +2970,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
Configuration.Settings.Reset();
Configuration.Settings.General.VideoPlayer = "MPV";
Configuration.Settings.Shortcuts = new Shortcuts();
Init();
}
}

View File

@ -2800,6 +2800,7 @@ can edit in same subtitle file (collaboration)",
ToggleDialogDashes = "Toggle dialog dashes",
ToggleQuotes = "Toggle quotes",
ToggleHiTags = "Toggle HI tags",
ToggleCustomTags = "Toggle custom tags",
ToggleMusicSymbols = "Toggle music symbols",
Alignment = "Alignment (selected lines)",
AlignmentN1 = "Alignment bottom left - {\\an1}",
@ -2985,6 +2986,7 @@ can edit in same subtitle file (collaboration)",
BDOpensInOcr = "OCR",
BDOpensInEdit = "Edit",
ShortcutsAllowSingleLetterOrNumberInTextBox = "Shortcuts: Allow single letter/number in text box",
ShortcutCustomToggle = "Shortcut toggle custom start/end",
UpdateFileTypeAssociations = "Update file type associations",
FileTypeAssociationsUpdated = "File type associations updated",
CustomContinuationStyle = "Edit custom continuation style",

View File

@ -2652,6 +2652,7 @@ namespace Nikse.SubtitleEdit.Logic
public string ToggleDialogDashes { get; set; }
public string ToggleQuotes { get; set; }
public string ToggleHiTags { get; set; }
public string ToggleCustomTags { get; set; }
public string ToggleMusicSymbols { get; set; }
public string Alignment { get; set; }
public string AlignmentN1 { get; set; }
@ -2834,6 +2835,7 @@ namespace Nikse.SubtitleEdit.Logic
public string BDOpensInOcr { get; set; }
public string BDOpensInEdit { get; set; }
public string ShortcutsAllowSingleLetterOrNumberInTextBox { get; set; }
public string ShortcutCustomToggle { get; set; }
public string UpdateFileTypeAssociations { get; set; }
public string FileTypeAssociationsUpdated { get; set; }
public string CustomContinuationStyle { get; set; }

View File

@ -186,6 +186,7 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainListViewToggleDashes { get; set; }
public Keys MainListViewToggleQuotes { get; set; }
public Keys MainListViewToggleHiTags { get; set; }
public Keys MainListViewToggleCustomTags { get; set; }
public Keys MainListViewToggleMusicSymbols { get; set; }
public Keys MainListViewAutoDuration { get; set; }
public Keys MainListViewAlignmentN1 { get; set; }
@ -345,6 +346,7 @@ namespace Nikse.SubtitleEdit.Logic
MainListViewToggleDashes = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleDashes);
MainListViewToggleQuotes = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleQuotes);
MainListViewToggleHiTags = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleHiTags);
MainListViewToggleCustomTags = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleCustomTags);
MainListViewToggleMusicSymbols = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols);
MainListViewAutoDuration = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAutoDuration);
MainListViewAlignmentN1 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignmentN1);