forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain (and indicate) orphaned dynamic profiles (microsoft#18188)
The original intent with dynamic profiles was that they could be uninstalled but that Terminal would remember your settings in case they ever came back. After we implemented dynamic profile _deletion_, however, we accidentally made it so that saving your settings after a dynamic profile disappeared scoured it from the planet _forever_ (since we remembered that we generated it, but now it was no longer in the settings file). This pull request implements: - Tracking for orphaned dynamic profiles - A new settings page for the profile that explains what happened - Badging on the Navigation Menu indicating which profiles are orphaned and which are hidden Closes microsoft#14061 Closes microsoft#11510 Refs microsoft#13916 Refs microsoft#9997
- Loading branch information
Showing
15 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/cascadia/TerminalSettingsEditor/Profiles_Base_Orphaned.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "Profiles_Base_Orphaned.h" | ||
#include "Profiles_Base_Orphaned.g.cpp" | ||
#include "ProfileViewModel.h" | ||
|
||
#include <LibraryResources.h> | ||
#include "..\WinRTUtils\inc\Utils.h" | ||
|
||
using namespace winrt::Windows::UI::Xaml; | ||
using namespace winrt::Windows::UI::Xaml::Controls; | ||
using namespace winrt::Windows::UI::Xaml::Navigation; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
Profiles_Base_Orphaned::Profiles_Base_Orphaned() | ||
{ | ||
InitializeComponent(); | ||
Automation::AutomationProperties::SetName(DeleteButton(), RS_(L"Profile_DeleteButton/Text")); | ||
} | ||
|
||
void Profiles_Base_Orphaned::OnNavigatedTo(const NavigationEventArgs& e) | ||
{ | ||
const auto args = e.Parameter().as<Editor::NavigateToProfileArgs>(); | ||
_Profile = args.Profile(); | ||
|
||
_layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { | ||
// This event fires every time the layout changes, but it is always the last one to fire | ||
// in any layout change chain. That gives us great flexibility in finding the right point | ||
// at which to initialize our renderer (and our terminal). | ||
// Any earlier than the last layout update and we may not know the terminal's starting size. | ||
|
||
// Only let this succeed once. | ||
_layoutUpdatedRevoker.revoke(); | ||
|
||
if (_Profile.FocusDeleteButton()) | ||
{ | ||
DeleteButton().Focus(FocusState::Programmatic); | ||
_Profile.FocusDeleteButton(false); | ||
} | ||
}); | ||
} | ||
|
||
void Profiles_Base_Orphaned::DeleteConfirmation_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/) | ||
{ | ||
winrt::get_self<ProfileViewModel>(_Profile)->DeleteProfile(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/cascadia/TerminalSettingsEditor/Profiles_Base_Orphaned.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "Profiles_Base_Orphaned.g.h" | ||
#include "ViewModelHelpers.h" | ||
#include "Utils.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
struct Profiles_Base_Orphaned : public HasScrollViewer<Profiles_Base_Orphaned>, Profiles_Base_OrphanedT<Profiles_Base_Orphaned> | ||
{ | ||
public: | ||
Profiles_Base_Orphaned(); | ||
|
||
void OnNavigatedTo(const Windows::UI::Xaml::Navigation::NavigationEventArgs& e); | ||
void DeleteConfirmation_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e); | ||
|
||
WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr); | ||
|
||
private: | ||
winrt::Windows::UI::Xaml::Controls::SwapChainPanel::LayoutUpdated_revoker _layoutUpdatedRevoker; | ||
}; | ||
}; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation | ||
{ | ||
BASIC_FACTORY(Profiles_Base_Orphaned); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/cascadia/TerminalSettingsEditor/Profiles_Base_Orphaned.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import "ProfileViewModel.idl"; | ||
|
||
namespace Microsoft.Terminal.Settings.Editor | ||
{ | ||
[default_interface] runtimeclass Profiles_Base_Orphaned : Windows.UI.Xaml.Controls.Page | ||
{ | ||
Profiles_Base_Orphaned(); | ||
ProfileViewModel Profile { get; }; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/cascadia/TerminalSettingsEditor/Profiles_Base_Orphaned.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under | ||
the MIT License. See LICENSE in the project root for license information. | ||
--> | ||
<Page x:Class="Microsoft.Terminal.Settings.Editor.Profiles_Base_Orphaned" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Microsoft.Terminal.Settings.Editor" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:model="using:Microsoft.Terminal.Settings.Model" | ||
xmlns:mtu="using:Microsoft.Terminal.UI" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="CommonResources.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Page.Resources> | ||
|
||
<StackPanel Style="{StaticResource SettingsStackStyle}"> | ||
<!-- Delete Button --> | ||
<local:SettingContainer x:Uid="Profile_Delete_Orphaned"> | ||
<local:SettingContainer.Content> | ||
<Button x:Name="DeleteButton" | ||
Click="DeleteConfirmation_Click" | ||
Style="{StaticResource DeleteButtonStyle}"> | ||
<Button.Content> | ||
<StackPanel Orientation="Horizontal"> | ||
<FontIcon FontSize="{StaticResource StandardIconSize}" | ||
Glyph="" /> | ||
<TextBlock x:Uid="Profile_DeleteButton" | ||
Margin="10,0,0,0" /> | ||
</StackPanel> | ||
</Button.Content> | ||
</Button> | ||
</local:SettingContainer.Content> | ||
</local:SettingContainer> | ||
|
||
<local:SettingContainer x:Uid="Profile_Name"> | ||
<local:SettingContainer.Content> | ||
<TextBlock FontFamily="Segoe UI, Segoe Fluent Icons, Segoe MDL2 Assets" | ||
Style="{StaticResource SettingsPageItemDescriptionStyle}" | ||
Text="{x:Bind Profile.Name, Mode=OneTime}" /> | ||
</local:SettingContainer.Content> | ||
</local:SettingContainer> | ||
|
||
<local:SettingContainer x:Uid="Profile_Source_Orphaned"> | ||
<local:SettingContainer.Content> | ||
<TextBlock FontFamily="Segoe UI, Segoe Fluent Icons, Segoe MDL2 Assets" | ||
Style="{StaticResource SettingsPageItemDescriptionStyle}" | ||
Text="{x:Bind Profile.Source, Mode=OneTime}" /> | ||
</local:SettingContainer.Content> | ||
</local:SettingContainer> | ||
</StackPanel> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters