2015-01-05 22:41:17 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-04-21 08:53:21 +08:00
|
|
|
|
using System.ComponentModel;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using System.Drawing;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using System.Linq;
|
2016-03-25 09:22:24 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2015-01-05 22:41:17 +08:00
|
|
|
|
using Wox.Infrastructure.Storage;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using Wox.Plugin;
|
2016-03-25 09:22:24 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2014-01-29 22:44:57 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
namespace Wox.Core.UserSettings
|
2014-01-29 22:44:57 +08:00
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public class Settings
|
2014-01-29 22:44:57 +08:00
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public string Hotkey { get; set; } = "Alt + Space";
|
|
|
|
|
public string Language { get; set; } = "en";
|
|
|
|
|
public string Theme { get; set; } = "Dark";
|
|
|
|
|
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
public string QueryBoxFontStyle { get; set; }
|
|
|
|
|
public string QueryBoxFontWeight { get; set; }
|
|
|
|
|
public string QueryBoxFontStretch { get; set; }
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public string ResultFontStyle { get; set; }
|
|
|
|
|
public string ResultFontWeight { get; set; }
|
|
|
|
|
public string ResultFontStretch { get; set; }
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
2014-06-16 14:06:24 +08:00
|
|
|
|
public double WindowLeft { get; set; }
|
|
|
|
|
public double WindowTop { get; set; }
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public int MaxResultsToShow { get; set; } = 6;
|
|
|
|
|
public int ActivateTimes { get; set; }
|
2014-06-16 14:06:24 +08:00
|
|
|
|
|
2016-03-25 09:22:24 +08:00
|
|
|
|
// Order defaults to 0 or -1, so 1 will let this property appear last
|
|
|
|
|
[JsonProperty(Order = 1)]
|
2016-04-22 05:40:03 +08:00
|
|
|
|
public Dictionary<string, PluginSettings> PluginSettings { get; set; } = new Dictionary<string, PluginSettings>();
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new List<CustomPluginHotkey>();
|
2014-03-23 16:17:41 +08:00
|
|
|
|
|
2015-01-26 22:50:38 +08:00
|
|
|
|
[Obsolete]
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public double Opacity { get; set; } = 1;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2015-01-26 22:50:38 +08:00
|
|
|
|
[Obsolete]
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public bool DontPromptUpdateMsg { get; set; }
|
|
|
|
|
public bool EnableUpdateLog { get; set; }
|
2014-04-11 05:44:57 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public bool StartWoxOnSystemStartup { get; set; }
|
|
|
|
|
public bool LeaveCmdOpen { get; set; }
|
2014-04-13 10:08:33 +08:00
|
|
|
|
public bool HideWhenDeactive { get; set; }
|
2015-02-20 21:45:42 +08:00
|
|
|
|
public bool RememberLastLaunchLocation { get; set; }
|
2015-10-08 07:02:36 +08:00
|
|
|
|
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
2015-10-08 06:17:37 +08:00
|
|
|
|
|
2014-07-18 20:00:55 +08:00
|
|
|
|
public string ProxyServer { get; set; }
|
|
|
|
|
public bool ProxyEnabled { get; set; }
|
|
|
|
|
public int ProxyPort { get; set; }
|
|
|
|
|
public string ProxyUserName { get; set; }
|
|
|
|
|
public string ProxyPassword { get; set; }
|
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public void UpdatePluginSettings()
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
2016-03-25 09:22:24 +08:00
|
|
|
|
var metadatas = PluginManager.AllPlugins.Select(p => p.Metadata);
|
2016-04-21 08:53:21 +08:00
|
|
|
|
if (PluginSettings == null)
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
2016-04-22 05:40:03 +08:00
|
|
|
|
var configs = new Dictionary<string, PluginSettings>();
|
2016-03-25 09:22:24 +08:00
|
|
|
|
foreach (var metadata in metadatas)
|
|
|
|
|
{
|
|
|
|
|
addPluginMetadata(configs, metadata);
|
|
|
|
|
}
|
2016-04-21 08:53:21 +08:00
|
|
|
|
PluginSettings = configs;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
}
|
2016-03-25 09:22:24 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
var configs = PluginSettings;
|
2016-03-25 09:22:24 +08:00
|
|
|
|
foreach (var metadata in metadatas)
|
|
|
|
|
{
|
|
|
|
|
if (configs.ContainsKey(metadata.ID))
|
|
|
|
|
{
|
|
|
|
|
var config = configs[metadata.ID];
|
|
|
|
|
if (config.ActionKeywords?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
metadata.ActionKeywords = config.ActionKeywords;
|
|
|
|
|
metadata.ActionKeyword = config.ActionKeywords[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addPluginMetadata(configs, metadata);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-01 22:19:46 +08:00
|
|
|
|
}
|
2015-11-09 11:20:02 +08:00
|
|
|
|
|
2016-03-25 09:22:24 +08:00
|
|
|
|
|
2016-04-22 05:40:03 +08:00
|
|
|
|
private void addPluginMetadata(Dictionary<string, PluginSettings> configs, PluginMetadata metadata)
|
2015-11-09 11:20:02 +08:00
|
|
|
|
{
|
2016-04-22 05:40:03 +08:00
|
|
|
|
configs[metadata.ID] = new PluginSettings
|
2015-11-09 11:20:02 +08:00
|
|
|
|
{
|
2016-03-25 09:22:24 +08:00
|
|
|
|
ID = metadata.ID,
|
|
|
|
|
Name = metadata.Name,
|
|
|
|
|
ActionKeywords = metadata.ActionKeywords,
|
|
|
|
|
Disabled = false
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateActionKeyword(PluginMetadata metadata)
|
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
var config = PluginSettings[metadata.ID];
|
2016-03-25 09:22:24 +08:00
|
|
|
|
config.ActionKeywords = metadata.ActionKeywords;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
}
|
2016-04-21 08:53:21 +08:00
|
|
|
|
|
2014-03-26 17:34:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum OpacityMode
|
|
|
|
|
{
|
|
|
|
|
Normal = 0,
|
|
|
|
|
LayeredWindow = 1,
|
|
|
|
|
DWM = 2
|
2014-01-29 22:44:57 +08:00
|
|
|
|
}
|
2015-07-17 15:08:39 +08:00
|
|
|
|
}
|