b7fa32881d
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
101 lines
3 KiB
C++
101 lines
3 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- DelegationConfig.hpp
|
|
|
|
Abstract:
|
|
- This module is used for looking up delegation handlers for the launch of the default console hosting environment
|
|
|
|
Author(s):
|
|
- Michael Niksa (MiNiksa) 31-Aug-2020
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
class DelegationConfig
|
|
{
|
|
public:
|
|
struct PkgVersion
|
|
{
|
|
unsigned short major;
|
|
unsigned short minor;
|
|
unsigned short build;
|
|
unsigned short revision;
|
|
|
|
bool operator==(const PkgVersion& other) const
|
|
{
|
|
return major == other.major &&
|
|
minor == other.minor &&
|
|
build == other.build &&
|
|
revision == other.revision;
|
|
}
|
|
};
|
|
|
|
struct DelegationBase
|
|
{
|
|
CLSID clsid;
|
|
std::wstring name;
|
|
std::wstring author;
|
|
std::wstring pfn;
|
|
std::wstring logo;
|
|
PkgVersion version;
|
|
|
|
bool IsFromSamePackage(const DelegationBase& other) const
|
|
{
|
|
return name == other.name &&
|
|
author == other.author &&
|
|
pfn == other.pfn &&
|
|
version == other.version;
|
|
}
|
|
|
|
bool operator==(const DelegationBase& other) const
|
|
{
|
|
return clsid == other.clsid &&
|
|
name == other.name &&
|
|
author == other.author &&
|
|
pfn == other.pfn &&
|
|
version == other.version;
|
|
}
|
|
};
|
|
|
|
struct DelegationConsole : public DelegationBase
|
|
{
|
|
};
|
|
|
|
struct DelegationTerminal : public DelegationBase
|
|
{
|
|
};
|
|
|
|
struct DelegationPackage
|
|
{
|
|
DelegationConsole console;
|
|
DelegationTerminal terminal;
|
|
|
|
bool operator==(const DelegationPackage& other) const
|
|
{
|
|
return console == other.console &&
|
|
terminal == other.terminal;
|
|
}
|
|
};
|
|
|
|
[[nodiscard]] static HRESULT s_GetAvailablePackages(std::vector<DelegationPackage>& packages, DelegationPackage& def) noexcept;
|
|
|
|
[[nodiscard]] static HRESULT s_SetDefaultByPackage(const DelegationPackage& pkg, const bool useRegExe = false) noexcept;
|
|
|
|
[[nodiscard]] static HRESULT s_GetDefaultConsoleId(IID& iid) noexcept;
|
|
[[nodiscard]] static HRESULT s_GetDefaultTerminalId(IID& iid) noexcept;
|
|
|
|
private:
|
|
[[nodiscard]] static HRESULT s_GetAvailableConsoles(std::vector<DelegationConsole>& consoles) noexcept;
|
|
[[nodiscard]] static HRESULT s_GetAvailableTerminals(std::vector<DelegationTerminal>& terminals) noexcept;
|
|
|
|
[[nodiscard]] static HRESULT s_SetDefaultConsoleById(const IID& iid, const bool useRegExe) noexcept;
|
|
[[nodiscard]] static HRESULT s_SetDefaultTerminalById(const IID& iid, const bool useRegExe) noexcept;
|
|
|
|
[[nodiscard]] static HRESULT s_Get(PCWSTR value, IID& iid) noexcept;
|
|
[[nodiscard]] static HRESULT s_Set(PCWSTR value, const CLSID clsid, const bool useRegExe) noexcept;
|
|
};
|