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.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Theme page: the donut's opacity, labelled and live in the preview (#276)
KnifeLemon8083233234a2
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 87e01d60..e5554b2a 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -601,6 +601,7 @@"theme.accent": "Accent colour","theme.custom_color": "Custom","theme.corner_radius": "Softness",+ "theme.donut_opacity": "Donut toolbar opacity","theme.reduce_motion": "Reduce animations","theme.reduce_motion_hint": "Recommended for older PCs. Turns off transitions and the donut's bounce.","theme.preview": "Preview",diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.jsonindex 41e92942..b85e6842 100644--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@ -585,6 +585,7 @@"theme.accent": "Color de acento","theme.custom_color": "Personalizado","theme.corner_radius": "Redondeo",+ "theme.donut_opacity": "Opacidad del menú circular","theme.reduce_motion": "Reducir las animaciones","theme.reduce_motion_hint": "Recomendado para PC antiguos. Desactiva las transiciones y el rebote del menú circular.","theme.preview": "Vista previa",diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.jsonindex 693f5653..562e9a5e 100644--- a/src/Filee.App/Assets/i18n/hi.json+++ b/src/Filee.App/Assets/i18n/hi.json@@ -585,6 +585,7 @@"theme.accent": "एक्सेंट रंग","theme.custom_color": "कस्टम","theme.corner_radius": "कोमलता",+ "theme.donut_opacity": "डोनट टूलबार की अपारदर्शिता","theme.reduce_motion": "एनिमेशन कम करें","theme.reduce_motion_hint": "पुराने PC के लिए अनुशंसित। ट्रांज़िशन और डोनट की उछाल बंद कर देता है।","theme.preview": "प्रीव्यू",diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.jsonindex 88ce8cc4..77682001 100644--- a/src/Filee.App/Assets/i18n/ja.json+++ b/src/Filee.App/Assets/i18n/ja.json@@ -585,6 +585,7 @@"theme.accent": "アクセントカラー","theme.custom_color": "カスタム","theme.corner_radius": "角の丸み",+ "theme.donut_opacity": "ドーナツメニューの不透明度","theme.reduce_motion": "アニメーションを減らす","theme.reduce_motion_hint": "古いPCにおすすめです。画面切り替え時のアニメーションと、ドーナツメニューの弾む動きを無効にします。","theme.preview": "プレビュー",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 4b8e1284..de082e6c 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -601,6 +601,7 @@"theme.accent": "강조색","theme.custom_color": "직접 선택","theme.corner_radius": "말랑함",+ "theme.donut_opacity": "원형 툴바 불투명도","theme.reduce_motion": "애니메이션 줄이기","theme.reduce_motion_hint": "저사양 PC에 권장해요. 전환 효과와 도넛의 튕김 효과를 꺼요.","theme.preview": "미리보기",diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex 09fe62ba..83f23d34 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -601,6 +601,7 @@"theme.accent": "Kolor akcentu","theme.custom_color": "Własny","theme.corner_radius": "Zaokrąglenie",+ "theme.donut_opacity": "Krycie paska-pierścienia","theme.reduce_motion": "Ogranicz animacje","theme.reduce_motion_hint": "Zalecane na starszych komputerach. Wyłącza przejścia i odbijanie pierścienia.","theme.preview": "Podgląd",diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.jsonindex e95a938a..11991d36 100644--- a/src/Filee.App/Assets/i18n/ru.json+++ b/src/Filee.App/Assets/i18n/ru.json@@ -601,6 +601,7 @@"theme.accent": "Акцентный цвет","theme.custom_color": "Свой","theme.corner_radius": "Скругление",+ "theme.donut_opacity": "Непрозрачность кругового меню","theme.reduce_motion": "Меньше анимации","theme.reduce_motion_hint": "Рекомендуется для старых компьютеров. Отключает переходы и подпрыгивание кругового меню.","theme.preview": "Предпросмотр",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 41b0b659..43f387bb 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -601,6 +601,7 @@"theme.accent": "强调色","theme.custom_color": "自定义","theme.corner_radius": "圆角",+ "theme.donut_opacity": "环形工具栏不透明度","theme.reduce_motion": "减少动画","theme.reduce_motion_hint": "适合配置较低的电脑。关闭过渡效果和圆环的弹跳效果。","theme.preview": "预览",diff --git a/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs b/src/Filee.App/ViewModels/Pages/ThemePageViewModel.csindex badc7bc3..49553eba 100644--- a/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs@@ -1,5 +1,6 @@-// Theme: light/dark, accent colour, softness (corner radius), reduce animations. Changes apply live.+// Theme: light/dark, accent colour, softness (corner radius), the donut's opacity, reduce animations. Changes apply live.+using Avalonia;using Avalonia.Media;using CommunityToolkit.Mvvm.ComponentModel;using CommunityToolkit.Mvvm.Input;@@ -26,6 +27,7 @@ public sealed partial class ThemePageViewModel : ObservableObjectAccent = Color.TryParse(theme.Accent, out var c) ? c : Colors.MediumPurple;AccentHex = $"#{Accent.R:X2}{Accent.G:X2}{Accent.B:X2}";CornerRadius = theme.CornerRadius;+ DonutOpacity = Math.Round(Math.Clamp(store.Settings.Donut.Opacity, DonutSettings.MinOpacity, 1) * 100);ReduceMotion = theme.ReduceMotion ?? platform.PrefersReducedMotion;PreviewItems =[@@ -44,13 +46,35 @@ public sealed partial class ThemePageViewModel : ObservableObjectpublic IReadOnlyList<DonutItem> PreviewItems { get; }[ObservableProperty] private Choice<ThemeMode> _mode = null!;- [ObservableProperty, NotifyPropertyChangedFor(nameof(AccentBrush))] private Color _accent;+ [ObservableProperty, NotifyPropertyChangedFor(nameof(AccentBrush), nameof(PreviewBackdrop))] private Color _accent;[ObservableProperty] private string _accentHex = "";public IBrush AccentBrush => new SolidColorBrush(Accent);++ /// <summary>+ /// What the preview donut floats on, standing in for the desktop: a gradient of the accent, so the slices'+ /// opacity shows (on the plain card, slices of its own colour look the same at any opacity).+ /// </summary>+ public IBrush PreviewBackdrop => new LinearGradientBrush+ {+ StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),+ EndPoint = new RelativePoint(1, 1, RelativeUnit.Relative),+ GradientStops =+ {+ new GradientStop(ThemeService.Shade(Accent, 0.55), 0),+ new GradientStop(Accent, 0.5),+ new GradientStop(ThemeService.Shade(Accent, -0.45), 1),+ },+ };[ObservableProperty] private double _cornerRadius;[ObservableProperty] private bool _reduceMotion;+ /// <summary>+ /// The donut toolbar's opacity in percent: the one setting Donut toolbar → Appearance → Opacity edits too (each+ /// page reads it when it opens). The preview donut follows it at once, the toolbar the next time it opens.+ /// </summary>+ [ObservableProperty] private double _donutOpacity;+partial void OnModeChanged(Choice<ThemeMode>? oldValue, Choice<ThemeMode> newValue){if (!Choices.Restore(oldValue, newValue, v => Mode = v))@@ -73,6 +97,14 @@ public sealed partial class ThemePageViewModel : ObservableObjectpartial void OnCornerRadiusChanged(double value) => Save(t => t.CornerRadius = Math.Round(value));partial void OnReduceMotionChanged(bool value) => Save(t => t.ReduceMotion = value);+ partial void OnDonutOpacityChanged(double value)+ {+ if (_loading)+ return;+ _store.Settings.Donut.Opacity = Math.Round(value) / 100;+ _store.SaveSettings();+ }+[RelayCommand]private void PickSwatch(Color color) => Accent = color;diff --git a/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs b/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.csindex dc90f74b..ee9553d7 100644--- a/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs@@ -61,7 +61,7 @@ public sealed partial class ToolbarPageViewModel : ObservableObject_loading = true;OuterRadius = store.Settings.Donut.OuterRadius;HoleRatio = store.Settings.Donut.HoleRatio * 100;- SliceOpacity = store.Settings.Donut.Opacity * 100;+ SliceOpacity = Math.Clamp(store.Settings.Donut.Opacity, DonutSettings.MinOpacity, 1) * 100;_loading = false;SelectedProfile = Profiles.FirstOrDefault();diff --git a/src/Filee.App/ViewModels/RadialViewModel.cs b/src/Filee.App/ViewModels/RadialViewModel.csindex 88df43ac..9e6705cc 100644--- a/src/Filee.App/ViewModels/RadialViewModel.cs+++ b/src/Filee.App/ViewModels/RadialViewModel.cs@@ -299,7 +299,7 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,{OuterRadius = Math.Clamp(store.Settings.Donut.OuterRadius, 100, 240);HoleRatio = store.Settings.Donut.HoleRatio;- SliceOpacity = store.Settings.Donut.Opacity;+ SliceOpacity = Math.Clamp(store.Settings.Donut.Opacity, DonutSettings.MinOpacity, 1);FlipKey = store.Settings.Donut.EffectiveFlipKey(store.Settings.Triggers);FlipWithWheel = store.Settings.Donut.FlipWithWheel;}diff --git a/src/Filee.App/Views/Pages/ThemePage.axaml b/src/Filee.App/Views/Pages/ThemePage.axamlindex 6d96b46b..3636ef5d 100644--- a/src/Filee.App/Views/Pages/ThemePage.axaml+++ b/src/Filee.App/Views/Pages/ThemePage.axaml@@ -54,6 +54,18 @@</StackPanel></Border>+ <!-- The donut toolbar's opacity: the same setting as Donut toolbar → Appearance → Opacity. -->+ <Border Classes="card">+ <StackPanel Spacing="8">+ <DockPanel>+ <TextBlock DockPanel.Dock="Right" FontWeight="SemiBold" Text="{Binding DonutOpacity, StringFormat={}{0:0}%}" />+ <TextBlock Classes="label" Text="{DynamicResource theme.donut_opacity}" />+ </DockPanel>+ <Slider x:Name="DonutOpacitySlider" Minimum="10" Maximum="100" Value="{Binding DonutOpacity}"+ TickFrequency="1" IsSnapToTickEnabled="True" />+ </StackPanel>+ </Border>+<Border Classes="card"><StackPanel Spacing="4"><CheckBox Content="{DynamicResource theme.reduce_motion}" IsChecked="{Binding ReduceMotion}" FontWeight="SemiBold" />@@ -66,13 +78,19 @@<Border Grid.Row="1" Grid.Column="2" Classes="card" VerticalAlignment="Top"><StackPanel Spacing="14"><TextBlock Classes="label" Text="{DynamicResource theme.preview}" />- <c:DonutMenu x:Name="PreviewDonut" Items="{Binding PreviewItems}" OuterRadius="120" CenterTitle="JPG × 3" HorizontalAlignment="Center" />- <StackPanel Orientation="Horizontal" Spacing="8" HorizontalAlignment="Center">- <Button Classes="accent" Content="{DynamicResource common.save}" />- <Button Content="{DynamicResource common.cancel}" />+ <!-- The donut over a stand-in for the desktop, so its opacity shows. -->+ <Border Background="{Binding PreviewBackdrop}" CornerRadius="{DynamicResource SoftRadiusLarge}" Padding="0,10" ClipToBounds="True">+ <c:DonutMenu x:Name="PreviewDonut" Items="{Binding PreviewItems}" OuterRadius="120" CenterTitle="JPG × 3" HorizontalAlignment="Center"+ SliceOpacity="{Binding DonutOpacity, Converter={x:Static vm:ToolbarConverters.Percent}}" />+ </Border>+ <!-- Samples of the accent on controls: pictures only, so they don't pass for settings. -->+ <StackPanel Spacing="14" IsHitTestVisible="False">+ <StackPanel Orientation="Horizontal" Spacing="8" HorizontalAlignment="Center">+ <Button Classes="accent" Content="{DynamicResource common.save}" Focusable="False" />+ <Button Content="{DynamicResource common.cancel}" Focusable="False" />+ </StackPanel>+ <ToggleSwitch IsChecked="True" HorizontalAlignment="Center" Focusable="False" /></StackPanel>- <Slider Value="60" Maximum="100" />- <ToggleSwitch IsChecked="True" HorizontalAlignment="Center" /></StackPanel></Border></Grid>diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex d4105e6e..1f64739c 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -55,9 +55,12 @@ public sealed class DonutSettings/// <summary>Inner (hole) radius as a fraction of the outer radius (0.2 - 0.7).</summary>public double HoleRatio { get; set; } = 0.42;- /// <summary>Background opacity of the slices (0.5 - 1).</summary>+ /// <summary>Background opacity of the slices (<see cref="MinOpacity"/> - 1); labels and outlines stay opaque.</summary>public double Opacity { get; set; } = 0.96;+ /// <summary>The lowest <see cref="Opacity"/> the Theme and Donut toolbar pages offer.</summary>+ public const double MinOpacity = 0.1;+/// <summary>The flip key unless the user picks another one (Settings → Shortcuts).</summary>public const string DefaultFlipKey = "Tab";diff --git a/tests/Filee.App.Tests/DonutOpacityTests.cs b/tests/Filee.App.Tests/DonutOpacityTests.csnew file mode 100644index 00000000..3de6d8f2--- /dev/null+++ b/tests/Filee.App.Tests/DonutOpacityTests.cs@@ -0,0 +1,78 @@+// The donut's opacity: one setting, edited on the Theme page (with the preview following it at once, issue #276) and+// on the Donut toolbar page, and read by the donut when it opens.++using Avalonia.Controls;+using Avalonia.Headless.XUnit;+using Avalonia.VisualTree;+using Filee.App.Controls;+using Filee.App.Services;+using Filee.App.ViewModels;+using Filee.App.ViewModels.Pages;+using Filee.App.Views;+using Filee.App.Views.Pages;+using Filee.Core.Localization;+using Filee.Core.Settings;++namespace Filee.App.Tests;++public class DonutOpacityTests+{+ [AvaloniaTheory]+ [InlineData("en")]+ [InlineData("ru")]+ public void The_theme_page_slider_moves_the_preview_and_is_the_toolbar_pages_setting(string language)+ {+ TestServices.EnsureInitialized(language);+ var store = AppHost.Get<UserDataStore>();+ var loc = AppHost.Get<ILocalizer>();+ var saved = store.Settings.Donut.Opacity;+ try+ {+ store.Settings.Donut.Opacity = 0.96;+ var vm = new MainWindowViewModel(AppHost.Services, loc, AppHost.Get<UpdateService>());+ vm.Navigate("theme");+ var window = new MainWindow { DataContext = vm, Width = 1080, Height = 820 };+ window.Show();+ RenderTests.Pump();++ var page = window.GetVisualDescendants().OfType<ThemePage>().Single();+ var slider = page.FindControl<Slider>("DonutOpacitySlider")!;+ var preview = page.FindControl<DonutMenu>("PreviewDonut")!;+ Assert.Equal(96, slider.Value);+ Assert.Equal(0.96, preview.SliceOpacity, 3);+ // Labelled, in the page's language.+ Assert.Contains(page.GetVisualDescendants().OfType<TextBlock>(),+ t => t.Text == loc["theme.donut_opacity"] && t.IsEffectivelyVisible);++ slider.Value = 35;+ RenderTests.Pump();+ Assert.Equal(0.35, preview.SliceOpacity, 3);+ Assert.Equal(0.35, store.Settings.Donut.Opacity, 3);+ RenderTests.Save(window, $"page-theme-opacity-{language}.png");++ // The Donut toolbar page shows and edits the same value, and the Theme page reads it back.+ vm.Navigate("toolbar");+ RenderTests.Pump();+ var toolbar = Assert.IsType<ToolbarPageViewModel>(vm.CurrentPage);+ Assert.Equal(35, toolbar.SliceOpacity, 3);+ toolbar.SliceOpacity = 70;+ vm.Navigate("theme");+ RenderTests.Pump();+ Assert.Equal(70, Assert.IsType<ThemePageViewModel>(vm.CurrentPage).DonutOpacity);+ window.Close();++ // The donut takes it the next time it opens; a value below the range (an edited file) is raised to it.+ var radial = AppHost.Get<RadialViewModel>();+ radial.Load([@"C:\photos\a.jpg"], clickMode: true);+ Assert.Equal(0.7, radial.SliceOpacity, 3);+ store.Settings.Donut.Opacity = 0;+ radial.Load([@"C:\photos\a.jpg"], clickMode: true);+ Assert.Equal(DonutSettings.MinOpacity, radial.SliceOpacity, 3);+ }+ finally+ {+ store.Settings.Donut.Opacity = saved;+ store.SaveSettings();+ }+ }+}