terminal/src/cascadia/TerminalSettingsModel/DefaultTerminal.h
Michael Niksa b7fa32881d
Implement UI for choosing default terminal inside Settings page (#9907)
Implement dropdown menu for choosing a default terminal application from inside the Windows Terminal Settings UI

## PR Checklist
* [x] Closes #9463 
* [x] I work here.
* [x] Manual tests passed
* [x] https://github.com/MicrosoftDocs/terminal/issues/314 (and cross reference #9462)

## Detailed Description of the Pull Request / Additional comments
- Adds dropdown menu and a template card for displaying the available default applications (using the same lookup code as the console property sheet `console.dll`)
- Adds model to TSM for adapting the data for display and binding on XAML
- Lookup occurs on every page reload. Persistence only happens on Save Changes.
- Manifest changed for Terminal to add capability to opt-out of registry redirection so we can edit this setting

## Validation Steps Performed
- [x] Flipped the menu and pressed Save Changes and launched cmd from run box... it moved between the two.
- [x] Flipped system theme from light to dark and ensured secondary color looked good
- [x] Flipped the status with a different mechanism (conhost propsheet) and then reopened settings page and confirmed it loaded the updated status
2021-04-28 10:43:30 +00:00

53 lines
1.5 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- DefaultTerminal.h
Abstract:
- A Default Terminal is an application that can register
as the handler window or "terminal" for a command-line
application. This class is the model for presenting
handler options in the Windows Terminal Settings UI.
Author(s):
- Michael Niksa <miniksa> - 20-Apr-2021
--*/
#pragma once
#include "DefaultTerminal.g.h"
#include "../inc/cppwinrt_utils.h"
#include "../../propslib/DelegationConfig.hpp"
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
struct DefaultTerminal : public DefaultTerminalT<DefaultTerminal>
{
DefaultTerminal(DelegationConfig::DelegationPackage pkg);
hstring Name() const;
hstring Author() const;
hstring Version() const;
hstring Icon() const;
static void Refresh();
static Windows::Foundation::Collections::IVectorView<Model::DefaultTerminal> Available();
static Model::DefaultTerminal Current();
static void Current(const Model::DefaultTerminal& term);
private:
DelegationConfig::DelegationPackage _pkg;
static Windows::Foundation::Collections::IVector<Model::DefaultTerminal> _available;
static std::optional<Model::DefaultTerminal> _current;
};
}
namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
{
BASIC_FACTORY(DefaultTerminal);
}