Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

fix(ui): keep translated preset choices readable in narrow dialogs

BlackSpiritse739128e7450
diff --git a/src/Filee.App/Views/PresetEditorView.axaml b/src/Filee.App/Views/PresetEditorView.axaml
index 8c81df87..470d8fb9 100644
--- a/src/Filee.App/Views/PresetEditorView.axaml
+++ b/src/Filee.App/Views/PresetEditorView.axaml
@@ -8,6 +8,15 @@
x:Class="Filee.App.Views.PresetEditorView"
x:DataType="vm:PresetEditorViewModel">
<UserControl.Styles>
+ <!-- Translated choices can need more than one line, particularly in the 440 px preset dialog. -->
+ <Style Selector="ComboBox:not(.targets)">
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+ <Setter Property="ItemTemplate">
+ <DataTemplate x:DataType="vm:IChoice">
+ <TextBlock Text="{Binding Label}" TextWrapping="Wrap" />
+ </DataTemplate>
+ </Setter>
+ </Style>
<!-- Target list: the category sits right-aligned next to each format name. -->
<Style Selector="ComboBox.targets ComboBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
diff --git a/tests/Filee.App.Tests/CropOverlayTests.cs b/tests/Filee.App.Tests/CropOverlayTests.cs
index 9706f0f2..13a32856 100644
--- a/tests/Filee.App.Tests/CropOverlayTests.cs
+++ b/tests/Filee.App.Tests/CropOverlayTests.cs
@@ -27,6 +27,7 @@ public class CropOverlayTests
public static TheoryData<string, bool> Looks => new()
{
{ "en", false }, { "en", true }, { "ko", false }, { "ko", true }, { "ru", false }, { "hi", true }, { "ar", false }, { "ar", true },
+ { "pt-PT", false }, { "pt-PT", true }, { "pt-BR", false }, { "pt-BR", true },
};
[AvaloniaTheory]
diff --git a/tests/Filee.App.Tests/MergeOrderTests.cs b/tests/Filee.App.Tests/MergeOrderTests.cs
index 1df71420..99a0eef4 100644
--- a/tests/Filee.App.Tests/MergeOrderTests.cs
+++ b/tests/Filee.App.Tests/MergeOrderTests.cs
@@ -126,6 +126,8 @@ public class MergeOrderTests
[InlineData("pl")]
[InlineData("hi")]
[InlineData("ru")]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
public void Chooser_fits_long_paths_at_its_minimum_width(string language)
{
TestServices.EnsureInitialized(language);
diff --git a/tests/Filee.App.Tests/PortugueseRenderTests.cs b/tests/Filee.App.Tests/PortugueseRenderTests.cs
index 43613077..4dc95eb1 100644
--- a/tests/Filee.App.Tests/PortugueseRenderTests.cs
+++ b/tests/Filee.App.Tests/PortugueseRenderTests.cs
@@ -10,12 +10,63 @@ using Filee.App.Services;
using Filee.App.ViewModels;
using Filee.App.Views;
using Filee.Core.Localization;
+using Filee.Core.Presets;
using Filee.Core.Settings;
namespace Filee.App.Tests;
public class PortugueseRenderTests
{
+ [AvaloniaTheory]
+ [InlineData("pt-PT", 440, "mp4-720")]
+ [InlineData("pt-BR", 440, "mp4-720")]
+ [InlineData("pt-PT", 560, "mp4-720")]
+ [InlineData("pt-BR", 560, "mp4-720")]
+ [InlineData("pt-PT", 440, "compress-pdf")]
+ [InlineData("pt-BR", 440, "compress-pdf")]
+ [InlineData("pt-PT", 560, "compress-pdf")]
+ [InlineData("pt-BR", 560, "compress-pdf")]
+ [InlineData("pt-PT", 440, "half-size")]
+ [InlineData("pt-BR", 440, "half-size")]
+ [InlineData("pt-PT", 560, "half-size")]
+ [InlineData("pt-BR", 560, "half-size")]
+ [InlineData("en", 440, "mp4-720")]
+ [InlineData("en", 440, "compress-pdf")]
+ [InlineData("en", 440, "half-size")]
+ public void Translated_choices_fit_in_the_preset_dialog(string language, int width, string preset)
+ {
+ TestServices.EnsureInitialized(language);
+ var loc = AppHost.Get<ILocalizer>();
+ var vm = new PresetEditorViewModel(AppHost.Get<UserDataStore>().FindPreset(preset)!, loc);
+ if (vm.ShowMediaQuality)
+ vm.MediaQuality = vm.MediaQualities.Single(q => q.Value == MediaQuality.Small);
+ if (vm.ShowPdfCompression)
+ vm.CompressionLevel = vm.CompressionLevels.Single(q => q.Value == PdfCompression.Screen);
+ var window = new PresetEditorWindow { DataContext = vm, Width = width, Height = 820 };
+ try
+ {
+ window.Show();
+ RenderTests.Pump();
+ RenderTests.Save(window, $"portuguese-preset-{preset}-{language}-{width}.png");
+ var boxes = window.GetVisualDescendants().OfType<ComboBox>()
+ .Where(c => c.IsEffectivelyVisible && !c.Classes.Contains("targets"));
+ Assert.NotEmpty(boxes);
+ foreach (var box in boxes)
+ {
+ var choice = Assert.IsAssignableFrom<IChoice>(box.SelectedItem);
+ var text = box.GetVisualDescendants().OfType<TextBlock>().Single(t => t.Text == choice.Label);
+ // A wrapped line may retain a trailing space outside its width; only the rendered text matters.
+ Assert.True(text.TextLayout.Width <= text.Bounds.Width + 1 &&
+ text.TextLayout.Height <= text.Bounds.Height + 1,
+ $"{language} at {width}px: '{text.Text}' is cut off ({text.TextLayout.Width}×{text.TextLayout.Height} in {text.Bounds.Size})");
+ }
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+
[AvaloniaTheory]
[InlineData("pt-PT")]
[InlineData("pt-BR")]
diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.cs
index 53ea0b9d..88496ec8 100644
--- a/tests/Filee.App.Tests/RenderTests.cs
+++ b/tests/Filee.App.Tests/RenderTests.cs
@@ -209,6 +209,8 @@ public class RenderTests
[InlineData("ko")]
[InlineData("ru")]
[InlineData("ar")]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
public void Watch_folder_options_rename_and_filter_with_a_preview(string language)
{
TestServices.EnsureInitialized(language);
@@ -1884,6 +1886,8 @@ public class RenderTests
[InlineData("zh-CN")]
[InlineData("ru")]
[InlineData("ar")]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
public void Live_photo_options_render_for_jpg_and_heic_and_save_only_there(string language)
{
TestServices.EnsureInitialized(language);