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

Add functionality to open the Settings UI tab through openSettings #7802

Merged
26 commits merged into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1cfaae9
ITab, winrtimplements, now i need the tab changes from master
leonMSFT Sep 24, 2020
0174020
getting updated with feature
leonMSFT Sep 24, 2020
80c0c3d
SettingsTab, building fine, still need hookups to create it
leonMSFT Sep 24, 2020
6b82151
eGaDs it opens a new tab on keybinding pog
leonMSFT Sep 25, 2020
091ac79
give it a fixed font icon, call update title and icon
leonMSFT Sep 25, 2020
8882f66
welp it builds in vs, doesn't want to build in cmd tho so i can't run…
leonMSFT Sep 30, 2020
3fdb0f1
goin back to good ol' GetStrongTabImpl
leonMSFT Sep 30, 2020
cb91b2a
changing the name to be a bit more descriptive
leonMSFT Sep 30, 2020
53ca33a
function name updates, revisiting ITab interface
leonMSFT Sep 30, 2020
ce8458c
comment updates
leonMSFT Sep 30, 2020
da5bf4f
runformat
leonMSFT Sep 30, 2020
258cfa9
teaching mr bot
leonMSFT Sep 30, 2020
c2f891f
cleanups, one tab at a time, switch to existing tab
leonMSFT Oct 1, 2020
ef8922b
attempting to fix build
leonMSFT Oct 1, 2020
9e0a979
settingsUI as Page, TabViewItem as Property
leonMSFT Oct 1, 2020
96af5a8
make the Content property
leonMSFT Oct 1, 2020
242b0f2
SettingsTab's Content property as Page
leonMSFT Oct 1, 2020
35e7920
mimic Control::Focus, move OpenSettingsUI call
leonMSFT Oct 2, 2020
bfd66f0
and that is why i should always build the tests too
leonMSFT Oct 2, 2020
657db06
remove unnecessary includes, add comments, slim down GetTTImpl
leonMSFT Oct 2, 2020
51591d7
re-add spaces to TAL.vcxproj
leonMSFT Oct 2, 2020
3d57825
hmm i guess there isn't a newline at the end
leonMSFT Oct 2, 2020
7f5987a
removing unnecessary GetTerminalTabImpl
leonMSFT Oct 2, 2020
2b250af
simplify the Title vs GetActiveTitle dance in TerminalTab
leonMSFT Oct 5, 2020
e9e8302
move command creation to terminal page
leonMSFT Oct 6, 2020
dcc1125
formatting
leonMSFT Oct 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions OpenConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,8 @@ Global
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x86.Build.0 = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x86.Deploy.0 = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|ARM64.ActiveCfg = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|ARM64.ActiveCfg = Debug|ARM64
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|ARM64.Build.0 = Debug|ARM64
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|DotNet_x64Test.ActiveCfg = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|DotNet_x86Test.ActiveCfg = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -2020,7 +2021,8 @@ Global
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x86.Build.0 = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x86.Deploy.0 = Debug|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|Any CPU.ActiveCfg = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|ARM64.ActiveCfg = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|ARM64.ActiveCfg = Release|ARM64
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|ARM64.Build.0 = Release|ARM64
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|DotNet_x64Test.ActiveCfg = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|DotNet_x86Test.ActiveCfg = Release|Win32
{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x64.ActiveCfg = Release|x64
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace TerminalAppLocalTests
// In the real app, this isn't a problem, but doesn't happen
// reliably in the unit tests.
Log::Comment(L"Ensure we set the first tab as the selected one.");
auto tab{ page->_GetTerminalTabImpl(0) };
auto tab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));
page->_tabView.SelectedItem(tab->TabViewItem());
page->_UpdatedSelectedTab(0);
});
Expand Down Expand Up @@ -469,7 +469,7 @@ namespace TerminalAppLocalTests

result = RunOnUIThread([&page]() {
VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetTerminalTabImpl(0);
auto tab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));
VERIFY_ARE_EQUAL(1, tab->GetLeafPaneCount());
});
VERIFY_SUCCEEDED(result);
Expand All @@ -479,7 +479,7 @@ namespace TerminalAppLocalTests
page->_SplitPane(SplitState::Automatic, SplitType::Duplicate, nullptr);

VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetTerminalTabImpl(0);
auto tab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));
VERIFY_ARE_EQUAL(2, tab->GetLeafPaneCount());
});
VERIFY_SUCCEEDED(result);
Expand All @@ -497,7 +497,7 @@ namespace TerminalAppLocalTests
page->_SplitPane(SplitState::Automatic, SplitType::Duplicate, nullptr);

VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetTerminalTabImpl(0);
auto tab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));
VERIFY_ARE_EQUAL(2,
tab->GetLeafPaneCount(),
L"We should gracefully do nothing here - the profile no longer exists.");
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalApp/AppLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#pragma once

#include "AppLogic.g.h"

