fixed #635: Only add default hotkeys when settings init first time

This commit is contained in:
Jaex 2015-04-21 22:31:03 +03:00
parent d06ba3cb9e
commit bc7a5ea4a4
3 changed files with 9 additions and 14 deletions

View file

@ -202,13 +202,15 @@ private void UpdateMainFormTip()
StringBuilder sb = new StringBuilder(Resources.MainForm_UpdateMainFormTip_You_can_drag_and_drop_files_to_this_window_);
if (Program.HotkeysConfig.Hotkeys.Count > 0)
List<HotkeySettings> hotkeys = Program.HotkeysConfig.Hotkeys.Where(x => x.HotkeyInfo.IsValidHotkey).ToList();
if (hotkeys.Count > 0)
{
sb.AppendLine();
sb.AppendLine();
sb.AppendLine(Resources.MainForm_UpdateMainFormTip_Currently_configured_hotkeys_);
foreach (HotkeySettings hotkey in Program.HotkeysConfig.Hotkeys.Where(x => x.HotkeyInfo.IsValidHotkey))
foreach (HotkeySettings hotkey in hotkeys)
{
sb.AppendFormat("{0} | {1}\r\n", hotkey.HotkeyInfo, hotkey.TaskSettings);
}

View file

@ -50,15 +50,7 @@ public HotkeyManager(HotkeyForm form, List<HotkeySettings> hotkeys)
Hotkeys = hotkeys;
if (Hotkeys.Count == 0)
{
ResetHotkeys();
}
else
{
RegisterAllHotkeys();
}
RegisterAllHotkeys();
ShowFailedHotkeys();
}
@ -166,9 +158,9 @@ public void ResetHotkeys()
RegisterAllHotkeys();
}
private HotkeySettings[] GetDefaultHotkeyList()
public static List<HotkeySettings> GetDefaultHotkeyList()
{
return new HotkeySettings[]
return new List<HotkeySettings>
{
new HotkeySettings(HotkeyType.PrintScreen, Keys.PrintScreen),
new HotkeySettings(HotkeyType.ActiveWindow, Keys.Alt | Keys.PrintScreen),

View file

@ -25,11 +25,12 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System.Collections.Generic;
using System.Linq;
namespace ShareX
{
public class HotkeysConfig : SettingsBase<HotkeysConfig>
{
public List<HotkeySettings> Hotkeys = new List<HotkeySettings>();
public List<HotkeySettings> Hotkeys = HotkeyManager.GetDefaultHotkeyList();
}
}