From 24219eed8c025bb0cdaac4ef973837c5f7c18036 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 19 Aug 2023 20:59:58 +0200 Subject: [PATCH] Work on plugin update check --- LanguageBaseEnglish.xml | 3 + src/libse/Common/Settings.cs | 47 +--------- src/ui/Forms/CheckForUpdates.Designer.cs | 79 ++++++++-------- src/ui/Forms/CheckForUpdates.cs | 113 +++++++++++++++++------ src/ui/Forms/Main.cs | 34 ++++--- src/ui/Forms/PluginsGet.cs | 14 ++- src/ui/Logic/CheckForUpdatesHelper.cs | 30 +++++- src/ui/Logic/Language.cs | 3 + src/ui/Logic/LanguageDeserializer.cs | 9 ++ src/ui/Logic/LanguageStructure.cs | 3 + 10 files changed, 202 insertions(+), 133 deletions(-) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index f27aa2451..2f688d4d8 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -542,6 +542,9 @@ We leverage the intrinsic rhythm of the image. New version available! Go to download page Don't update + {0} plugins have an updates - + One plugin has an update - + update Choose audio track diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index 6254d3bf2..fa7bbb7f3 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -3397,51 +3397,8 @@ $HorzAlign = Center var mergeLinesShorterThan = listNode.SelectSingleNode("MergeLinesShorterThan")?.InnerText; var minimumMillisecondsBetweenLines = listNode.SelectSingleNode("MinimumMillisecondsBetweenLines")?.InnerText; - var dialogStyle = DialogType.DashBothLinesWithSpace; - if (listNode.SelectSingleNode("DialogStyle") == null || !Enum.IsDefined(typeof(DialogType), listNode.SelectSingleNode("DialogStyle").InnerText)) - { //TODO: Remove after 2022 - if (listNode.SelectSingleNode("Name") != null) - { - var lookup = new List(); - GeneralSettings.AddExtraProfiles(lookup); - var match = lookup.Find(LookupProfile => LookupProfile.Name == listNode.SelectSingleNode("Name").InnerText); - if (match != null) - { - dialogStyle = match.DialogStyle; // update style when upgrading from 3.5.13 or below - } - else - { - dialogStyle = DialogType.DashBothLinesWithSpace; - } - } - } - else - { - dialogStyle = (DialogType)Enum.Parse(typeof(DialogType), listNode.SelectSingleNode("DialogStyle")?.InnerText); - } - - var continuationStyle = ContinuationStyle.NoneLeadingTrailingDots; - if (listNode.SelectSingleNode("ContinuationStyle") == null || !Enum.IsDefined(typeof(ContinuationStyle), listNode.SelectSingleNode("ContinuationStyle").InnerText)) - { //TODO: Remove after 2022 - if (listNode.SelectSingleNode("Name") != null) - { - var lookup = new List(); - GeneralSettings.AddExtraProfiles(lookup); - var match = lookup.Find(LookupProfile => LookupProfile.Name == listNode.SelectSingleNode("Name").InnerText); - if (match != null) - { - continuationStyle = match.ContinuationStyle; // update style when upgrading from 3.5.13 or below - } - else - { - continuationStyle = ContinuationStyle.NoneLeadingTrailingDots; - } - } - } - else - { - continuationStyle = (ContinuationStyle)Enum.Parse(typeof(ContinuationStyle), listNode.SelectSingleNode("ContinuationStyle")?.InnerText); - } + var dialogStyle = (DialogType)Enum.Parse(typeof(DialogType), listNode.SelectSingleNode("DialogStyle")?.InnerText); + var continuationStyle = (ContinuationStyle)Enum.Parse(typeof(ContinuationStyle), listNode.SelectSingleNode("ContinuationStyle")?.InnerText); settings.General.Profiles.Add(new RulesProfile { diff --git a/src/ui/Forms/CheckForUpdates.Designer.cs b/src/ui/Forms/CheckForUpdates.Designer.cs index f8510d9b9..fe8a5a6e5 100644 --- a/src/ui/Forms/CheckForUpdates.Designer.cs +++ b/src/ui/Forms/CheckForUpdates.Designer.cs @@ -32,13 +32,13 @@ namespace Nikse.SubtitleEdit.Forms { this.components = new System.ComponentModel.Container(); this.labelStatus = new System.Windows.Forms.Label(); - this.textBoxChangeLog = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.buttonOK = new System.Windows.Forms.Button(); this.buttonDownloadAndInstall = new System.Windows.Forms.Button(); this.timerCheckForUpdates = new System.Windows.Forms.Timer(this.components); this.buttonDontCheckUpdates = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.linkLabelUpdatePlugins = new System.Windows.Forms.LinkLabel(); + this.labelPluginsHaveUpdates = new System.Windows.Forms.Label(); + this.textBoxChangeLog = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.SuspendLayout(); // // labelStatus @@ -47,23 +47,9 @@ namespace Nikse.SubtitleEdit.Forms this.labelStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelStatus.Location = new System.Drawing.Point(10, 15); this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(41, 13); + this.labelStatus.Size = new System.Drawing.Size(70, 13); this.labelStatus.TabIndex = 3; - this.labelStatus.Text = "label1"; - // - // textBoxChangeLog - // - this.textBoxChangeLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxChangeLog.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.textBoxChangeLog.Location = new System.Drawing.Point(13, 31); - this.textBoxChangeLog.Multiline = true; - this.textBoxChangeLog.Name = "textBoxChangeLog"; - this.textBoxChangeLog.ReadOnly = true; - this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxChangeLog.Size = new System.Drawing.Size(618, 106); - this.textBoxChangeLog.TabIndex = 4; + this.labelStatus.Text = "labelStatus"; // // buttonOK // @@ -105,32 +91,49 @@ namespace Nikse.SubtitleEdit.Forms this.buttonDontCheckUpdates.UseVisualStyleBackColor = true; this.buttonDontCheckUpdates.Click += new System.EventHandler(this.buttonDontCheckUpdates_Click); // - // label1 + // linkLabelUpdatePlugins // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 144); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(35, 13); - this.label1.TabIndex = 5; - this.label1.Text = "label1"; + this.linkLabelUpdatePlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.linkLabelUpdatePlugins.AutoSize = true; + this.linkLabelUpdatePlugins.Location = new System.Drawing.Point(182, 150); + this.linkLabelUpdatePlugins.Name = "linkLabelUpdatePlugins"; + this.linkLabelUpdatePlugins.Size = new System.Drawing.Size(63, 13); + this.linkLabelUpdatePlugins.TabIndex = 6; + this.linkLabelUpdatePlugins.TabStop = true; + this.linkLabelUpdatePlugins.Text = "update now"; + this.linkLabelUpdatePlugins.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelUpdatePlugins_LinkClicked); // - // linkLabel1 + // labelPluginsHaveUpdates // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(55, 143); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(55, 13); - this.linkLabel1.TabIndex = 6; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "linkLabel1"; + this.labelPluginsHaveUpdates.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelPluginsHaveUpdates.AutoSize = true; + this.labelPluginsHaveUpdates.Location = new System.Drawing.Point(13, 150); + this.labelPluginsHaveUpdates.Name = "labelPluginsHaveUpdates"; + this.labelPluginsHaveUpdates.Size = new System.Drawing.Size(169, 13); + this.labelPluginsHaveUpdates.TabIndex = 5; + this.labelPluginsHaveUpdates.Text = "X plugins have updates available -"; + // + // textBoxChangeLog + // + this.textBoxChangeLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxChangeLog.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.textBoxChangeLog.Location = new System.Drawing.Point(13, 32); + this.textBoxChangeLog.Multiline = true; + this.textBoxChangeLog.Name = "textBoxChangeLog"; + this.textBoxChangeLog.ReadOnly = true; + this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxChangeLog.Size = new System.Drawing.Size(618, 106); + this.textBoxChangeLog.TabIndex = 4; // // CheckForUpdates // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(643, 201); - this.Controls.Add(this.linkLabel1); - this.Controls.Add(this.label1); + this.Controls.Add(this.linkLabelUpdatePlugins); + this.Controls.Add(this.labelPluginsHaveUpdates); this.Controls.Add(this.buttonDontCheckUpdates); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonDownloadAndInstall); @@ -157,7 +160,7 @@ namespace Nikse.SubtitleEdit.Forms private System.Windows.Forms.Button buttonDownloadAndInstall; private System.Windows.Forms.Timer timerCheckForUpdates; private System.Windows.Forms.Button buttonDontCheckUpdates; - private Label label1; - private LinkLabel linkLabel1; + private LinkLabel linkLabelUpdatePlugins; + private Label labelPluginsHaveUpdates; } } \ No newline at end of file diff --git a/src/ui/Forms/CheckForUpdates.cs b/src/ui/Forms/CheckForUpdates.cs index c945bd9c4..9e0927b19 100644 --- a/src/ui/Forms/CheckForUpdates.cs +++ b/src/ui/Forms/CheckForUpdates.cs @@ -13,6 +13,8 @@ namespace Nikse.SubtitleEdit.Forms private readonly bool _performCheckOnShown = true; private readonly Main _mainForm; + public bool UpdatePlugins { get; set; } + public CheckForUpdates(Main mainForm) { UiUtil.PreInitialize(this); @@ -36,6 +38,9 @@ namespace Nikse.SubtitleEdit.Forms buttonDontCheckUpdates.Text = LanguageSettings.Current.CheckForUpdates.NoUpdates; buttonDontCheckUpdates.Visible = false; + labelPluginsHaveUpdates.Visible = false; + linkLabelUpdatePlugins.Visible = false; + Location = new System.Drawing.Point(_mainForm.Location.X + (_mainForm.Width / 2) - (Width / 2), _mainForm.Location.Y + (_mainForm.Height / 2) - (Height / 2) - 200); } @@ -48,7 +53,7 @@ namespace Nikse.SubtitleEdit.Forms _mainForm = mainForm; _updatesHelper = checkForUpdatesHelper; InitLanguage(); - ShowAvailableUpdate(true); + ShowAvailableUpdate(); _performCheckOnShown = false; UiUtil.FixLargeFonts(this, buttonOK); } @@ -72,7 +77,7 @@ namespace Nikse.SubtitleEdit.Forms _updatesHelper = new CheckForUpdatesHelper(); Application.DoEvents(); Refresh(); - _updatesHelper.CheckForUpdates(); + _updatesHelper.CheckForUpdates(true); timerCheckForUpdates.Start(); buttonOK.Focus(); @@ -96,19 +101,9 @@ namespace Nikse.SubtitleEdit.Forms else if (_updatesHelper.Done) { timerCheckForUpdates.Stop(); - if (_updatesHelper.IsUpdateAvailable()) - { - ShowAvailableUpdate(false); - } - else - { - labelStatus.Text = LanguageSettings.Current.CheckForUpdates.CheckingForUpdatesNoneAvailable; - SetLargeSize(); - textBoxChangeLog.Text = _updatesHelper.LatestChangeLog; - textBoxChangeLog.Visible = true; - buttonOK.Visible = true; - } + ShowAvailableUpdate(); } + _seconds += timerCheckForUpdates.Interval / TimeCode.BaseUnit; if (buttonDownloadAndInstall.Visible) @@ -121,28 +116,81 @@ namespace Nikse.SubtitleEdit.Forms } } - private void SetLargeSize() + private void ShowAvailableUpdate() { - Height = 600; - MinimumSize = new System.Drawing.Size(500, 400); - } + //TODO: clean this method a little up - private void ShowAvailableUpdate(bool fromAutoCheck) - { - SetLargeSize(); - textBoxChangeLog.Text = _updatesHelper.LatestChangeLog; - textBoxChangeLog.Visible = true; - labelStatus.Text = LanguageSettings.Current.CheckForUpdates.CheckingForUpdatesNewVersion; - buttonDownloadAndInstall.Visible = true; - buttonOK.Visible = true; - if (Configuration.Settings.General.CheckForUpdates && fromAutoCheck) + var hideChangeLog = !_updatesHelper.ManualCheck; + if (_updatesHelper.IsNewSubtitleEditAvailable()) { - buttonDontCheckUpdates.Visible = true; + hideChangeLog = false; + } + + if (_updatesHelper.PluginUpdates > 0) + { + if (_updatesHelper.PluginUpdates == 1) + { + labelPluginsHaveUpdates.Text = LanguageSettings.Current.CheckForUpdates.OnePluginsHasAnUpdate; + } + else + { + labelPluginsHaveUpdates.Text = string.Format(LanguageSettings.Current.CheckForUpdates.XPluginsHasAnUpdate, _updatesHelper.PluginUpdates); + } + + linkLabelUpdatePlugins.Text = LanguageSettings.Current.CheckForUpdates.Update; + labelPluginsHaveUpdates.Visible = true; + linkLabelUpdatePlugins.Visible = true; + + if (hideChangeLog) + { + MinimizeBox = false; + MaximizeBox = false; + FormBorderStyle = FormBorderStyle.FixedDialog; + labelStatus.Visible = false; + var w = linkLabelUpdatePlugins.Right + 75; + var h = 120; + MinimumSize = new System.Drawing.Size(w, h); + Height = h; + Width = w; + } + + linkLabelUpdatePlugins.Left = labelPluginsHaveUpdates.Right - 2; + linkLabelUpdatePlugins.BringToFront(); } else { - buttonDontCheckUpdates.Visible = false; - buttonDownloadAndInstall.Left = buttonOK.Left - 6 - buttonDownloadAndInstall.Width; + labelPluginsHaveUpdates.Visible = false; + linkLabelUpdatePlugins.Visible = false; + textBoxChangeLog.Height += 14; + } + + if (!hideChangeLog) + { + Height = 600; + MinimumSize = new System.Drawing.Size(500, 400); + } + + buttonDownloadAndInstall.Visible = _updatesHelper.IsNewSubtitleEditAvailable(); + + if (_updatesHelper.IsNewSubtitleEditAvailable() || _updatesHelper.ManualCheck) + { + textBoxChangeLog.Text = _updatesHelper.LatestChangeLog; + textBoxChangeLog.Visible = true; + labelStatus.Text = LanguageSettings.Current.CheckForUpdates.CheckingForUpdatesNewVersion; + buttonOK.Visible = true; + if (_updatesHelper.IsNewSubtitleEditAvailable()) + { + buttonDontCheckUpdates.Visible = true; + } + else + { + buttonDontCheckUpdates.Visible = false; + buttonDownloadAndInstall.Left = buttonOK.Left - 6 - buttonDownloadAndInstall.Width; + } + } + else + { + textBoxChangeLog.Visible = false; } } @@ -157,5 +205,10 @@ namespace Nikse.SubtitleEdit.Forms DialogResult = DialogResult.Cancel; } + private void linkLabelUpdatePlugins_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + UpdatePlugins = true; + DialogResult = DialogResult.OK; + } } } diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index c8c619b71..03ffdb158 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -1,4 +1,5 @@ using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core.AudioToText; using Nikse.SubtitleEdit.Core.BluRaySup; using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.ContainerFormats; @@ -15,6 +16,7 @@ using Nikse.SubtitleEdit.Core.SpellCheck; using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Core.VobSub; using Nikse.SubtitleEdit.Forms.Assa; +using Nikse.SubtitleEdit.Forms.AudioToText; using Nikse.SubtitleEdit.Forms.FormatProperties; using Nikse.SubtitleEdit.Forms.Networking; using Nikse.SubtitleEdit.Forms.Ocr; @@ -23,6 +25,7 @@ using Nikse.SubtitleEdit.Forms.SeJobs; using Nikse.SubtitleEdit.Forms.ShotChanges; using Nikse.SubtitleEdit.Forms.Styles; using Nikse.SubtitleEdit.Forms.Translate; +using Nikse.SubtitleEdit.Forms.VTT; using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic.CommandLineConvert; using Nikse.SubtitleEdit.Logic.Networking; @@ -43,13 +46,9 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.AudioToText; -using Nikse.SubtitleEdit.Forms.AudioToText; -using Nikse.SubtitleEdit.Forms.VTT; -using Nikse.SubtitleEdit.Logic.Plugins; using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper; -using Timer = System.Windows.Forms.Timer; using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox; +using Timer = System.Windows.Forms.Timer; namespace Nikse.SubtitleEdit.Forms { @@ -25315,7 +25314,7 @@ namespace Nikse.SubtitleEdit.Forms else if (Configuration.Settings.General.CheckForUpdates && Configuration.Settings.General.LastCheckForUpdates < DateTime.Now.AddDays(-5)) { _checkForUpdatesHelper = new CheckForUpdatesHelper(); - _checkForUpdatesHelper.CheckForUpdates(); + _checkForUpdatesHelper.CheckForUpdates(false); _timerCheckForUpdates = new Timer(); _timerCheckForUpdates.Interval = 7000; _timerCheckForUpdates.Tick += TimerCheckForUpdatesTick; @@ -25713,10 +25712,7 @@ namespace Nikse.SubtitleEdit.Forms _timerCheckForUpdates.Stop(); if (_checkForUpdatesHelper.IsUpdateAvailable()) { - using (var form = new CheckForUpdates(this, _checkForUpdatesHelper)) - { - form.ShowDialog(this); - } + ShowCheckForUpdates(); } _checkForUpdatesHelper = null; @@ -33130,12 +33126,26 @@ namespace Nikse.SubtitleEdit.Forms // ignore } + ShowCheckForUpdates(); + + Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; + } + + private void ShowCheckForUpdates() + { using (var form = new CheckForUpdates(this)) { form.ShowDialog(this); - } + if (form.UpdatePlugins) + { + using (var formGetPlugins = new PluginsGet()) + { + formGetPlugins.UpdateAll = true; + formGetPlugins.ShowDialog(this); + } - Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; + } + } } private void setVideoOffsetToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/src/ui/Forms/PluginsGet.cs b/src/ui/Forms/PluginsGet.cs index f205f59b3..137be2b05 100644 --- a/src/ui/Forms/PluginsGet.cs +++ b/src/ui/Forms/PluginsGet.cs @@ -60,10 +60,8 @@ namespace Nikse.SubtitleEdit.Forms _cancellationTokenSource = new CancellationTokenSource(); } - private static string GetPluginXmlFileUrl() - { - return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; - } + public static string PluginXmlFileUrl = "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; + public bool UpdateAll { get; set; } private static string GetPluginFolder() { @@ -111,7 +109,7 @@ namespace Nikse.SubtitleEdit.Forms _downloadList = new List(); listViewGetPlugins.BeginUpdate(); _updateAllListUrls = new List(); - var onlinePluginInfo = new OnlinePluginMetadataProvider(GetPluginXmlFileUrl()); + var onlinePluginInfo = new OnlinePluginMetadataProvider(PluginXmlFileUrl); _downloadList = onlinePluginInfo.GetPlugins().ToList(); LoadAvailablePlugins(installedPlugins, _downloadList); ShowAvailablePlugins(); @@ -349,6 +347,12 @@ namespace Nikse.SubtitleEdit.Forms { GetAndShowAllPluginInfo(); PluginsGet_ResizeEnd(sender, e); + + if (UpdateAll) + { + buttonUpdateAll.Visible = false; + buttonUpdateAll_Click(sender, e); + } } private void buttonRemove_Click(object sender, EventArgs e) diff --git a/src/ui/Logic/CheckForUpdatesHelper.cs b/src/ui/Logic/CheckForUpdatesHelper.cs index b7958e292..9db98a2ff 100644 --- a/src/ui/Logic/CheckForUpdatesHelper.cs +++ b/src/ui/Logic/CheckForUpdatesHelper.cs @@ -5,6 +5,8 @@ using System.Text; using System.Text.RegularExpressions; using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.Http; +using Nikse.SubtitleEdit.Forms; +using Nikse.SubtitleEdit.Logic.Plugins; namespace Nikse.SubtitleEdit.Logic { @@ -19,8 +21,10 @@ namespace Nikse.SubtitleEdit.Logic private int _successCount; public string Error { get; set; } + public int PluginUpdates { get; set; } public bool Done => _successCount == 1; + public bool ManualCheck { get; set; } public string LatestVersionNumber { get; set; } public string LatestChangeLog { get; set; } @@ -89,8 +93,10 @@ namespace Nikse.SubtitleEdit.Logic return sb.ToString(); } - public void CheckForUpdates() + public void CheckForUpdates(bool manualCheck) { + ManualCheck = manualCheck; + try { using (var httpClient = DownloaderFactory.MakeHttpClient()) @@ -98,6 +104,14 @@ namespace Nikse.SubtitleEdit.Logic _changeLog = httpClient.GetStringAsync(ChangeLogUrl).Result; } + var installedPlugins = new InstalledPluginMetadataProvider().GetPlugins(); + if (installedPlugins.Count > 0) + { + var onlinePlugins = new OnlinePluginMetadataProvider(PluginsGet.PluginXmlFileUrl).GetPlugins(); + var updates = PluginUpdateChecker.GetAvailableUpdates(installedPlugins, onlinePlugins.ToArray()); + PluginUpdates = updates.Count; + } + LatestChangeLog = GetLatestChangeLog(_changeLog); LatestVersionNumber = GetLatestVersionNumber(LatestChangeLog); _successCount = 1; @@ -120,13 +134,23 @@ namespace Nikse.SubtitleEdit.Logic try { - //string[] currentVersionInfo = "3.3.14".Split('.'); // for testing... - return Version.Parse(LatestVersionNumber) > Version.Parse(Utilities.AssemblyVersion); + if (PluginUpdates > 0) + { + return true; + } + + return IsNewSubtitleEditAvailable(); } catch { return false; } } + + public bool IsNewSubtitleEditAvailable() + { + //string[] currentVersionInfo = "3.3.14".Split('.'); // for testing... + return Version.Parse(LatestVersionNumber) > Version.Parse(Utilities.AssemblyVersion); + } } } diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 65a571113..d82d7c32a 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -744,6 +744,9 @@ namespace Nikse.SubtitleEdit.Logic CheckingForUpdatesNewVersion = "New version available!", InstallUpdate = "Go to download page", NoUpdates = "Don't update", + OnePluginsHasAnUpdate = "One plugin has an update -", + XPluginsHasAnUpdate = "{0} plugins have an updates -", + Update = "update", }; ChooseAudioTrack = new LanguageStructure.ChooseAudioTrack diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index 4a645a19f..ee6a6bfd3 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -1420,6 +1420,15 @@ namespace Nikse.SubtitleEdit.Logic case "CheckForUpdates/NoUpdates": language.CheckForUpdates.NoUpdates = reader.Value; break; + case "CheckForUpdates/XPluginsHasAnUpdate": + language.CheckForUpdates.XPluginsHasAnUpdate = reader.Value; + break; + case "CheckForUpdates/OnePluginsHasAnUpdate": + language.CheckForUpdates.OnePluginsHasAnUpdate = reader.Value; + break; + case "CheckForUpdates/Update": + language.CheckForUpdates.Update = reader.Value; + break; case "ChooseAudioTrack/Title": language.ChooseAudioTrack.Title = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 02b2b1858..115e39627 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -567,6 +567,9 @@ public string CheckingForUpdatesNewVersion { get; set; } public string InstallUpdate { get; set; } public string NoUpdates { get; set; } + public string XPluginsHasAnUpdate { get; set; } + public string OnePluginsHasAnUpdate { get; set; } + public string Update { get; set; } } public class ChooseAudioTrack