Add "Restore default settings" button in settings

This commit is contained in:
Nikolaj Olsson 2019-12-11 15:17:35 +01:00
parent 7c0b4bab4f
commit eca6157df9
7 changed files with 86 additions and 28 deletions

View File

@ -2096,6 +2096,10 @@ can edit in same subtitle file (collaboration)</Information>
<FontNote>Note: These font settings are for the Subtitle Edit UI only.
Setting a font for a subtitle is normally done in the video player, but can also be done when using a subtitle format with built-in font information like
"Advanced Sub Station Alpha" or via export to image based formats.</FontNote>
<RestoreDefaultSettings>Restore default settings</RestoreDefaultSettings>
<RestoreDefaultSettingsMsg>All settings will be restored to default values
Continue?</RestoreDefaultSettingsMsg>
</Settings>
<SettingsMpv>
<Title>Settings for mpv</Title>

View File

@ -2389,7 +2389,11 @@ can edit in same subtitle file (collaboration)",
MicrosoftTranslateTokenEndpoint = "Token endpoint",
FontNote = "Note: These font settings are for the Subtitle Edit UI only." + Environment.NewLine +
"Setting a font for a subtitle is normally done in the video player, but can also be done when using a subtitle format with built-in font information like " + Environment.NewLine +
"\"Advanced Sub Station Alpha\" or via export to image based formats."
"\"Advanced Sub Station Alpha\" or via export to image based formats.",
RestoreDefaultSettings = "Restore default settings",
RestoreDefaultSettingsMsg = "All settings will be restored to default values" + Environment.NewLine +
Environment.NewLine +
"Continue?"
};
SettingsMpv = new LanguageStructure.SettingsMpv

View File

@ -5704,6 +5704,12 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/FontNote":
language.Settings.FontNote = reader.Value;
break;
case "Settings/RestoreDefaultSettings":
language.Settings.RestoreDefaultSettings = reader.Value;
break;
case "Settings/RestoreDefaultSettingsMsg":
language.Settings.RestoreDefaultSettingsMsg = reader.Value;
break;
case "SettingsMpv/Title":
language.SettingsMpv.Title = reader.Value;
break;

View File

@ -2260,6 +2260,8 @@
public string MicrosoftTranslateApiKey { get; set; }
public string MicrosoftTranslateTokenEndpoint { get; set; }
public string FontNote { get; set; }
public string RestoreDefaultSettings { get; set; }
public string RestoreDefaultSettingsMsg { get; set; }
}
public class SettingsMpv

View File

