Skip to content

Commit

Permalink
Add a success dialog to window renaming (#9808)
Browse files Browse the repository at this point in the history
I added a `RenameSucceededText` property to the `TerminalPage` which returns the
formatted message `Successfully renamed window to "{WindowNameForDisplay()}"`

This _doesn't_ pop the dialog when you `wt -w foo` for the first time. Only
_subsequent_ renames.

## References
* Added in #9662
* Closes #9804
  • Loading branch information
zadjii-msft authored Apr 22, 2021
1 parent cf8ac0e commit aa54de1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,12 +2607,32 @@ namespace winrt::TerminalApp::implementation
{
return _WindowName;
}
void TerminalPage::WindowName(const winrt::hstring& value)

winrt::fire_and_forget TerminalPage::WindowName(const winrt::hstring& value)
{
if (_WindowName != value)
const bool changed = _WindowName != value;
if (changed)
{
_WindowName = value;
_PropertyChangedHandlers(*this, WUX::Data::PropertyChangedEventArgs{ L"WindowNameForDisplay" });
}
auto weakThis{ get_weak() };
// On the foreground thread, raise property changed notifications, and
// display the success toast.
co_await resume_foreground(Dispatcher());
if (auto page{ weakThis.get() })
{
if (changed)
{
page->_PropertyChangedHandlers(*this, WUX::Data::PropertyChangedEventArgs{ L"WindowName" });
page->_PropertyChangedHandlers(*this, WUX::Data::PropertyChangedEventArgs{ L"WindowNameForDisplay" });

// DON'T display the confirmation if this is the name we were
// given on startup!
if (page->_startupState == StartupState::Initialized)
{
page->IdentifyWindow();
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace winrt::TerminalApp::implementation
// WINRT_OBSERVABLE_PROPERTY's, but we want them to raise
// WindowNameForDisplay and WindowIdForDisplay instead
winrt::hstring WindowName() const noexcept;
void WindowName(const winrt::hstring& value);
winrt::fire_and_forget WindowName(const winrt::hstring& value);
uint64_t WindowId() const noexcept;
void WindowId(const uint64_t& value);
winrt::hstring WindowIdForDisplay() const noexcept;
Expand Down

0 comments on commit aa54de1

Please sign in to comment.