Add sort mark to join subs - thx Leon :)

Work on #8257
This commit is contained in:
Nikolaj Olsson 2024-04-28 19:09:03 +02:00
parent 443d88d195
commit 0c28e8a0ec
2 changed files with 51 additions and 12 deletions

View File

@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Forms
private long _totalFrames; private long _totalFrames;
private StringBuilder _log; private StringBuilder _log;
private readonly bool _isAssa; private readonly bool _isAssa;
private readonly FfmpegMediaInfo _mediaInfo; private FfmpegMediaInfo _mediaInfo;
private bool _promptFFmpegParameters; private bool _promptFFmpegParameters;
private readonly bool _mpvOn; private readonly bool _mpvOn;
private readonly string _mpvSubtitleFileName; private readonly string _mpvSubtitleFileName;
@ -248,7 +248,6 @@ namespace Nikse.SubtitleEdit.Forms
UiUtil.FixLargeFonts(this, buttonGenerate); UiUtil.FixLargeFonts(this, buttonGenerate);
UiUtil.FixFonts(this, 2000); UiUtil.FixFonts(this, 2000);
_mediaInfo = FfmpegMediaInfo.Parse(inputVideoFileName); _mediaInfo = FfmpegMediaInfo.Parse(inputVideoFileName);
if (_videoInfo != null && _videoInfo.TotalSeconds > 0) if (_videoInfo != null && _videoInfo.TotalSeconds > 0)
@ -459,6 +458,8 @@ namespace Nikse.SubtitleEdit.Forms
labelPleaseWait.Text = $"{index + 1}/{_batchVideoAndSubList.Count} - {LanguageSettings.Current.General.PleaseWait}"; labelPleaseWait.Text = $"{index + 1}/{_batchVideoAndSubList.Count} - {LanguageSettings.Current.General.PleaseWait}";
var videoAndSub = _batchVideoAndSubList[index]; var videoAndSub = _batchVideoAndSubList[index];
_mediaInfo = FfmpegMediaInfo.Parse(videoAndSub.VideoFileName);
_videoInfo = UiUtil.GetVideoInfo(videoAndSub.VideoFileName); _videoInfo = UiUtil.GetVideoInfo(videoAndSub.VideoFileName);
if (useSourceResolution) if (useSourceResolution)
{ {
@ -2162,7 +2163,16 @@ namespace Nikse.SubtitleEdit.Forms
item.SubtitleFileFileSizeInBytes = new FileInfo(subFileName).Length; item.SubtitleFileFileSizeInBytes = new FileInfo(subFileName).Length;
} }
var width = 0;
var height = 0;
var mediaInfo = FfmpegMediaInfo.Parse(fileName);
if (mediaInfo.VideoWidth > 0 && mediaInfo.VideoHeight > 0)
{
width = mediaInfo.VideoWidth;
height = mediaInfo.VideoHeight;
}
else
{
var vInfo = new VideoInfo { Success = false }; var vInfo = new VideoInfo { Success = false };
if (fileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)) if (fileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase))
{ {
@ -2178,9 +2188,13 @@ namespace Nikse.SubtitleEdit.Forms
vInfo = UiUtil.GetVideoInfo(fileName); vInfo = UiUtil.GetVideoInfo(fileName);
} }
width = vInfo.Width;
height = vInfo.Height;
}
var listViewItem = new ListViewItem(fileName); var listViewItem = new ListViewItem(fileName);
listViewItem.Tag = item; listViewItem.Tag = item;
listViewItem.SubItems.Add($"{vInfo.Width}x{vInfo.Height}"); listViewItem.SubItems.Add($"{width}x{height}");
var s = Utilities.FormatBytesToDisplayFileSize(item.VideoFileSizeInBytes); var s = Utilities.FormatBytesToDisplayFileSize(item.VideoFileSizeInBytes);
listViewItem.SubItems.Add(s); listViewItem.SubItems.Add(s);
listViewItem.SubItems.Add(Path.GetFileName(item.SubtitleFileName)); listViewItem.SubItems.Add(Path.GetFileName(item.SubtitleFileName));

View File

@ -3,6 +3,7 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -443,6 +444,7 @@ namespace Nikse.SubtitleEdit.Forms
numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked; numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked;
labelAddTime.Enabled = radioButtonJoinAddTime.Checked; labelAddTime.Enabled = radioButtonJoinAddTime.Checked;
SortAndLoad(); SortAndLoad();
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
} }
private void contextMenuStripParts_Opening(object sender, System.ComponentModel.CancelEventArgs e) private void contextMenuStripParts_Opening(object sender, System.ComponentModel.CancelEventArgs e)
@ -581,6 +583,7 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveUp(listViewParts); MoveUp(listViewParts);
} }
@ -591,6 +594,7 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveDown(listViewParts); MoveDown(listViewParts);
} }
@ -601,6 +605,7 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveToTop(listViewParts); MoveToTop(listViewParts);
} }
@ -611,6 +616,7 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveToBottom(listViewParts); MoveToBottom(listViewParts);
} }
@ -641,6 +647,25 @@ namespace Nikse.SubtitleEdit.Forms
} }
lv.Sort(); lv.Sort();
SetSortArrow(listViewParts.Columns[e.Column], sorter.Descending ? SortOrder.Descending : SortOrder.Ascending);
}
private static void SetSortArrow(ColumnHeader head, SortOrder order)
{
const string ascArrow = " ▲";
const string descArrow = " ▼";
// remove arrow
if (head.Text.EndsWith(ascArrow) || head.Text.EndsWith(descArrow))
head.Text = head.Text.Substring(0, head.Text.Length - 2);
// add arrow
switch (order)
{
case SortOrder.Ascending: head.Text += ascArrow; break;
case SortOrder.Descending: head.Text += descArrow; break;
}
} }
} }
} }