@ -1691,7 +1691,7 @@ $HorzAlign = Center
[XmlIgnore]
public Language Language { get; set; }
private Settings()
public void Reset()
{
RecentFiles = new RecentFilesSettings();
General = new GeneralSettings();
@ -1712,6 +1712,11 @@ $HorzAlign = Center
Compare = new CompareSettings();
}
private Settings()
{
Reset();
}
public void Save()
{
//this is too slow: Serialize(Configuration.SettingsFileName, this);

View File

@ -206,6 +206,7 @@
this.linkLabelBingSubscribe = new System.Windows.Forms.LinkLabel();
this.label1 = new System.Windows.Forms.Label();
this.groupBoxToolsAutoBr = new System.Windows.Forms.GroupBox();
this.labelToolsBreakBottomHeavyPercent = new System.Windows.Forms.Label();
this.numericUpDownToolsBreakPreferBottomHeavy = new System.Windows.Forms.NumericUpDown();
this.checkBoxToolsBreakPreferBottomHeavy = new System.Windows.Forms.CheckBox();
this.checkBoxToolsBreakByPixelWidth = new System.Windows.Forms.CheckBox();
@ -364,7 +365,7 @@
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
this.labelStatus = new System.Windows.Forms.Label();
this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog();
this.labelToolsBreakBottomHeavyPercent = new System.Windows.Forms.Label();
this.buttonReset = new System.Windows.Forms.Button();
this.tabControlSettings.SuspendLayout();
this.tabPageGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
@ -449,7 +450,7 @@
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(697, 528);
this.buttonOK.Location = new System.Drawing.Point(506, 528);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 0;
@ -461,7 +462,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.Location = new System.Drawing.Point(778, 528);
this.buttonCancel.Location = new System.Drawing.Point(587, 528);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 1;
@ -619,7 +620,7 @@
//
// buttonEditProfile
//
this.buttonEditProfile.Location = new System.Drawing.Point(282, 19);
this.buttonEditProfile.Location = new System.Drawing.Point(322, 19);
this.buttonEditProfile.Name = "buttonEditProfile";
this.buttonEditProfile.Size = new System.Drawing.Size(28, 23);
this.buttonEditProfile.TabIndex = 10;
@ -633,7 +634,7 @@
this.comboBoxRulesProfileName.FormattingEnabled = true;
this.comboBoxRulesProfileName.Location = new System.Drawing.Point(78, 20);
this.comboBoxRulesProfileName.Name = "comboBoxRulesProfileName";
this.comboBoxRulesProfileName.Size = new System.Drawing.Size(198, 21);
this.comboBoxRulesProfileName.Size = new System.Drawing.Size(238, 21);
this.comboBoxRulesProfileName.TabIndex = 5;
this.comboBoxRulesProfileName.SelectedIndexChanged += new System.EventHandler(this.comboBoxRulesProfileName_SelectedIndexChanged);
//
@ -2726,6 +2727,15 @@
this.groupBoxToolsAutoBr.TabStop = false;
this.groupBoxToolsAutoBr.Text = "Auto br";
//
// labelToolsBreakBottomHeavyPercent
//
this.labelToolsBreakBottomHeavyPercent.AutoSize = true;
this.labelToolsBreakBottomHeavyPercent.Location = new System.Drawing.Point(226, 142);
this.labelToolsBreakBottomHeavyPercent.Name = "labelToolsBreakBottomHeavyPercent";
this.labelToolsBreakBottomHeavyPercent.Size = new System.Drawing.Size(18, 13);
this.labelToolsBreakBottomHeavyPercent.TabIndex = 63;
this.labelToolsBreakBottomHeavyPercent.Text = "%";
//
// numericUpDownToolsBreakPreferBottomHeavy
//
this.numericUpDownToolsBreakPreferBottomHeavy.DecimalPlaces = 1;
@ -4421,20 +4431,23 @@
//
this.openFileDialogFFmpeg.FileName = "openFileDialog1";
//
// labelToolsBreakBottomHeavyPercent
// buttonReset
//
this.labelToolsBreakBottomHeavyPercent.AutoSize = true;
this.labelToolsBreakBottomHeavyPercent.Location = new System.Drawing.Point(226, 142);
this.labelToolsBreakBottomHeavyPercent.Name = "labelToolsBreakBottomHeavyPercent";
this.labelToolsBreakBottomHeavyPercent.Size = new System.Drawing.Size(18, 13);
this.labelToolsBreakBottomHeavyPercent.TabIndex = 63;
this.labelToolsBreakBottomHeavyPercent.Text = "%";
this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonReset.Location = new System.Drawing.Point(668, 528);
this.buttonReset.Name = "buttonReset";
this.buttonReset.Size = new System.Drawing.Size(185, 21);
this.buttonReset.TabIndex = 2;
this.buttonReset.Text = "Restore default settings";
this.buttonReset.UseVisualStyleBackColor = true;
this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click);
//
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(865, 561);
this.Controls.Add(this.buttonReset);
this.Controls.Add(this.labelStatus);
this.Controls.Add(this.tabControlSettings);
this.Controls.Add(this.buttonCancel);
@ -4905,5 +4918,6 @@
private System.Windows.Forms.NumericUpDown numericUpDownToolsBreakPreferBottomHeavy;
private System.Windows.Forms.CheckBox checkBoxToolsBreakPreferBottomHeavy;
private System.Windows.Forms.Label labelToolsBreakBottomHeavyPercent;
private System.Windows.Forms.Button buttonReset;
}
}

View File

