Skip to content

Commit 14a00c8

Browse files
committed
lots of cleanup
1 parent 02a5593 commit 14a00c8

File tree

4 files changed

+22
-99
lines changed

4 files changed

+22
-99
lines changed

src/cascadia/TerminalApp/TasksPaneContent.cpp

+8-16
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,24 @@ namespace winrt::TerminalApp::implementation
3434
{
3535
const auto& queryString = _filterBox().Text();
3636

37-
// You'd think that `FilterToSendInput(queryString)` would work. It
38-
// doesn't! That uses the queryString as the current command the user
39-
// has typed, then relies on the sxnui to _also_ filter with that
40-
// string.
41-
42-
// In the fullness of time, we'll actually want to filter things here.
43-
// Probably with something that re-uses the suggestions control list
44-
//
45-
// huh. now that's a thought.
46-
47-
// const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(L""); // IVector<Model::Command>
48-
// auto itemSource = winrt::single_threaded_observable_vector<TerminalApp::FilteredTask>();
37+
// DON'T replace the itemSource here. If you do, it'll un-expand all the
38+
// nested items the user has expanded. Instead, just update the filter.
39+
// That'll also trigger a PropertyChanged for the Visibility property.
4940
for (const auto& t : _allTasks)
5041
{
51-
// const auto& filtered{ winrt::make<FilteredTask>(t) };
5242
t.UpdateFilter(queryString);
53-
// itemSource.Append(filtered);
5443
}
55-
56-
// _treeView().ItemsSource(itemSource);
5744
}
5845

5946
void TasksPaneContent::UpdateSettings(const CascadiaSettings& settings)
6047
{
6148
_settings = settings;
6249

50+
// You'd think that `FilterToSendInput(queryString)` would work. It
51+
// doesn't! That uses the queryString as the current command the user
52+
// has typed, then relies on the sxnui to _also_ filter with that
53+
// string.
54+
6355
const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(L""); // IVector<Model::Command>
6456
_allTasks = winrt::single_threaded_observable_vector<TerminalApp::FilteredTask>();
6557
for (const auto& t : tasks)

src/cascadia/TerminalApp/TasksPaneContent.h

+7-48
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace winrt::TerminalApp::implementation
2323
void Close();
2424
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const;
2525

26-
winrt::hstring Title() { return L"Scratchpad"; }
26+
// TODO! lots of strings here and in XAML that need RS_-ifying
27+
winrt::hstring Title() { return L"Tasks"; }
2728
uint64_t TaskbarState() { return 0; }
2829
uint64_t TaskbarProgress() { return 0; }
2930
bool ReadOnly() { return false; }
@@ -58,42 +59,6 @@ namespace winrt::TerminalApp::implementation
5859
void _updateFilteredCommands();
5960
};
6061

61-
struct TaskViewModel : TaskViewModelT<TaskViewModel>
62-
{
63-
TaskViewModel(const winrt::Microsoft::Terminal::Settings::Model::Command& command) :
64-
_command{ command }
65-
{
66-
// The Children() method must always return a non-null vector
67-
_children = winrt::single_threaded_observable_vector<TerminalApp::TaskViewModel>();
68-
if (_command.HasNestedCommands())
69-
{
70-
for (const auto& [_, child] : _command.NestedCommands())
71-
{
72-
auto vm{ winrt::make<TaskViewModel>(child) };
73-
_children.Append(vm);
74-
}
75-
}
76-
}
77-
78-
winrt::hstring Name() { return _command.Name(); }
79-
winrt::hstring IconPath() { return _command.IconPath(); }
80-
winrt::hstring Input()
81-
{
82-
if (const auto& sendInput{ _command.ActionAndArgs().Args().try_as<winrt::Microsoft::Terminal::Settings::Model::SendInputArgs>() })
83-
{
84-
return sendInput.Input();
85-
}
86-
return L"";
87-
};
88-
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::TaskViewModel> Children() { return _children; }
89-
winrt::Microsoft::Terminal::Settings::Model::Command Command() { return _command; }
90-
91-
private:
92-
winrt::Microsoft::Terminal::Settings::Model::Command _command{ nullptr };
93-
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::TaskViewModel> _children{ nullptr };
94-
};
95-
96-
// struct FilteredTask : public winrt::TerminalApp::implementation::FilteredCommand, FilteredTaskT<FilteredTask, FilteredCommand>
9762
struct FilteredTask : FilteredTaskT<FilteredTask, TerminalApp::implementation::FilteredCommand>
9863
{
9964
FilteredTask() = default;
@@ -115,9 +80,6 @@ namespace winrt::TerminalApp::implementation
11580
}
11681
}
11782

118-
// FilteredCommand() = default;
119-
// FilteredCommand(const winrt::TerminalApp::PaletteItem& item);
120-
12183
void UpdateFilter(const winrt::hstring& filter) override
12284
{
12385
TerminalApp::implementation::FilteredCommand::UpdateFilter(filter);
@@ -129,14 +91,6 @@ namespace winrt::TerminalApp::implementation
12991
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Visibility" });
13092
}
13193

