THATS RIGHT, IT HOT-RELOADS

This commit is contained in:
Mike Griese 2021-04-12 16:50:42 -05:00
parent 7c2a514e50
commit ac8fef0e39
5 changed files with 25 additions and 11 deletions

View file

@ -968,7 +968,7 @@ namespace winrt::TerminalApp::implementation
CATCH_LOG();
// Method Description:
// - Reloads the settings from the profile.json.
// - Reloads the settings from the settings.json file.
void AppLogic::_ReloadSettings()
{
// Attempt to load our settings.
@ -998,6 +998,8 @@ namespace winrt::TerminalApp::implementation
_ApplyStartupTaskStateChange();
Jumplist::UpdateJumplist(_settings);
_SettingsChangedHandlers(*this, nullptr);
}
// Method Description:

View file

@ -94,6 +94,7 @@ namespace winrt::TerminalApp::implementation
// -------------------------------- WinRT Events ---------------------------------
TYPED_EVENT(RequestedThemeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::ElementTheme);
TYPED_EVENT(SettingsChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
private:
bool _isUwp{ false };

View file

@ -88,5 +88,6 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> SettingsChanged;
}
}

View file

@ -260,6 +260,7 @@ void AppHost::Initialize()
_logic.SetTaskbarProgress({ this, &AppHost::SetTaskbarProgress });
_logic.IdentifyWindowsRequested({ this, &AppHost::_IdentifyWindowsRequested });
_logic.RenameWindowRequested({ this, &AppHost::_RenameWindowRequested });
_logic.SettingsChanged({ this, &AppHost::_HandleSettingsChanged });
_window->UpdateTitle(_logic.Title());
@ -606,18 +607,19 @@ winrt::fire_and_forget AppHost::_WindowActivated()
}
}
winrt::fire_and_forget AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
_setupGlobalHotkeys();
}
winrt::fire_and_forget AppHost::_setupGlobalHotkeys()
{
// The hotkey MUST be registered on the main thread. It will fail otherwise!
co_await winrt::resume_foreground(_logic.GetRoot().Dispatcher(),
winrt::Windows::UI::Core::CoreDispatcherPriority::Normal);
_setupGlobalHotkeys();
}
void AppHost::_setupGlobalHotkeys()
{
// Remove all the already registered hotkeys before setting up the new ones.
_window->UnsetHotkeys(_hotkeys);
_hotkeyActions = _logic.GlobalHotkeys();
@ -780,3 +782,9 @@ winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Fou
}
}
}
void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
_setupGlobalHotkeys();
}

View file

@ -55,8 +55,8 @@ private:
void _FindTargetWindow(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs& args);
winrt::fire_and_forget _BecomeMonarch(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
void _BecomeMonarch(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
void _GlobalHotkeyPressed(const long hotkeyIndex);
void _HandleSummon(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
@ -70,6 +70,8 @@ private:
GUID _CurrentDesktopGuid();
void _setupGlobalHotkeys();
winrt::fire_and_forget _setupGlobalHotkeys();
winrt::fire_and_forget _createNewTerminalWindow(winrt::Microsoft::Terminal::Settings::Model::GlobalSummonArgs args);
void _HandleSettingsChanged(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
};