#include "TerminalTab.h"
#include "CascadiaSettings.h"
#include "TerminalPage.h"
#include "Jumplist.h"
Expand Down
5 changes: 1 addition & 4 deletions src/cascadia/TerminalApp/ITab.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ namespace TerminalApp
{
String Title { get; };
Windows.UI.Xaml.Controls.IconSource IconSource { get; };
Command SwitchToTabCommand { get; };
Command SwitchToTabCommand;
Microsoft.UI.Xaml.Controls.TabViewItem TabViewItem { get; };
Windows.UI.Xaml.FrameworkElement Content { get; };
Windows.UI.Xaml.FocusState FocusState { get; };

String GetActiveTitle();

void Focus(Windows.UI.Xaml.FocusState focusState);
void UpdateTabViewIndex(UInt32 idx);
void Shutdown();
}
}
42 changes: 0 additions & 42 deletions src/cascadia/TerminalApp/SettingsTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace winrt::TerminalApp::implementation
Content(winrt::Microsoft::Terminal::Settings::Editor::MainPage());

_MakeTabViewItem();
_MakeSwitchToTabCommand();
_CreateContextMenu();
_CreateIcon();
}
Expand Down Expand Up @@ -92,18 +91,6 @@ namespace winrt::TerminalApp::implementation
}
}

// Method Description:
// - Gets the title string of the settings UI
// Arguments:
// - <none>
// Return Value:
// - the title string of the last focused terminal control in our tree.
winrt::hstring SettingsTab::GetActiveTitle() const
{
// TODO: This _could_ change depending on what page of the settings UI is open/focused?
return Title();
}

// Method Description:
// - Prepares this tab for being removed from the UI hierarchy
void SettingsTab::Shutdown()
Expand Down Expand Up @@ -145,33 +132,4 @@ namespace winrt::TerminalApp::implementation
newTabFlyout.Items().Append(closeTabMenuItem);
TabViewItem().ContextFlyout(newTabFlyout);
}

// Method Description:
// - Initializes a SwitchToTab command object for this Tab instance.
// Arguments:
// - <none>
// Return Value:
// - <none>
void SettingsTab::_MakeSwitchToTabCommand()
{
auto focusTabAction = winrt::make_self<implementation::ActionAndArgs>();
auto args = winrt::make_self<implementation::SwitchToTabArgs>();
args->TabIndex(_TabViewIndex);

focusTabAction->Action(ShortcutAction::SwitchToTab);
focusTabAction->Args(*args);

winrt::TerminalApp::Command command;
command.Action(*focusTabAction);
command.Name(Title());
command.IconSource(IconSource());

SwitchToTabCommand(command);
}

void SettingsTab::UpdateTabViewIndex(const uint32_t idx)
{
TabViewIndex(idx);
SwitchToTabCommand().Action().Args().as<implementation::SwitchToTabArgs>()->TabIndex(idx);
}
}
24 changes: 16 additions & 8 deletions src/cascadia/TerminalApp/SettingsTab.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.

Module Name:
- SettingsTab.h

Abstract:
- The SettingsTab is a tab whose content is a Settings UI control. They can
coexist in a TabView with all other types of tabs, like the TerminalTab.
There should only be at most one SettingsTab open at any given time.

Author(s):
- Leon Liang - October 2020

--*/

#pragma once
#include "SettingsTab.g.h"
Expand All @@ -17,18 +31,13 @@ namespace winrt::TerminalApp::implementation
void Focus(winrt::Windows::UI::Xaml::FocusState focusState);
winrt::Windows::UI::Xaml::FocusState FocusState() const noexcept;

winrt::hstring GetActiveTitle() const;

void UpdateTabViewIndex(const uint32_t idx);

void Shutdown();

WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);

GETSET_PROPERTY(winrt::hstring, Title, L"Settings");
GETSET_PROPERTY(winrt::Windows::UI::Xaml::Controls::IconSource, IconSource, nullptr);
GETSET_PROPERTY(winrt::TerminalApp::Command, SwitchToTabCommand, nullptr);
GETSET_PROPERTY(uint32_t, TabViewIndex, 0);
GETSET_PROPERTY(winrt::Microsoft::UI::Xaml::Controls::TabViewItem, TabViewItem, nullptr);
GETSET_PROPERTY(winrt::Windows::UI::Xaml::Controls::Page, Content, nullptr);

Expand All @@ -37,7 +46,6 @@ namespace winrt::TerminalApp::implementation

void _MakeTabViewItem();
void _CreateContextMenu();
void _MakeSwitchToTabCommand();
winrt::fire_and_forget _CreateIcon();
};
}
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
<Import Project="..\..\..\common.openconsole.props" Condition="'$(OpenConsoleDir)'==''" />
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.pre.props" />
<Import Project="..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props" Condition="Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" />

<ItemDefinitionGroup>
<ClCompile>
<!-- For CLI11: It uses dynamic_cast to cast types around, which depends
on being compiled with RTTI (/GR). -->
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
</ItemDefinitionGroup>

<!-- ========================= XAML files ======================== -->
<ItemGroup>
<!-- HERE BE DRAGONS:
Expand Down Expand Up @@ -385,6 +387,7 @@
</ItemDefinitionGroup>
<!-- ========================= Globals ======================== -->
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />

<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.200609001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.200609001\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand All @@ -394,6 +397,7 @@
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.200609001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.200609001\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
</Target>

<!--
By default, the PRI file will contain resource paths beginning with the
project name. Since we enabled XBF embedding, this *also* includes App.xbf.
Expand Down Expand Up @@ -427,5 +431,6 @@
<Target Name="_TerminalAppGenerateUserSettingsH" Inputs="userDefaults.json" Outputs="Generated Files\userDefaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile –ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1 -JsonFile userDefaults.json -OutPath '&quot;Generated Files\userDefaults.h&quot;' -VariableName UserSettingsJson" />
</Target>

<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
</Project>
Loading