misc
This commit is contained in:
@@ -8,14 +8,10 @@ public class WinMpvHelp
|
||||
{
|
||||
public static void Setup()
|
||||
{
|
||||
string dir = RegistryHelp.GetString("PathEnvVarCheck"); // backward compatibility
|
||||
if (RegistryHelp.GetString("PathEnvVarCheck") == Folder.Startup ||
|
||||
RegistryHelp.GetString("Setup") == Folder.Startup ||
|
||||
App.Settings.StartupFolder == Folder.Startup)
|
||||
|
||||
if (dir == Folder.Startup)
|
||||
return;
|
||||
|
||||
dir = RegistryHelp.GetString("Setup");
|
||||
|
||||
if (dir == Folder.Startup)
|
||||
return;
|
||||
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
|
||||
@@ -53,6 +49,6 @@ public class WinMpvHelp
|
||||
Msg.ShowInfo("If you want to register file associations later," + BR +
|
||||
"you can do so with the context menu (Settings/Setup).");
|
||||
|
||||
RegistryHelp.SetString("Setup", Folder.Startup);
|
||||
App.Settings.StartupFolder = Folder.Startup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ url = https://mpv.io/manual/master/#options-input-ipc-server
|
||||
name = language
|
||||
file = mpvnet
|
||||
default = system
|
||||
directory = UI
|
||||
directory = Appearance
|
||||
help = User interface display language.\nmpv.net must be restarted after a change.\nInterested joining our translation team?:
|
||||
url = https://app.transifex.com/stax76/teams/
|
||||
option = system
|
||||
@@ -765,7 +765,7 @@ option = german
|
||||
name = dark-mode
|
||||
file = mpvnet
|
||||
default = always
|
||||
directory = UI
|
||||
directory = Appearance
|
||||
help = Changes between a light and dark theme.\nmpv.net must be restarted after a change.\nmpv.net specific option.
|
||||
option = always
|
||||
option = system Available on Windows 10 or higher
|
||||
@@ -773,13 +773,13 @@ option = never
|
||||
|
||||
name = dark-theme
|
||||
file = mpvnet
|
||||
directory = UI
|
||||
directory = Appearance
|
||||
url = https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md#color-theme
|
||||
help = Color theme used in dark mode.\nmpv.net must be restarted after a change.\nmpv.net specific option. Default: dark
|
||||
|
||||
name = light-theme
|
||||
file = mpvnet
|
||||
directory = UI
|
||||
directory = Appearance
|
||||
url = https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md#color-theme
|
||||
help = Color theme used in light mode.\nmpv.net must be restarted after a change.\nmpv.net specific option. Default: light
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
List<Setting> Settings = Conf.LoadConf(Properties.Resources.editor_conf.TrimEnd());
|
||||
List<ConfItem> ConfItems = new List<ConfItem>();
|
||||
public ObservableCollection<string> FilterStrings { get; } = new();
|
||||
string InitialContent;
|
||||
string ThemeConf = GetThemeConf();
|
||||
string? _searchText;
|
||||
List<NodeViewModel>? _nodes;
|
||||
bool _shown;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public ConfWindow()
|
||||
@@ -51,6 +51,8 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
node.IsExpanded = true;
|
||||
}
|
||||
|
||||
public ObservableCollection<string> FilterStrings { get; } = new();
|
||||
|
||||
public Theme? Theme => Theme.Current;
|
||||
|
||||
public string SearchText
|
||||
@@ -162,64 +164,6 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
|
||||
static string GetThemeConf() => Theme.DarkMode + App.DarkTheme + App.LightTheme;
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
App.Settings.ConfigEditorSearch = SearchText;
|
||||
|
||||
if (InitialContent == GetCompareString())
|
||||
return;
|
||||
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
if (setting.Name == "libplacebo-opts")
|
||||
{
|
||||
setting.Value = GetKeyValueContent("libplacebo");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(Player.ConfPath, GetContent("mpv"));
|
||||
File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
|
||||
|
||||
foreach (Setting it in Settings)
|
||||
{
|
||||
if (it.Value != it.StartValue)
|
||||
{
|
||||
if (it.File == "mpv")
|
||||
{
|
||||
Player.ProcessProperty(it.Name, it.Value);
|
||||
Player.SetPropertyString(it.Name!, it.Value!);
|
||||
}
|
||||
else if (it.File == "mpvnet")
|
||||
App.ProcessProperty(it.Name ?? "", it.Value ?? "", true);
|
||||
}
|
||||
}
|
||||
|
||||
Theme.Init();
|
||||
Theme.UpdateWpfColors();
|
||||
|
||||
if (ThemeConf != GetThemeConf())
|
||||
MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info");
|
||||
}
|
||||
|
||||
bool _shown;
|
||||
|
||||
protected override void OnContentRendered(EventArgs e)
|
||||
{
|
||||
base.OnContentRendered(e);
|
||||
|
||||
if (_shown)
|
||||
return;
|
||||
|
||||
_shown = true;
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(() => {
|
||||
SearchControl.SearchTextBox.SelectAll();
|
||||
},
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
string GetCompareString() => string.Join("", Settings.Select(item => item.Name + item.Value).ToArray());
|
||||
|
||||
void LoadConf(string file)
|
||||
@@ -466,6 +410,47 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
i.Update();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
App.Settings.ConfigEditorSearch = SearchText;
|
||||
|
||||
if (InitialContent == GetCompareString())
|
||||
return;
|
||||
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
if (setting.Name == "libplacebo-opts")
|
||||
{
|
||||
setting.Value = GetKeyValueContent("libplacebo");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(Player.ConfPath, GetContent("mpv"));
|
||||
File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
|
||||
|
||||
foreach (Setting it in Settings)
|
||||
{
|
||||
if (it.Value != it.StartValue)
|
||||
{
|
||||
if (it.File == "mpv")
|
||||
{
|
||||
Player.ProcessProperty(it.Name, it.Value);
|
||||
Player.SetPropertyString(it.Name!, it.Value!);
|
||||
}
|
||||
else if (it.File == "mpvnet")
|
||||
App.ProcessProperty(it.Name ?? "", it.Value ?? "", true);
|
||||
}
|
||||
}
|
||||
|
||||
Theme.Init();
|
||||
Theme.UpdateWpfColors();
|
||||
|
||||
if (ThemeConf != GetThemeConf())
|
||||
MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info");
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
@@ -480,9 +465,22 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string? name = null)
|
||||
{
|
||||
protected void OnPropertyChanged([CallerMemberName] string? name = null) =>
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
|
||||
protected override void OnContentRendered(EventArgs e)
|
||||
{
|
||||
base.OnContentRendered(e);
|
||||
|
||||
if (_shown)
|
||||
return;
|
||||
|
||||
_shown = true;
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(() => {
|
||||
SearchControl.SearchTextBox.SelectAll();
|
||||
},
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
||||
|
||||
@@ -48,8 +48,7 @@ public partial class MainForm : Form
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Environment.OSVersion.Version >= new Version(10, 0, 18985) && Theme.DarkMode)
|
||||
DwmSetWindowAttribute(Handle, 20, new[] { 1 }, 4); // DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
||||
UpdateDarkMode();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -125,6 +124,12 @@ public partial class MainForm : Form
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDarkMode()
|
||||
{
|
||||
if (Environment.OSVersion.Version >= new Version(10, 0, 18985))
|
||||
DwmSetWindowAttribute(Handle, 20, new[] { Theme.DarkMode ? 1 : 0 }, 4); // DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
||||
}
|
||||
|
||||
void Player_ClientMessage(string[] args)
|
||||
{
|
||||
if (Command.Current.Commands.ContainsKey(args[0]))
|
||||
@@ -1007,6 +1012,9 @@ public partial class MainForm : Form
|
||||
m.Result = SendMessage(MpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
}
|
||||
break;
|
||||
case 0x001A: // WM_SETTINGCHANGE
|
||||
UpdateDarkMode();
|
||||
break;
|
||||
case 0x51: // WM_INPUTLANGCHANGE
|
||||
ActivateKeyboardLayout(m.LParam, 0x00000100u /*KLF_SETFORPROCESS*/);
|
||||
break;
|
||||
|
||||
@@ -435,7 +435,7 @@ public class MainPlayer : MpvClient
|
||||
{
|
||||
string name = pair.Name[..^4];
|
||||
string separator = name.Contains("-file") || name.Contains("-path") ? ";" : ",";
|
||||
SetPropertyString(name, (GetPropertyString(name) + separator + pair.Value).TrimStart(','));
|
||||
SetPropertyString(name, (GetPropertyString(name) + separator + pair.Value).TrimStart(',', ';'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class AppSettings
|
||||
public Size WindowSize;
|
||||
public string ConfigEditorSearch = "Video:";
|
||||
public string Mute = "no";
|
||||
public string StartupFolder = "";
|
||||
}
|
||||
|
||||
class SettingsManager
|
||||
|
||||
Reference in New Issue
Block a user