@ -31,13 +31,13 @@ namespace Nikse.SubtitleEdit.Forms
private List<string> _wordListNames = new List<string>();
private List<string> _userWordList = new List<string>();
private OcrFixReplaceList _ocrFixReplaceList;
private readonly string _oldVlcLocation;
private readonly string _oldVlcLocationRelative;
private readonly bool _oldListViewShowCps;
private readonly bool _oldListViewShowWpm;
private string _oldVlcLocation;
private string _oldVlcLocationRelative;
private bool _oldListViewShowCps;
private bool _oldListViewShowWpm;
private readonly Dictionary<ShortcutHelper, string> _newShortcuts = new Dictionary<ShortcutHelper, string>();
private List<RulesProfile> _rulesProfiles;
private readonly bool _loading = true;
private bool _loading = true;
private class ComboBoxLanguage
{
@ -102,7 +102,13 @@ namespace Nikse.SubtitleEdit.Forms
InitializeComponent();
UiUtil.FixFonts(this);
UiUtil.FixLargeFonts(this, buttonOK);
Init();
}
public void Init()
{
_loading = true;
labelStatus.Text = string.Empty;
_rulesProfiles = new List<RulesProfile>(Configuration.Settings.General.Profiles);
var gs = Configuration.Settings.General;
@ -121,14 +127,15 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxNetflixQualityCheck.Checked = gs.ShowToolbarNetflixGlyphCheck;
checkBoxHelp.Checked = gs.ShowToolbarHelp;
comboBoxFrameRate.Items.Add((23.976).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((24.0).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((25.0).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((29.97).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((30.00).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((50.00).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((59.94).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add((60.00).ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Clear();
comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(30.00.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(50.00.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture));
comboBoxFrameRate.Items.Add(60.00.ToString(CultureInfo.CurrentCulture));
checkBoxShowFrameRate.Checked = gs.ShowFrameRate;
comboBoxFrameRate.Text = gs.DefaultFrameRate.ToString(CultureInfo.CurrentCulture);
@ -246,7 +253,10 @@ namespace Nikse.SubtitleEdit.Forms
textBoxCustomSearchUrl4.Text = Configuration.Settings.VideoControls.CustomSearchUrl4;
textBoxCustomSearchUrl5.Text = Configuration.Settings.VideoControls.CustomSearchUrl5;
comboBoxFontName.BeginUpdate();
comboBoxSubtitleFont.BeginUpdate();
comboBoxFontName.Items.Clear();
comboBoxSubtitleFont.Items.Clear();
foreach (var x in FontFamily.Families)
{
comboBoxFontName.Items.Add(x.Name);
@ -259,6 +269,8 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
comboBoxFontName.EndUpdate();
comboBoxSubtitleFont.EndUpdate();
var wordListSettings = Configuration.Settings.WordLists;
checkBoxNamesOnline.Checked = wordListSettings.UseOnlineNames;
@ -843,6 +855,7 @@ namespace Nikse.SubtitleEdit.Forms
textBoxBingTokenEndpoint.Text = Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint;
textBoxGoogleTransleApiKey.Text = toolsSettings.GoogleApiV2Key;
buttonReset.Text = Configuration.Settings.Language.Settings.RestoreDefaultSettings;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
@ -1627,7 +1640,7 @@ namespace Nikse.SubtitleEdit.Forms
toolsSettings.AutoBreakLineEndingEarly = checkBoxToolsBreakEarlyLineEnding.Checked;
toolsSettings.AutoBreakUsePixelWidth = checkBoxToolsBreakByPixelWidth.Checked;
toolsSettings.AutoBreakPreferBottomHeavy = checkBoxToolsBreakPreferBottomHeavy.Checked;
toolsSettings.AutoBreakPreferBottomPercent = (double) numericUpDownToolsBreakPreferBottomHeavy.Value;
toolsSettings.AutoBreakPreferBottomPercent = (double)numericUpDownToolsBreakPreferBottomHeavy.Value;
toolsSettings.AutoBreakDashEarly = checkBoxToolsBreakEarlyDash.Checked;
Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = !checkBoxCpsIncludeWhiteSpace.Checked;
@ -3122,5 +3135,15 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked;
numericUpDownToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked;
}
private void buttonReset_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(Configuration.Settings.Language.Settings.RestoreDefaultSettingsMsg, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
Configuration.Settings.Reset();
Init();
}
}
}
}