Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UI for choosing default terminal inside Settings page #9907

Merged
18 commits merged into from
Apr 28, 2021

Conversation

miniksa
Copy link
Member

@miniksa miniksa commented Apr 20, 2021

Implement dropdown menu for choosing a default terminal application from inside the Windows Terminal Settings UI

PR Checklist

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

  • Flipped the menu and pressed Save Changes and launched cmd from run box... it moved between the two.
  • Flipped system theme from light to dark and ensured secondary color looked good
  • Flipped the status with a different mechanism (conhost propsheet) and then reopened settings page and confirmed it loaded the updated status

@ghost ghost added Area-DefApp Area-Settings UI Anything specific to the SUI Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Apr 20, 2021
@github-actions

This comment has been minimized.

@miniksa miniksa self-assigned this Apr 20, 2021
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/DefaultTerminal.h Outdated Show resolved Hide resolved
src/propslib/DelegationConfig.cpp Outdated Show resolved Hide resolved
@miniksa
Copy link
Member Author

miniksa commented Apr 21, 2021

reg.exe

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@miniksa
Copy link
Member Author

miniksa commented Apr 21, 2021

Check what reg.exe do when key is missing.

wil::unique_cotaskmem_string str;
RETURN_IF_FAILED(StringFromCLSID(clsid, &str));

auto regExePath = wil::ExpandEnvironmentStringsW<std::wstring>(L"%WINDIR%\\System32\\reg.exe");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we can GetSystemDirectory (for which wil has a wrapper) -- might be (delta) "easier"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like making one more call and concatenate.... I think I'll just leave it this way especially since I stole this from another part of our codebase already (and subbed the exe name)

@miniksa
Copy link
Member Author

miniksa commented Apr 22, 2021

Check what reg.exe do when key is missing.

It just works. Makes the tree of keys and puts the key/value pair in. Good enough.

@miniksa miniksa marked this pull request as ready for review April 26, 2021 17:59
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@carlos-zamora carlos-zamora added the Needs-Second It's a PR that needs another sign-off label Apr 27, 2021
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea these are just nits. Check the theming thing though, and watch out for #9716

return _current.value();
}

void DefaultTerminal::Current(const Model::DefaultTerminal& term)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd maybe add a doc comment here that this will write to the registry. Everything else in this class are all just reads, but this one's a write.

hstring Version() const;
hstring Icon() const;

static void Refresh();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: this can be private, right?

// - <none>
void CascadiaSettings::CurrentDefaultTerminal(winrt::Microsoft::Terminal::Settings::Model::DefaultTerminal terminal)
{
_currentDefaultTerminal = terminal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe note that this doesn't write the defterm choice to the registry, it just sets the value internally, and that the value is persisted to the reg in CascadiaSettings::WriteSettingsToDisk


<TextBlock Grid.Row="1"
Grid.Column="1"
Foreground="{StaticResource SystemBaseMediumColor}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work in both dark and light mode? What if the OS is set to dark mode, but the app is set to light?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked OS set to light and OS set to dark with the app following. If you switch it while it is open, it looks terrible. But if you close and reopen the page it's fine. I wasn't going to cry over that.

I can check and cross-reference the other bug I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh, :shipit:

src/propslib/DelegationConfig.cpp Show resolved Hide resolved
@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Apr 28, 2021
@ghost
Copy link

ghost commented Apr 28, 2021

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit b7fa328 into main Apr 28, 2021
@ghost ghost deleted the dev/miniksa/term_def_ui branch April 28, 2021 10:43
@DHowett
Copy link
Member

DHowett commented Apr 28, 2021

Just to be sure- we didn't fix the truncated version number on the right side, right?

@carlos-zamora
Copy link
Member

Just to be sure- we didn't fix the truncated version number on the right side, right?

                                    <Grid.ColumnDefinitions>
                                        <!--  icon  -->
                                        <ColumnDefinition Width="24" />
                                        <!--  profile name and author  -->
                                        <ColumnDefinition Width="*" />
                                        <!--  version  -->
                                        <ColumnDefinition Width="48" />
                                    </Grid.ColumnDefinitions>

Hmm... Doesn't look like it. We could add a TextTrimming property to the TextBlock to truncate the version instead of clipping it.

@ghost
Copy link

ghost commented May 25, 2021

🎉Windows Terminal Preview v1.9.1445.0 has been released which incorporates this pull request.:tada:

Handy links:

@jantari
Copy link
Contributor

jantari commented May 25, 2021

I absolutely love that this possibility is coming, so thanks a ton everyone for all the work on this.

I have a question though, and maybe it's obvious, but I was kind of expecting this setting to be in "Windows Settings -> Apps -> Default apps", which is this menu here:

click to expand large-ish screenshot:

image

Is that planned at all by / with the Windows team or is it the end-goal to permanently host the setting inside the Windows Terminal settings UI?

@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal v1.11.2921.0 has been released which incorporates this pull request.:tada:

Handy links:

@Kein
Copy link

Kein commented Oct 20, 2021

If it matters and relevant, I'm running 1.11.211019001-release1.11 on W10-19042.685 and there is no such option in the menu. On first launch of new version no pop-up appeared either.
Terminal was installed manually.

@zadjii-msft
Copy link
Member

on W10-19042.685

Yep, that's by design. Defterm only works on Windows 11.

@DHowett
Copy link
Member

DHowett commented Oct 20, 2021

AH! Another thing:
Right now, Terminal can only be set as default when it was installed as an app package (either from the store or by double-clicking the msixbundle.)

When Terminal is installed in a directory by extracting the archive (which scoop does!), there are required OS registration steps that get skipped.

@Kein
Copy link

Kein commented Oct 20, 2021

I see. The release notes were written in such way that it implies the Windows 11 sub-remark was just describing different behavior on Windows 11 and the main bulletpoint applied in general to all supportsed OSes.

@DHowett
Copy link
Member

DHowett commented Oct 20, 2021

Thanks, we should clarify that!

@5-Hydroxytryptamin
Copy link

Will the defterm functionality be added to Win10 in the future?

@zadjii-msft
Copy link
Member

Nope. That feature is going to remain a Windows 11-only feature. It's powered by a fairly large feature change to the OS, which is unlikely to be serviced as a "bugfix" to earlier OS versions.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DefApp Area-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DefApp] Complete Terminal-side UI chooser of registered defapp
7 participants