Skip to content

Commit

Permalink
[Redesign] Replace TextBoxes w/ TextBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Oct 1, 2024
1 parent bd038c3 commit 45e80b6
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 23 deletions.
11 changes: 11 additions & 0 deletions src/cascadia/TerminalSettingsEditor/CommonResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@
<Setter Property="TextWrapping" Value="Wrap" />
</Style>

<!-- Text Block -->
<Style x:Key="TextBlockSettingStyle"
BasedOn="{StaticResource BaseTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="MinWidth" Value="{StaticResource StandardBoxMinWidth}" />
<Setter Property="MaxWidth" Value="400" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>

<Style x:Key="TextBlockSubHeaderStyle"
BasedOn="{StaticResource SubtitleTextBlockStyle}"
TargetType="TextBlock">
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

void ProfileViewModel::RequestAddBellSound()
Editor::BellSoundViewModel ProfileViewModel::RequestAddBellSound()
{
// If we were inheriting our bell sound,
// copy it over to the current layer and apply modifications
Expand All @@ -514,6 +514,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
vm.PropertyChanged({ this, &ProfileViewModel::_BellSoundVMPropertyChanged });
_CurrentBellSounds.Append(vm);
_NotifyChanges(L"CurrentBellSounds");

return vm;
}

void ProfileViewModel::RequestDeleteBellSound(const Editor::BellSoundViewModel& vm)
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsEditor/ProfileViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference<bool> on);

hstring BellSoundPreview();
void RequestAddBellSound();
Editor::BellSoundViewModel RequestAddBellSound();
void RequestDeleteBellSound(const Editor::BellSoundViewModel& vm);

void SetAcrylicOpacityPercentageValue(double value)
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Microsoft.Terminal.Settings.Editor

String BellSoundPreview { get; };
Windows.Foundation.Collections.IObservableVector<BellSoundViewModel> CurrentBellSounds { get; };
void RequestAddBellSound();
BellSoundViewModel RequestAddBellSound();
void RequestDeleteBellSound(BellSoundViewModel vm);

IInspectable CurrentAntiAliasingMode;
Expand Down
28 changes: 20 additions & 8 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,25 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
CATCH_LOG();

safe_void_coroutine Profiles_Advanced::BellSoundBrowse_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
void Profiles_Advanced::BellSoundBrowse_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
{
auto vm = sender.as<Button>().Tag().as<Editor::BellSoundViewModel>();
_PickFileForBellSound(vm);
}

void Profiles_Advanced::BellSoundDelete_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
{
auto bellSoundEntry = sender.as<Button>().Tag().as<Editor::BellSoundViewModel>();
_Profile.RequestDeleteBellSound(bellSoundEntry);
}

void Profiles_Advanced::BellSoundAdd_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
{
auto bellSoundVM = _Profile.RequestAddBellSound();
_PickFileForBellSound(bellSoundVM);
}

safe_void_coroutine Profiles_Advanced::_PickFileForBellSound(Editor::BellSoundViewModel& vm)
{
static constexpr COMDLG_FILTERSPEC supportedFileTypes[] = {
{ L"Sound Files (*.wav;*.mp3;*.flac)", L"*.wav;*.mp3;*.flac" },

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

flac is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

flac is not a recognized word. (unrecognized-spelling)
Expand All @@ -93,13 +111,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
});
if (!file.empty())
{
sender.as<Button>().Tag().as<Editor::BellSoundViewModel>().Path(file);
vm.Path(file);
}
}

void Profiles_Advanced::BellSoundDelete_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
{
auto bellSoundEntry = sender.as<Button>().Tag().as<Editor::BellSoundViewModel>();
_Profile.RequestDeleteBellSound(bellSoundEntry);
}
}
5 changes: 4 additions & 1 deletion src/cascadia/TerminalSettingsEditor/Profiles_Advanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedFrom(const Windows::UI::Xaml::Navigation::NavigationEventArgs& e);

safe_void_coroutine BellSoundAudioPreview_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
safe_void_coroutine BellSoundBrowse_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void BellSoundBrowse_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void BellSoundDelete_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void BellSoundAdd_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);

til::property_changed_event PropertyChanged;
Editor::IHostedInWindow WindowRoot() { return _windowRoot; };
Expand All @@ -30,6 +31,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Editor::IHostedInWindow _windowRoot;
winrt::Windows::Media::Playback::MediaPlayer _bellPlayer{ nullptr };
bool _bellPlayerCreated{ false };

safe_void_coroutine _PickFileForBellSound(Editor::BellSoundViewModel& vm);
};
};

Expand Down
13 changes: 6 additions & 7 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,15 @@
<DataTemplate x:DataType="local:BellSoundViewModel">
<Grid TabFocusNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Uid="Profile_BellSoundPath"
Grid.Column="0"
IsSpellCheckEnabled="False"
Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind Path=Path, Mode=TwoWay}" />
<TextBlock x:Uid="Profile_BellSoundPath"
Grid.Column="0"
Style="{StaticResource TextBlockSettingStyle}"
Text="{x:Bind Path=Path, Mode=TwoWay}" />
<Button x:Uid="Profile_BellSoundAudioPreview"
Grid.Column="1"
Margin="5,0,0,0"
Expand Down Expand Up @@ -177,7 +176,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Click="{x:Bind Profile.RequestAddBellSound}">
<Button Click="BellSoundAdd_Click">
<StackPanel Orientation="Horizontal">
<FontIcon FontSize="{StaticResource StandardIconSize}"
Glyph="&#xE948;" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1855,10 +1855,6 @@
<value>Controls what sound is played when the application emits a BEL character.</value>
<comment>A description for what the "bell sound" setting does. Presented near "Profile_BellSound".{Locked="BEL"}</comment>
</data>
<data name="Profile_BellSoundPath.PlaceholderText" xml:space="preserve">
<value>Path to sound file</value>
<comment>Placeholder text for a text box that is used to set the path to the sound file that will be used. Presented near the "Profile_BellSound" setting.</comment>
</data>
<data name="Profile_AddBellSound.Text" xml:space="preserve">
<value>Add sound</value>
<comment>Text label for a button that adds a sound to the bell sound list. Presented near "Profile_BellSound"</comment>
Expand Down

1 comment on commit 45e80b6

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (1)

flac

Previously acknowledged words that are now absent vtio vtpt 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/cazamor/SUI/bell-sound branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/11133273072/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2221) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (1)

Dictionary Entries Covers Uniquely
cspell:cpp/src/lang-jargon.txt 11 1 1
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:cpp/src/lang-jargon.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 6

See ❌ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.