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

Hide incomplete settings UI features #8078

Merged
3 commits merged into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 0 additions & 40 deletions src/cascadia/TerminalSettingsEditor/Home.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/cascadia/TerminalSettingsEditor/Home.h

This file was deleted.

13 changes: 0 additions & 13 deletions src/cascadia/TerminalSettingsEditor/Home.idl

This file was deleted.

79 changes: 0 additions & 79 deletions src/cascadia/TerminalSettingsEditor/Home.xaml

This file was deleted.

15 changes: 0 additions & 15 deletions src/cascadia/TerminalSettingsEditor/HomeGridItem.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions src/cascadia/TerminalSettingsEditor/HomeGridItem.h

This file was deleted.

11 changes: 0 additions & 11 deletions src/cascadia/TerminalSettingsEditor/HomeGridItem.idl

This file was deleted.

104 changes: 3 additions & 101 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
#include "Home.h"
#include "Globals.h"
#include "Launch.h"
#include "Interaction.h"
Expand Down Expand Up @@ -36,34 +35,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// this section will clone the active AppSettings
MainPage::_settingsSource = settings;
_settingsClone = nullptr;

SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Add new profile"), L"AddNew_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Always show tabs"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Color scheme"), L"ColorSchemes_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Columns on first launch"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Copy after selection is made"), L"Interaction_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Copy formatting"), L"Interaction_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Default profile"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Disable dynamic profiles"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Global appearance"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Global profile settings"), L"GlobalProfile_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Hide close all tabs popup"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Interaction"), L"Interaction_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Keyboard"), L"Keyboard_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Launch"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Launch on startup"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Launch position"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Launch size"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Rendering"), L"Rendering_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Rows on first launch"), L"Launch_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Screen redrawing"), L"Rendering_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Show terminal title in title bar"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Show the title bar"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Software rendering"), L"Rendering_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Tab width mode"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Theme"), L"GlobalAppearance_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Window resize behavior"), L"Rendering_Nav"));
SearchList.insert(std::pair<IInspectable, hstring>(Windows::Foundation::PropertyValue::CreateString(L"Word delimiters"), L"Interaction_Nav"));
}

CascadiaSettings MainPage::Settings()
Expand All @@ -77,7 +48,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
for (uint32_t i = 0; i < SettingsNav().MenuItems().Size(); i++)
{
const auto item = SettingsNav().MenuItems().GetAt(i).as<Controls::ContentControl>();
const hstring homeNav = L"Home_Nav";
const hstring homeNav = L"General_Nav";
const hstring itemTag = unbox_value<hstring>(item.Tag());

if (itemTag == homeNav)
Expand All @@ -87,7 +58,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

contentFrame().Navigate(xaml_typename<Editor::Home>());
contentFrame().Navigate(xaml_typename<Editor::Launch>());
}

void MainPage::SettingsNav_ItemInvoked(MUX::Controls::NavigationView const&, MUX::Controls::NavigationViewItemInvokedEventArgs const& args)
Expand Down Expand Up @@ -123,67 +94,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return true;
}

void MainPage::AutoSuggestBox_TextChanged(IInspectable const& sender, const Controls::AutoSuggestBoxTextChangedEventArgs args)
{
Controls::AutoSuggestBox autoBox = sender.as<Controls::AutoSuggestBox>();
auto query = autoBox.Text();
SearchSettings(query, autoBox);
}

void MainPage::AutoSuggestBox_QuerySubmitted(const Controls::AutoSuggestBox sender, const Controls::AutoSuggestBoxQuerySubmittedEventArgs args)
{
auto value = args.QueryText();
}

void MainPage::AutoSuggestBox_SuggestionChosen(const Controls::AutoSuggestBox sender, const Controls::AutoSuggestBoxSuggestionChosenEventArgs args)
{
auto selectItem = args.SelectedItem().as<Windows::Foundation::IPropertyValue>().GetString();
Controls::AutoSuggestBox autoBox = sender.as<Controls::AutoSuggestBox>();

Navigate(contentFrame(), SearchList.at(args.SelectedItem()));
}

void MainPage::SearchSettings(hstring query, Controls::AutoSuggestBox& autoBox)
{
Windows::Foundation::Collections::IVector<IInspectable> suggestions = single_threaded_vector<IInspectable>();
std::vector<IInspectable> rawSuggestions;

for (auto it = SearchList.begin(); it != SearchList.end(); ++it)
{
auto value = it->first;
hstring item = value.as<Windows::Foundation::IPropertyValue>().GetString();

std::string tmp = winrt::to_string(item);
std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](auto c) { return static_cast<char>(std::tolower(c)); });
item = winrt::to_hstring(tmp);

std::string tmp2 = winrt::to_string(query);
std::transform(tmp2.begin(), tmp2.end(), tmp2.begin(), [](auto c) { return static_cast<char>(std::tolower(c)); });
query = winrt::to_hstring(tmp2);

if (std::wcsstr(item.c_str(), query.c_str()))
{
rawSuggestions.emplace_back(value);
}
}

// perform sort comparing strings inside of IPropertyValues
std::sort(rawSuggestions.begin(), rawSuggestions.end(), [](const IInspectable& a, const IInspectable& b) -> bool {
return a.as<IPropertyValue>().GetString() < b.as<IPropertyValue>().GetString();
});

// Pass all elements from rawSuggestions to suggestions
for (const auto& suggestion : rawSuggestions)
{
suggestions.Append(suggestion);
}

autoBox.ItemsSource(suggestions);
}

void MainPage::Navigate(Controls::Frame contentFrame, hstring clickedItemTag)
{
const hstring homePage = L"Home_Nav";
const hstring generalPage = L"General_Nav";
const hstring launchSubpage = L"Launch_Nav";
const hstring interactionSubpage = L"Interaction_Nav";
Expand All @@ -197,13 +109,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const hstring colorSchemesPage = L"ColorSchemes_Nav";
const hstring globalAppearancePage = L"GlobalAppearance_Nav";

const hstring keybindingsPage = L"Keyboard_Nav";

if (clickedItemTag == homePage)
{
contentFrame.Navigate(xaml_typename<Editor::Home>());
}
else if (clickedItemTag == launchSubpage)
if (clickedItemTag == launchSubpage)
{
contentFrame.Navigate(xaml_typename<Editor::Launch>());
}
Expand Down Expand Up @@ -231,9 +137,5 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
contentFrame.Navigate(xaml_typename<Editor::GlobalAppearance>());
}
else if (clickedItemTag == keybindingsPage)
{
contentFrame.Navigate(xaml_typename<Editor::Keybindings>());
}
}
}
7 changes: 0 additions & 7 deletions src/cascadia/TerminalSettingsEditor/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
bool On_BackRequested();
static void Navigate(Windows::UI::Xaml::Controls::Frame contentFrame, hstring clickedItemTag);

std::map<IInspectable, hstring> SearchList;

void AutoSuggestBox_TextChanged(Windows::Foundation::IInspectable const& sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxTextChangedEventArgs args);
void AutoSuggestBox_QuerySubmitted(const winrt::Windows::UI::Xaml::Controls::AutoSuggestBox sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxQuerySubmittedEventArgs args);
void AutoSuggestBox_SuggestionChosen(const winrt::Windows::UI::Xaml::Controls::AutoSuggestBox sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxSuggestionChosenEventArgs args);
void SearchSettings(hstring query, winrt::Windows::UI::Xaml::Controls::AutoSuggestBox& autoBox);

static winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings Settings();

private:
Expand Down
Loading