132-
// static int Compare(const winrt::TerminalApp::FilteredCommand& first, const winrt::TerminalApp::FilteredCommand& second);
133-
134-
// WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
135-
// WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::PaletteItem, Item, _PropertyChangedHandlers, nullptr);
136-
// WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Filter, _PropertyChangedHandlers);
137-
// WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::HighlightedText, HighlightedName, _PropertyChangedHandlers);
138-
// WINRT_OBSERVABLE_PROPERTY(int, Weight, _PropertyChangedHandlers);
139-
14094
winrt::hstring Input()
14195
{
14296
if (const auto& actionItem{ _Item.try_as<winrt::TerminalApp::ActionPaletteItem>() })
@@ -155,12 +109,17 @@ namespace winrt::TerminalApp::implementation
155109
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::FilteredTask> Children() { return _children; }
156110
winrt::Microsoft::Terminal::Settings::Model::Command Command() { return _command; }
157111

112+
// Used to control if this item is visible in the TreeView. Turns out,
113+
// TreeView is in fact sane enough to remove items entirely if they're
114+
// Collapsed.
158115
winrt::Windows::UI::Xaml::Visibility Visibility()
159116
{
117+
// Is there no filter, or do we match it?
160118
if (_Filter.empty() || _Weight > 0)
161119
{
162120
return winrt::Windows::UI::Xaml::Visibility::Visible;
163121
}
122+
// If we don't match, maybe one of our children does
164123
auto totalWeight = _Weight;
165124
for (const auto& c : _children)
166125
{

src/cascadia/TerminalApp/TasksPaneContent.xaml

+7-25
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
<ResourceDictionary>
2121
<model:IconPathConverter x:Key="IconSourceConverter" />
2222

23-
<DataTemplate x:Key="ListItemTemplate"
24-
x:DataType="local:FilteredCommand">
25-
<ListViewItem Height="32"
26-
MinHeight="0"
27-
Padding="16,0,12,0"
28-
HorizontalContentAlignment="Stretch"
29-
AutomationProperties.AcceleratorKey="{x:Bind Item.KeyChordText, Mode=OneWay}"
30-
AutomationProperties.Name="{x:Bind Item.Name, Mode=OneWay}"
31-
FontSize="12" />
32-
</DataTemplate>
3323
<DataTemplate x:Key="TaskItemTemplate"
3424
x:DataType="local:FilteredTask">
3525
<mux:TreeViewItem x:Name="rootItem"
@@ -44,20 +34,14 @@
4434
<ColumnDefinition Width="Auto" />
4535
<ColumnDefinition Width="*" />
4636
</Grid.ColumnDefinitions>
37+
4738
<ContentPresenter Grid.Column="0">
4839
<IconSourceElement Width="16"
4940
Height="16"
5041
IconSource="{x:Bind Item.Icon, Converter={StaticResource IconSourceConverter}}"
5142
Visibility="Collapsed" />
5243
</ContentPresenter>
53-
<!-- <Ellipse x:Name="Ellipse"
54-
Grid.RowSpan="2"
55-
Width ="32"
56-
Height="32"
57-
Margin="6"
58-
VerticalAlignment="Center"
59-
HorizontalAlignment="Center"
60-
Fill="{ThemeResource SystemControlBackgroundBaseMediumBrush}"/>-->
44+
6145
<Button Grid.Row="0"
6246
Grid.RowSpan="1"
6347
Grid.Column="0"
@@ -72,7 +56,11 @@
7256
<FontIcon FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets"
7357
FontSize="12"
7458
Glyph="&#xE768;" />
75-
<!-- xF5B0 is PlaySolid, also a good option. Seemed better to have a lightweight outline though -->
59+
<!--
60+
xE768 is Play, which is just an outline.
61+
xF5B0 is PlaySolid, also a good option. Seemed
62+
better to have a lightweight outline though
63+
-->
7664
</Button.Content>
7765

7866
<Button.Resources>
@@ -109,12 +97,6 @@
10997
</Button.Resources>
11098
</Button>
11199

112-
<!-- <TextBlock Grid.Column="1"
113-
Margin="12,6,0,0"
114-
Style="{ThemeResource BaseTextBlockStyle}"
115-
Text="{x:Bind Item.Name, Mode=OneWay}"
116-
TextWrapping="WrapWholeWords" />-->
117-
118100
<local:HighlightedTextControl Grid.Column="1"
119101
HorizontalAlignment="Left"
120102
Text="{x:Bind HighlightedName, Mode=OneWay}" />

src/cascadia/TerminalApp/TerminalPaneContent.idl

-10
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ namespace TerminalApp
2929
SettingsPaneContent(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
3030
}
3131

32-
[default_interface] runtimeclass TaskViewModel
33-
{
34-
TaskViewModel(Microsoft.Terminal.Settings.Model.Command command);
35-
String Name{ get; };
36-
String IconPath{ get; };
37-
String Input{ get; };
38-
Microsoft.Terminal.Settings.Model.Command Command{ get; };
39-
Windows.Foundation.Collections.IObservableVector<TaskViewModel> Children { get; };
40-
41-
}
4232
[default_interface] runtimeclass FilteredTask : TerminalApp.FilteredCommand
4333
{
4434
String Input{ get; };

0 commit comments

Comments
 (0)