misc
This commit is contained in:
@@ -37,9 +37,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static Extension Extension { get; set; }
|
public static Extension Extension { get; set; }
|
||||||
|
|
||||||
public static bool IsDarkMode {
|
public static bool IsDarkMode => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
|
||||||
}
|
|
||||||
|
|
||||||
static AppSettings _Settings;
|
static AppSettings _Settings;
|
||||||
|
|
||||||
@@ -143,13 +141,22 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (obj is Exception e)
|
if (obj is Exception e)
|
||||||
Msg.ShowException(e);
|
InvokeOnMainThread(() => Msg.ShowException(e));
|
||||||
else
|
else
|
||||||
Msg.ShowError(obj.ToString());
|
InvokeOnMainThread(() => Msg.ShowError(obj.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InvokeOnMainThread(Action action) => MainForm.Instance.BeginInvoke(action);
|
public static void InvokeOnMainThread(Action action)
|
||||||
|
{
|
||||||
|
if (action == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (MainForm.Instance == null)
|
||||||
|
action.Invoke();
|
||||||
|
else
|
||||||
|
MainForm.Instance.BeginInvoke(action);
|
||||||
|
}
|
||||||
|
|
||||||
public static void ShowInfo(string msg)
|
public static void ShowInfo(string msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,33 +153,14 @@ namespace mpvnet
|
|||||||
SetPropertyBool("keep-open", true);
|
SetPropertyBool("keep-open", true);
|
||||||
SetPropertyBool("keep-open-pause", false);
|
SetPropertyBool("keep-open-pause", false);
|
||||||
|
|
||||||
|
SetInputBindingProperties();
|
||||||
|
|
||||||
ProcessCommandLine(true);
|
ProcessCommandLine(true);
|
||||||
mpv_error err = mpv_initialize(Handle);
|
mpv_error err = mpv_initialize(Handle);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
|
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
|
||||||
|
|
||||||
if (Debugger.IsAttached)
|
|
||||||
{
|
|
||||||
if (GetPropertyString("property-list").Contains("input-builtin-bindings"))
|
|
||||||
{
|
|
||||||
SetPropertyBool("input-default-bindings", true);
|
|
||||||
SetPropertyBool("input-builtin-bindings", false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetPropertyBool("input-default-bindings", false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetPropertyBool("input-default-bindings", true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
SetPropertyBool("input-builtin-bindings", false, true);
|
|
||||||
} catch {
|
|
||||||
SetPropertyBool("input-default-bindings", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ObservePropertyInt("video-rotate", value => {
|
ObservePropertyInt("video-rotate", value => {
|
||||||
VideoRotate = value;
|
VideoRotate = value;
|
||||||
UpdateVideoSize("dwidth", "dheight");
|
UpdateVideoSize("dwidth", "dheight");
|
||||||
@@ -189,6 +170,49 @@ namespace mpvnet
|
|||||||
InvokeAsync(InitializedAsync);
|
InvokeAsync(InitializedAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetInputBindingProperties()
|
||||||
|
{
|
||||||
|
if (Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
if (GetPropertyString("property-list").Contains("input-builtin-bindings"))
|
||||||
|
throw new Exception();
|
||||||
|
else
|
||||||
|
SetPropertyBool("input-default-bindings", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetPropertyBool("input-default-bindings", true);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetPropertyBool("input-builtin-bindings", false, true);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
SetPropertyBool("input-default-bindings", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyCompatibilityFixex()
|
||||||
|
{
|
||||||
|
if (!App.Settings.InputDefaultBindingsFixApplied)
|
||||||
|
{
|
||||||
|
if (File.Exists(ConfPath))
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(ConfPath);
|
||||||
|
|
||||||
|
if (content.Contains("input-default-bindings = no"))
|
||||||
|
File.WriteAllText(ConfPath, content.Replace("input-default-bindings = no", ""));
|
||||||
|
|
||||||
|
if (content.Contains("input-default-bindings=no"))
|
||||||
|
File.WriteAllText(ConfPath, content.Replace("input-default-bindings=no", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Settings.InputDefaultBindingsFixApplied = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ProcessProperty(string name, string value)
|
public void ProcessProperty(string name, string value)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
@@ -266,6 +290,8 @@ namespace mpvnet
|
|||||||
get {
|
get {
|
||||||
if (_Conf == null)
|
if (_Conf == null)
|
||||||
{
|
{
|
||||||
|
ApplyCompatibilityFixex();
|
||||||
|
|
||||||
_Conf = new Dictionary<string, string>();
|
_Conf = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (File.Exists(ConfPath))
|
if (File.Exists(ConfPath))
|
||||||
@@ -1092,8 +1118,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!App.IsTerminalAttached)
|
App.ShowException(e);
|
||||||
Msg.ShowException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1356,15 +1381,9 @@ namespace mpvnet
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RaiseScaleWindow(float value)
|
public void RaiseScaleWindow(float value) => ScaleWindow(value);
|
||||||
{
|
|
||||||
ScaleWindow(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RaiseWindowScale(float value)
|
public void RaiseWindowScale(float value) => WindowScale(value);
|
||||||
{
|
|
||||||
WindowScale(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReadMetaData()
|
void ReadMetaData()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace mpvnet
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class AppSettings
|
public class AppSettings
|
||||||
{
|
{
|
||||||
|
public bool InputDefaultBindingsFixApplied;
|
||||||
public int LastUpdateCheck;
|
public int LastUpdateCheck;
|
||||||
public int Volume = 70;
|
public int Volume = 70;
|
||||||
public List<string> RecentFiles = new List<string>();
|
public List<string> RecentFiles = new List<string>();
|
||||||
@@ -27,9 +28,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
class SettingsManager
|
class SettingsManager
|
||||||
{
|
{
|
||||||
public static string SettingsFile {
|
public static string SettingsFile => Core.ConfigFolder + "settings.xml";
|
||||||
get => Core.ConfigFolder + "settings.xml";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AppSettings Load()
|
public static AppSettings Load()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user