This commit is contained in:
stax76
2023-12-23 10:20:57 +01:00
parent 3e4ea03437
commit 764f00ed3a
6 changed files with 64 additions and 96 deletions

View File

@@ -4,6 +4,11 @@
- Support of the mpv option `title-bar`. - Support of the mpv option `title-bar`.
- Command line parser fix using list options with `-add` suffix. - Command line parser fix using list options with `-add` suffix.
- Fix video being rendered with black line at the bottom. - Fix video being rendered with black line at the bottom.
- The conf file reader/writer detects if the user prefers space before and after the equal sign.
- The portable download includes like the installer debug symbols.
- Setup questions on startup removed.
- Pressing shift while drag and drop (and clipboard import) appends
instead of replaces files in the playlist. mpv supports this as well.
# v7.0.0.4 Beta (2023-12-19) # v7.0.0.4 Beta (2023-12-19)

View File

@@ -153,10 +153,12 @@ public class GuiCommand
public void OpenFromClipboard(IList<string> args) public void OpenFromClipboard(IList<string> args)
{ {
bool append = Control.ModifierKeys == Keys.Shift;
if (System.Windows.Forms.Clipboard.ContainsFileDropList()) if (System.Windows.Forms.Clipboard.ContainsFileDropList())
{ {
string[] files = System.Windows.Forms.Clipboard.GetFileDropList().Cast<string>().ToArray(); string[] files = System.Windows.Forms.Clipboard.GetFileDropList().Cast<string>().ToArray();
Player.LoadFiles(files, false, false); Player.LoadFiles(files, false, append);
} }
else else
{ {
@@ -173,7 +175,7 @@ public class GuiCommand
return; return;
} }
Player.LoadFiles(files.ToArray(), false, false); Player.LoadFiles(files.ToArray(), false, append);
} }
} }

View File

@@ -1,55 +0,0 @@

