mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-01-31 21:11:39 +01:00
parent
dff5f92a7c
commit
b5e102bb0a
@ -1736,6 +1736,7 @@ If you have edited this file with Subtitle Edit you might be able to find a back
|
||||
<ShowVideoControls>Show video controls</ShowVideoControls>
|
||||
<HideVideoControls>Hide video controls</HideVideoControls>
|
||||
<GeneratingWaveformInBackground>Generating waveform in background...</GeneratingWaveformInBackground>
|
||||
<AutoBackupSaved>Auto-backup saved</AutoBackupSaved>
|
||||
</Main>
|
||||
<MatroskaSubtitleChooser>
|
||||
<Title>Choose subtitle from Matroska file</Title>
|
||||
@ -2135,6 +2136,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<ApplyAssaOverrideTags>Apply ASSA override tags to selection</ApplyAssaOverrideTags>
|
||||
<SetAssaPosition>Set/get ASSA position</SetAssaPosition>
|
||||
<SetAssaResolution>Set ASSA resolution (PlayResX/PlayResY)</SetAssaResolution>
|
||||
<TakeAutoBackup>Take auto-backup now</TakeAutoBackup>
|
||||
<ShowLineBreaksAs>Show line breaks in list view as</ShowLineBreaksAs>
|
||||
<SaveAsFileNameFrom>"Save as..." uses file name from</SaveAsFileNameFrom>
|
||||
<MainListViewDoubleClickAction>Double-clicking line in main window list view will</MainListViewDoubleClickAction>
|
||||
|
@ -2092,6 +2092,7 @@ $HorzAlign = Center
|
||||
public string GeneralApplyAssaOverrideTags { get; set; }
|
||||
public string GeneralSetAssaPosition { get; set; }
|
||||
public string GeneralSetAssaResolution { get; set; }
|
||||
public string GeneralTakeAutoBackup { get; set; }
|
||||
public string GeneralHelp { get; set; }
|
||||
|
||||
// File
|
||||
@ -8527,6 +8528,12 @@ $HorzAlign = Center
|
||||
shortcuts.GeneralSetAssaResolution = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("GeneralTakeAutoBackup");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.GeneralTakeAutoBackup = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewRemoveTimeCodes");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -10387,6 +10394,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("GeneralApplyAssaOverrideTags", shortcuts.GeneralApplyAssaOverrideTags);
|
||||
textWriter.WriteElementString("GeneralSetAssaPosition", shortcuts.GeneralSetAssaPosition);
|
||||
textWriter.WriteElementString("GeneralSetAssaResolution", shortcuts.GeneralSetAssaResolution);
|
||||
textWriter.WriteElementString("GeneralTakeAutoBackup", shortcuts.GeneralTakeAutoBackup);
|
||||
textWriter.WriteElementString("MainListViewRemoveTimeCodes", shortcuts.MainListViewRemoveTimeCodes);
|
||||
textWriter.WriteElementString("MainEditFixRTLViaUnicodeChars", shortcuts.MainEditFixRTLViaUnicodeChars);
|
||||
textWriter.WriteElementString("MainEditRemoveRTLUnicodeChars", shortcuts.MainEditRemoveRTLUnicodeChars);
|
||||
|
@ -3803,7 +3803,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitleListViewIndex = -1;
|
||||
SubtitleListview1.Fill(newSubtitle, _subtitleOriginal);
|
||||
_subtitle = newSubtitle;
|
||||
|
||||
|
||||
|
||||
_findHelper = null;
|
||||
_spellCheckForm = null;
|
||||
@ -15913,6 +15913,29 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetAssaResolution(_subtitle);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainGeneralTakeAutoBackupNow == e.KeyData)
|
||||
{
|
||||
var saveFormat = GetCurrentSubtitleFormat();
|
||||
if (!saveFormat.IsTextBased)
|
||||
{
|
||||
saveFormat = new SubRip();
|
||||
}
|
||||
|
||||
if (_subtitle != null)
|
||||
{
|
||||
if (SaveAutoBackup(_subtitle, saveFormat, _subtitle.ToText(saveFormat)))
|
||||
{
|
||||
ShowStatus(_language.AutoBackupSaved);
|
||||
}
|
||||
}
|
||||
|
||||
if (_subtitleOriginal != null)
|
||||
{
|
||||
SaveAutoBackup(_subtitle, saveFormat, _subtitleOriginal.ToText(saveFormat));
|
||||
}
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainToggleFocus == e.KeyData)
|
||||
{
|
||||
if (InListView)
|
||||
@ -24649,41 +24672,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
!string.IsNullOrEmpty(_textAutoBackup) && currentText.Trim() != _textAutoBackup.Trim() && !string.IsNullOrWhiteSpace(currentText)) &&
|
||||
_lastWrittenAutoBackup != currentText)
|
||||
{
|
||||
if (!Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.AutoBackupDirectory);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string title = string.Empty;
|
||||
if (!string.IsNullOrEmpty(_fileName))
|
||||
{
|
||||
title = "_" + Path.GetFileNameWithoutExtension(_fileName);
|
||||
}
|
||||
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, saveFormat.Extension);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(fileName, currentText);
|
||||
_lastWrittenAutoBackup = currentText;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (_showAutoBackupError)
|
||||
{
|
||||
MessageBox.Show("Unable to save auto-backup to file: " + fileName + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
exception.Message + Environment.NewLine + exception.StackTrace);
|
||||
_showAutoBackupError = false;
|
||||
}
|
||||
}
|
||||
SaveAutoBackup(_subtitle, saveFormat, currentText);
|
||||
_lastWrittenAutoBackup = currentText;
|
||||
|
||||
if (!_cleanupHasRun)
|
||||
{
|
||||
@ -24715,27 +24705,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (Configuration.Settings.General.AutoSave ||
|
||||
!string.IsNullOrEmpty(_textAutoBackupOriginal) && currentTextOriginal.Trim() != _textAutoBackupOriginal.Trim() && !string.IsNullOrWhiteSpace(currentTextOriginal))
|
||||
{
|
||||
if (!Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.AutoBackupDirectory);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string title = string.Empty;
|
||||
if (!string.IsNullOrEmpty(_subtitleOriginalFileName))
|
||||
{
|
||||
title = "_" + Path.GetFileNameWithoutExtension(_subtitleOriginalFileName);
|
||||
}
|
||||
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, "_Original" + title, saveFormat.Extension);
|
||||
File.WriteAllText(fileName, currentTextOriginal);
|
||||
SaveAutoBackup(_subtitleOriginal, saveFormat, currentTextOriginal);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24743,6 +24713,52 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private bool SaveAutoBackup(Subtitle subtitle, SubtitleFormat saveFormat, string currentText)
|
||||
{
|
||||
if (subtitle == null || subtitle.Paragraphs.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.AutoBackupDirectory);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string title = string.Empty;
|
||||
if (!string.IsNullOrEmpty(subtitle.FileName))
|
||||
{
|
||||
title = "_" + Path.GetFileNameWithoutExtension(subtitle.FileName);
|
||||
}
|
||||
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, saveFormat.Extension);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(fileName, currentText);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (_showAutoBackupError)
|
||||
{
|
||||
MessageBox.Show("Unable to save auto-backup to file: " + fileName + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
exception.Message + Environment.NewLine + exception.StackTrace);
|
||||
_showAutoBackupError = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DropVideoTick(object sender, EventArgs e)
|
||||
{
|
||||
_dragAndDropVideoTimer.Stop();
|
||||
@ -24794,6 +24810,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName));
|
||||
|
@ -1296,8 +1296,9 @@ namespace Nikse.SubtitleEdit.Forms.Options
|
||||
AddNode(generalNode, language.TogglePreviewOnVideo, nameof(Configuration.Settings.Shortcuts.GeneralTogglePreviewOnVideo));
|
||||
AddNode(generalNode, language.RemoveBlankLines, nameof(Configuration.Settings.Shortcuts.GeneralRemoveBlankLines));
|
||||
AddNode(generalNode, language.ApplyAssaOverrideTags, nameof(Configuration.Settings.Shortcuts.GeneralApplyAssaOverrideTags), true);
|
||||
AddNode(generalNode, language.SetAssaPosition, nameof(Configuration.Settings.Shortcuts.GeneralSetAssaPosition), true);
|
||||
AddNode(generalNode, language.SetAssaPosition, nameof(Configuration.Settings.Shortcuts.GeneralTakeAutoBackup), true);
|
||||
AddNode(generalNode, language.SetAssaResolution, nameof(Configuration.Settings.Shortcuts.GeneralSetAssaResolution));
|
||||
AddNode(generalNode, language.TakeAutoBackup, nameof(Configuration.Settings.Shortcuts.GeneralTakeAutoBackup));
|
||||
AddNode(generalNode, language.Help, nameof(Configuration.Settings.Shortcuts.GeneralHelp), true);
|
||||
_shortcuts.Nodes.Add(generalNode);
|
||||
|
||||
|
@ -1638,6 +1638,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
ShowVideoControls = "Show video controls",
|
||||
HideVideoControls = "Hide video controls",
|
||||
GeneratingWaveformInBackground = "Generating waveform in background...",
|
||||
AutoBackupSaved = "Auto-backup saved",
|
||||
|
||||
Menu = new LanguageStructure.Main.MainMenu
|
||||
{
|
||||
@ -2467,6 +2468,7 @@ can edit in same subtitle file (collaboration)",
|
||||
ApplyAssaOverrideTags = "Apply ASSA override tags to selection",
|
||||
SetAssaPosition = "Set/get ASSA position",
|
||||
SetAssaResolution = "Set ASSA resolution (PlayResX/PlayResY)",
|
||||
TakeAutoBackup = "Take auto-backup now",
|
||||
ShowLineBreaksAs = "Show line breaks in list view as",
|
||||
SaveAsFileNameFrom = "\"Save as...\" uses file name from",
|
||||
MainListViewDoubleClickAction = "Double-clicking line in main window list view will",
|
||||
|
@ -3781,6 +3781,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Main/GeneratingWaveformInBackground":
|
||||
language.Main.GeneratingWaveformInBackground = reader.Value;
|
||||
break;
|
||||
case "Main/AutoBackupSaved":
|
||||
language.Main.AutoBackupSaved = reader.Value;
|
||||
break;
|
||||
case "Main/Menu/File/Title":
|
||||
language.Main.Menu.File.Title = reader.Value;
|
||||
break;
|
||||
@ -5776,6 +5779,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Settings/SetAssaResolution":
|
||||
language.Settings.SetAssaResolution = reader.Value;
|
||||
break;
|
||||
case "Settings/TakeAutoBackup":
|
||||
language.Settings.TakeAutoBackup = reader.Value;
|
||||
break;
|
||||
case "Settings/ShowLineBreaksAs":
|
||||
language.Settings.ShowLineBreaksAs = reader.Value;
|
||||
break;
|
||||
|
@ -1490,6 +1490,7 @@
|
||||
public string ShowVideoControls { get; set; }
|
||||
public string HideVideoControls { get; set; }
|
||||
public string GeneratingWaveformInBackground { get; set; }
|
||||
public string AutoBackupSaved { get; set; }
|
||||
|
||||
public class MainMenu
|
||||
{
|
||||
@ -2315,6 +2316,7 @@
|
||||
public string ApplyAssaOverrideTags { get; set; }
|
||||
public string SetAssaPosition { get; set; }
|
||||
public string SetAssaResolution { get; set; }
|
||||
public string TakeAutoBackup { get; set; }
|
||||
public string ShowLineBreaksAs { get; set; }
|
||||
public string SaveAsFileNameFrom { get; set; }
|
||||
public string MainListViewDoubleClickAction { get; set; }
|
||||
|
@ -32,6 +32,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public Keys MainGeneralGoToEndOfCurrentSubtitle { get; set; }
|
||||
public Keys MainGeneralFileSaveAll { get; set; }
|
||||
public Keys MainGeneralSetAssaResolution { get; set; }
|
||||
public Keys MainGeneralTakeAutoBackupNow { get; set; }
|
||||
public Keys MainToolsAutoDuration { get; set; }
|
||||
public Keys MainVideoFoucsSetVideoPosition { get; set; }
|
||||
public Keys ToggleVideoDockUndock { get; set; }
|
||||
@ -251,6 +252,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MainGeneralGoToEndOfCurrentSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToEndOfCurrentSubtitle);
|
||||
MainGeneralFileSaveAll = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveAll);
|
||||
MainGeneralSetAssaResolution = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralSetAssaResolution);
|
||||
MainGeneralTakeAutoBackupNow = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralTakeAutoBackup);
|
||||
MainVideoPlayFromJustBefore = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore);
|
||||
MainVideoPlayFromBeginning = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayFromBeginning);
|
||||
VideoPause = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPause);
|
||||
|
Loading…
x
Reference in New Issue
Block a user