Fix progressbar in "Audio to text" on Ubuntu

This commit is contained in:
niksedk 2022-08-30 14:58:43 +02:00
parent 08e7e8ba67
commit f2abd0596f
2 changed files with 25 additions and 8 deletions

View File

@ -12,6 +12,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Vosk; using Vosk;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Nikse.SubtitleEdit.Forms namespace Nikse.SubtitleEdit.Forms
{ {
@ -134,9 +135,7 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
progressBar1.Maximum = 100; ShowProgressBar();
progressBar1.Value = 0;
progressBar1.Visible = true;
var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text); var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);
buttonGenerate.Enabled = false; buttonGenerate.Enabled = false;
buttonDownload.Enabled = false; buttonDownload.Enabled = false;
@ -161,6 +160,16 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} }
private void ShowProgressBar()
{
progressBar1.Maximum = 100;
progressBar1.Value = 0;
progressBar1.Visible = true;
progressBar1.BringToFront();
progressBar1.Refresh();
progressBar1.Top = labelProgress.Bottom + 3;
}
private void GenerateBatch() private void GenerateBatch()
{ {
groupBoxInputFiles.Enabled = false; groupBoxInputFiles.Enabled = false;
@ -172,9 +181,7 @@ namespace Nikse.SubtitleEdit.Forms
var videoFileName = lvi.Text; var videoFileName = lvi.Text;
listViewInputFiles.SelectedIndices.Clear(); listViewInputFiles.SelectedIndices.Clear();
lvi.Selected = true; lvi.Selected = true;
progressBar1.Maximum = 100; ShowProgressBar();
progressBar1.Value = 0;
progressBar1.Visible = true;
var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text); var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);
buttonGenerate.Enabled = false; buttonGenerate.Enabled = false;
buttonDownload.Enabled = false; buttonDownload.Enabled = false;
@ -361,8 +368,8 @@ namespace Nikse.SubtitleEdit.Forms
_filesToDelete.Add(outWaveFile); _filesToDelete.Add(outWaveFile);
var process = GetFfmpegProcess(videoFileName, audioTrackNumber, outWaveFile); var process = GetFfmpegProcess(videoFileName, audioTrackNumber, outWaveFile);
process.Start(); process.Start();
ShowProgressBar();
progressBar1.Style = ProgressBarStyle.Marquee; progressBar1.Style = ProgressBarStyle.Marquee;
progressBar1.Visible = true;
double seconds = 0; double seconds = 0;
buttonCancel.Visible = true; buttonCancel.Visible = true;
try try

View File

@ -106,6 +106,16 @@ namespace Nikse.SubtitleEdit.Forms
TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress); TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
} }
private void ShowProgressBar()
{
progressBar1.Maximum = 100;
progressBar1.Value = 0;
progressBar1.Visible = true;
progressBar1.BringToFront();
progressBar1.Refresh();
progressBar1.Top = labelProgress.Bottom + 3;
}
private void GenerateBatch() private void GenerateBatch()
{ {
groupBoxInputFiles.Enabled = false; groupBoxInputFiles.Enabled = false;
@ -116,7 +126,7 @@ namespace Nikse.SubtitleEdit.Forms
ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2, ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
}; };
progressBar1.Visible = true; ShowProgressBar();
foreach (ListViewItem lvi in listViewInputFiles.Items) foreach (ListViewItem lvi in listViewInputFiles.Items)
{ {
_batchFileNumber++; _batchFileNumber++;