terminal/src/cascadia/TerminalSettingsEditor/AddProfile.h
PankajBhojwani b53bd672d7
Create a new page for "Add new profile" in the SUI (#9352)
- Whenever we add a new profile setting from now on we have to update
  `Profile::CopySettings` _and_ `CascadiaSettings::DuplicateProfile` 👎 

Notes from bug bash (checked bugs have been resolved):

- [ ] The duplicate list can be very long if you have profiles
- [x] DH: "Create new" seems too vague. "New empty profile" or something
  seems a little clearer to me.
- [x] There is no deduplication counter for name
- [x] Crash when your settings file is corrupt and we had to fall back
  to the defaults and you duplicate a profile
- [x] Crash due to #10003

## PR Checklist
* [x] Closes #9121
2021-05-05 04:15:25 +00:00

64 lines
1.7 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- AddProfile.h
Abstract:
- This creates the 'add new profile' page in the settings UI and handles
user interaction with it, raising events to the main page as necessary
Author(s):
- Pankaj Bhojwani - March 2021
--*/
#pragma once
#include "AddProfile.g.h"
#include "AddProfilePageNavigationState.g.h"
#include "Utils.h"
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
struct AddProfilePageNavigationState : AddProfilePageNavigationStateT<AddProfilePageNavigationState>
{
public:
AddProfilePageNavigationState(const Model::CascadiaSettings& settings) :
_Settings{ settings } {}
void RequestAddNew()
{
_AddNewHandlers(winrt::guid{});
}
void RequestDuplicate(GUID profile)
{
_AddNewHandlers(profile);
}
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
WINRT_CALLBACK(AddNew, AddNewArgs);
};
struct AddProfile : AddProfileT<AddProfile>
{
public:
AddProfile();
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
void AddNewClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void DuplicateClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
WINRT_PROPERTY(Editor::AddProfilePageNavigationState, State, nullptr);
};
}
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
{
BASIC_FACTORY(AddProfile);
}