using System.Windows;
using MpvNet.Windows.WPF;
namespace MpvNet.Windows.Help;
public class WinMpvHelp
{
public static void Setup()
{
if (RegistryHelp.GetString("PathEnvVarCheck") == Folder.Startup ||
RegistryHelp.GetString("Setup") == Folder.Startup ||
App.Settings.StartupFolder == Folder.Startup ||
Folder.Startup.Contains("portable_config"))
return;
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
if (!path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
{
var result = Msg.ShowQuestion("Would you like to add mpv.net to the Path environment variable?" + BR2 +
"This will allow using mpv.net in a console/terminal.", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
Environment.SetEnvironmentVariable("Path",
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path,
EnvironmentVariableTarget.User);
Msg.ShowInfo("mpv.net was added successfully to Path.");
}
else
Msg.ShowInfo("If you want to add mpv.net to the Path environment variable later," + BR +
"you can do so with the context menu (Settings/Setup).");
}
var result2 = Msg.ShowQuestion("Would you like to register video file associations?", MessageBoxButton.YesNo);
if (result2 == MessageBoxResult.Yes)
{
Player.Command("script-message-to mpvnet reg-file-assoc video");
result2 = Msg.ShowQuestion("Would you like to register audio file associations?", MessageBoxButton.YesNo);
if (result2 == MessageBoxResult.Yes)
Player.Command("script-message-to mpvnet reg-file-assoc audio");
}
else
Msg.ShowInfo("If you want to register file associations later," + BR +
"you can do so with the context menu (Settings/Setup).");
App.Settings.StartupFolder = Folder.Startup;
}
}

View File

@@ -20,13 +20,16 @@ namespace MpvNet.Windows.WPF;
public partial class ConfWindow : Window, INotifyPropertyChanged public partial class ConfWindow : Window, INotifyPropertyChanged
{ {
List<Setting> Settings = Conf.LoadConf(Properties.Resources.editor_conf.TrimEnd()); List<Setting> _settings = Conf.LoadConf(Properties.Resources.editor_conf.TrimEnd());
List<ConfItem> ConfItems = new List<ConfItem>(); List<ConfItem> _confItems = new List<ConfItem>();
string InitialContent; string _initialContent;
string ThemeConf = GetThemeConf(); string _themeConf = GetThemeConf();
string? _searchText; string? _searchText;
List<NodeViewModel>? _nodes; List<NodeViewModel>? _nodes;
bool _shown; bool _shown;
int _useSpace;
int _useNoSpace;
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
public ConfWindow() public ConfWindow()
@@ -37,7 +40,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
LoadConf(App.ConfPath); LoadConf(App.ConfPath);
LoadLibplaceboConf(); LoadLibplaceboConf();
LoadSettings(); LoadSettings();
InitialContent = GetCompareString(); _initialContent = GetCompareString();
if (string.IsNullOrEmpty(App.Settings.ConfigEditorSearch)) if (string.IsNullOrEmpty(App.Settings.ConfigEditorSearch))
SearchText = "General:"; SearchText = "General:";
@@ -74,7 +77,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{ {
var rootNode = new TreeNode(); var rootNode = new TreeNode();
foreach (Setting setting in Settings) foreach (Setting setting in _settings)
AddNode(rootNode.Children, setting.Directory!); AddNode(rootNode.Children, setting.Directory!);
_nodes = new NodeViewModel(rootNode).Children; _nodes = new NodeViewModel(rootNode).Children;
@@ -127,14 +130,14 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
void LoadSettings() void LoadSettings()
{ {
foreach (Setting setting in Settings) foreach (Setting setting in _settings)
{ {
setting.StartValue = setting.Value; setting.StartValue = setting.Value;
if (!FilterStrings.Contains(setting.Directory!)) if (!FilterStrings.Contains(setting.Directory!))
FilterStrings.Add(setting.Directory!); FilterStrings.Add(setting.Directory!);
foreach (ConfItem item in ConfItems) foreach (ConfItem item in _confItems)
{ {
if (setting.Name == item.Name && if (setting.Name == item.Name &&
setting.File == item.File && setting.File == item.File &&
@@ -164,7 +167,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
static string GetThemeConf() => Theme.DarkMode + App.DarkTheme + App.LightTheme; static string GetThemeConf() => Theme.DarkMode + App.DarkTheme + App.LightTheme;
string GetCompareString() => string.Join("", Settings.Select(item => item.Name + item.Value).ToArray()); string GetCompareString() => string.Join("", _settings.Select(item => item.Name + item.Value).ToArray());
void LoadConf(string file) void LoadConf(string file)
{ {
@@ -176,9 +179,12 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
bool isSectionItem = false; bool isSectionItem = false;
foreach (string currentLine in File.ReadAllLines(file)) foreach (string it in File.ReadAllLines(file))
{ {
string line = currentLine.Trim(); string line = it.Trim();
if (line.StartsWith("-"))
line = line.TrimStart('-');
if (line == "") if (line == "")
comment += "\r\n"; comment += "\r\n";
@@ -187,7 +193,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
else if (line.StartsWith("[") && line.Contains(']')) else if (line.StartsWith("[") && line.Contains(']'))
{ {
if (!isSectionItem && comment != "" && comment != "\r\n") if (!isSectionItem && comment != "" && comment != "\r\n")
ConfItems.Add(new ConfItem() { _confItems.Add(new ConfItem() {
Comment = comment, File = Path.GetFileNameWithoutExtension(file)}); Comment = comment, File = Path.GetFileNameWithoutExtension(file)});
section = line.Substring(0, line.IndexOf("]") + 1); section = line.Substring(0, line.IndexOf("]") + 1);
@@ -197,7 +203,20 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
else if (line.Contains('=') || Regex.Match(line, "^[\\w-]+$").Success) else if (line.Contains('=') || Regex.Match(line, "^[\\w-]+$").Success)
{ {
if (!line.Contains('=')) if (!line.Contains('='))
line += "=yes"; {
if (line.StartsWith("no-"))
{
line = line.Substring(3);
line += "=no";
}
else
line += "=yes";
}
if (line.Contains(" =") || line.Contains("= "))
_useSpace += 1;
else
_useNoSpace += 1;
ConfItem item = new(); ConfItem item = new();
item.File = Path.GetFileNameWithoutExtension(file); item.File = Path.GetFileNameWithoutExtension(file);
@@ -207,7 +226,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Section = section; item.Section = section;
section = ""; section = "";
if (line.Contains('#') && !line.Contains("'") && !line.Contains("\"")) if (line.Contains('#') && !line.Contains('\'') && !line.Contains('"'))
{ {
item.LineComment = line.Substring(line.IndexOf("#")).Trim(); item.LineComment = line.Substring(line.IndexOf("#")).Trim();
line = line.Substring(0, line.IndexOf("#")).Trim(); line = line.Substring(0, line.IndexOf("#")).Trim();
@@ -231,7 +250,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Name = left; item.Name = left;
item.Value = right; item.Value = right;
ConfItems.Add(item); _confItems.Add(item);
} }
} }
} }
@@ -240,7 +259,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{ {
List<string> pairs = new(); List<string> pairs = new();
foreach (Setting setting in Settings) foreach (Setting setting in _settings)
{ {
if (filename != setting.File) if (filename != setting.File)
continue; continue;
@@ -254,7 +273,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
void LoadLibplaceboConf() void LoadLibplaceboConf()
{ {
foreach (ConfItem item in ConfItems.ToArray()) foreach (ConfItem item in _confItems.ToArray())
if (item.Name == "libplacebo-opts") if (item.Name == "libplacebo-opts")
LoadKeyValueList(item.Value, "libplacebo"); LoadKeyValueList(item.Value, "libplacebo");
} }
@@ -276,7 +295,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Name = left; item.Name = left;
item.Value = right; item.Value = right;
item.File = file; item.File = file;
ConfItems.Add(item); _confItems.Add(item);
} }
} }
@@ -301,8 +320,9 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<string> namesWritten = new List<string>(); List<string> namesWritten = new List<string>();
string equalString = _useSpace > _useNoSpace ? " = " : "=";
foreach (ConfItem item in ConfItems) foreach (ConfItem item in _confItems)
{ {
if (filename != item.File || item.Section != "" || item.IsSectionItem) if (filename != item.File || item.Section != "" || item.IsSectionItem)
continue; continue;
@@ -314,7 +334,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{ {
if (item.Name != "") if (item.Name != "")
{ {
sb.Append(item.Name + " = " + EscapeValue(item.Value)); sb.Append(item.Name + equalString + EscapeValue(item.Value));
if (item.LineComment != "") if (item.LineComment != "")
sb.Append(" " + item.LineComment); sb.Append(" " + item.LineComment);
@@ -325,7 +345,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
} }
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default) else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
{ {
sb.Append(item.Name + " = " + EscapeValue(item.SettingBase.Value!)); sb.Append(item.Name + equalString + EscapeValue(item.SettingBase.Value!));
if (item.LineComment != "") if (item.LineComment != "")
sb.Append(" " + item.LineComment); sb.Append(" " + item.LineComment);
@@ -335,16 +355,16 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
} }
} }
foreach (Setting setting in Settings) foreach (Setting setting in _settings)
{ {
if (filename != setting.File || namesWritten.Contains(setting.Name!)) if (filename != setting.File || namesWritten.Contains(setting.Name!))
continue; continue;
if ((setting.Value ?? "") != setting.Default) if ((setting.Value ?? "") != setting.Default)
sb.AppendLine(setting.Name + " = " + EscapeValue(setting.Value!)); sb.AppendLine(setting.Name + equalString + EscapeValue(setting.Value!));
} }
foreach (ConfItem item in ConfItems) foreach (ConfItem item in _confItems)
{ {
if (filename != item.File || (item.Section == "" && !item.IsSectionItem)) if (filename != item.File || (item.Section == "" && !item.IsSectionItem))
continue; continue;
@@ -360,7 +380,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
if (item.Comment != "") if (item.Comment != "")
sb.Append(item.Comment); sb.Append(item.Comment);
sb.Append(item.Name + " = " + EscapeValue(item.Value)); sb.Append(item.Name + equalString + EscapeValue(item.Value));
if (item.LineComment != "") if (item.LineComment != "")
sb.Append(" " + item.LineComment); sb.Append(" " + item.LineComment);
@@ -415,10 +435,10 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
base.OnClosed(e); base.OnClosed(e);
App.Settings.ConfigEditorSearch = SearchText; App.Settings.ConfigEditorSearch = SearchText;
if (InitialContent == GetCompareString()) if (_initialContent == GetCompareString())
return; return;
foreach (Setting setting in Settings) foreach (Setting setting in _settings)
{ {
if (setting.Name == "libplacebo-opts") if (setting.Name == "libplacebo-opts")
{ {
@@ -430,7 +450,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
File.WriteAllText(Player.ConfPath, GetContent("mpv")); File.WriteAllText(Player.ConfPath, GetContent("mpv"));
File.WriteAllText(App.ConfPath, GetContent("mpvnet")); File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
foreach (Setting it in Settings) foreach (Setting it in _settings)
{ {
if (it.Value != it.StartValue) if (it.Value != it.StartValue)
{ {
@@ -447,7 +467,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
Theme.Init(); Theme.Init();
Theme.UpdateWpfColors(); Theme.UpdateWpfColors();
if (ThemeConf != GetThemeConf()) if (_themeConf != GetThemeConf())
MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info"); MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info");
} }

View File

@@ -1352,14 +1352,8 @@ public partial class MainForm : Form
InitAndBuildContextMenu(); InitAndBuildContextMenu();
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y); Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
GlobalHotkey.RegisterGlobalHotkeys(Handle); GlobalHotkey.RegisterGlobalHotkeys(Handle);
WasShown = true;
StrongReferenceMessenger.Default.Send(new MainWindowIsLoadedMessage()); StrongReferenceMessenger.Default.Send(new MainWindowIsLoadedMessage());
WasShown = true;
TaskHelp.Run(() => {
System.Windows.Application.Current.Dispatcher.BeginInvoke(() => {
WinMpvHelp.Setup();
}, DispatcherPriority.Background);
});
} }
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set(); void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set();
@@ -1448,10 +1442,12 @@ public partial class MainForm : Form
{ {
base.OnDragDrop(e); base.OnDragDrop(e);
bool append = ModifierKeys == Keys.Shift;
if (e.Data!.GetDataPresent(DataFormats.FileDrop)) if (e.Data!.GetDataPresent(DataFormats.FileDrop))
Player.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as string[], true, false); Player.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as string[], true, append);
else if (e.Data.GetDataPresent(DataFormats.Text)) else if (e.Data.GetDataPresent(DataFormats.Text))
Player.LoadFiles(new[] { e.Data.GetData(DataFormats.Text)!.ToString()! }, true, false); Player.LoadFiles(new[] { e.Data.GetData(DataFormats.Text)!.ToString()! }, true, append);
} }
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)

View File

@@ -452,7 +452,7 @@ public class MainPlayer : MpvClient
files.Add(arg); files.Add(arg);
LoadFiles(files.ToArray(), !App.Queue, false || App.Queue); LoadFiles(files.ToArray(), !App.Queue, App.Queue);
if (App.CommandLine.Contains("--shuffle")) if (App.CommandLine.Contains("--shuffle"))
{ {