Skip to content

Commit

Permalink
init launcher start shortcut with default if it does not exsist in th… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mykhailopylyp committed Jan 22, 2021
1 parent 2b42fb8 commit 016656f
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/modules/launcher/Microsoft.Launcher/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,36 @@ void Microsoft_Launcher::init_settings()

void Microsoft_Launcher::parse_hotkey(PowerToysSettings::PowerToyValues& settings)
{
try
auto settingsObject = settings.get_raw_json();
if (settingsObject.GetView().Size())
{
auto jsonHotkeyObject = settings.get_raw_json().GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_OPEN_POWERLAUNCHER);
m_hotkey.win = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_WIN);
m_hotkey.alt = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_ALT);
m_hotkey.shift = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_SHIFT);
m_hotkey.ctrl = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_CTRL);
m_hotkey.key = static_cast<unsigned char>(jsonHotkeyObject.GetNamedNumber(JSON_KEY_CODE));
try
{
auto jsonHotkeyObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_OPEN_POWERLAUNCHER);
m_hotkey.win = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_WIN);
m_hotkey.alt = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_ALT);
m_hotkey.shift = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_SHIFT);
m_hotkey.ctrl = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_CTRL);
m_hotkey.key = static_cast<unsigned char>(jsonHotkeyObject.GetNamedNumber(JSON_KEY_CODE));
}
catch(...)
{
Logger::error("Failed to initialize PT Run start shortcut");
}
}
else
{
Logger::info("PT Run settings are empty");
}
catch (...)

if (!m_hotkey.key)
{
m_hotkey.key = 0;
Logger::info("PT Run is going to use default shortcut");
m_hotkey.win = false;
m_hotkey.alt = true;
m_hotkey.shift = false;
m_hotkey.ctrl = false;
m_hotkey.key = VK_SPACE;
}
}

Expand Down

0 comments on commit 016656f

Please sign in to comment.