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

View File

@ -3,6 +3,7 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@ -443,6 +444,7 @@ namespace Nikse.SubtitleEdit.Forms
numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked;
labelAddTime.Enabled = radioButtonJoinAddTime.Checked;
SortAndLoad();
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
}
private void contextMenuStripParts_Opening(object sender, System.ComponentModel.CancelEventArgs e)
@ -581,6 +583,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveUp(listViewParts);
}
@ -591,6 +594,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveDown(listViewParts);
}
@ -601,6 +605,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveToTop(listViewParts);
}
@ -611,6 +616,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
SetSortArrow(listViewParts.Columns[3], SortOrder.None);
MoveToBottom(listViewParts);
}
@ -641,6 +647,25 @@ namespace Nikse.SubtitleEdit.Forms
}
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;
}
}
}
}