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.

Merge remote-tracking branch 'origin/main' into sync-440

KnifeLemon4a0c2e937392
diff --cc src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs
index f5b1b574,03aee264..b1558168
--- a/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs
@@@ -42,10 -55,9 +56,11 @@@ public sealed partial class ThemePageVi
new DonutItem { Id = "f", Label = "TIFF" },
];
_loading = false;
+ UiZoom.Changed += OnZoomChanged;
+ loc.LanguageChanged += OnLanguageChanged;
}
+ public IReadOnlyList<Choice<ThemeStyle>> Styles { get; }
public IReadOnlyList<Choice<ThemeMode>> Modes { get; }
public IReadOnlyList<Color> Swatches { get; } = ThemeService.Swatches.Select(Color.Parse).ToList();
public IReadOnlyList<DonutItem> PreviewItems { get; }
@@@ -80,47 -107,71 +110,107 @@@
/// </summary>
[ObservableProperty] private double _donutOpacity;
+ /// <summary>The window size in percent (<see cref="UiZoom.Scale"/>): the same for every window, saved by UiZoom.</summary>
+ public double WindowSize => Math.Round(UiZoom.Scale * 100);
+
+ /// <summary>Where the shortcuts do the same, with the platform's key: Ctrl, or Cmd on a Mac.</summary>
+ public string WindowSizeHint => _loc.Format("theme.window_size_hint", OperatingSystem.IsMacOS() ? "Cmd" : "Ctrl");
+
+ [RelayCommand(CanExecute = nameof(CanZoomOut))]
+ private void ZoomOut() => UiZoom.ZoomOut();
+
+ [RelayCommand(CanExecute = nameof(CanZoomIn))]
+ private void ZoomIn() => UiZoom.ZoomIn();
+
+ [RelayCommand(CanExecute = nameof(CanResetZoom))]
+ private void ResetZoom() => UiZoom.Reset();
+
+ private static bool CanZoomOut() => UiZoom.Scale > UiZoom.Min + 1e-9;
+ private static bool CanZoomIn() => UiZoom.Scale < UiZoom.Max - 1e-9;
+ private static bool CanResetZoom() => Math.Abs(UiZoom.Scale - 1) > 1e-9;
+
+ // Ctrl + wheel in any window changes it too.
+ private void OnZoomChanged(object? sender, EventArgs e)
+ {
+ OnPropertyChanged(nameof(WindowSize));
+ ZoomOutCommand.NotifyCanExecuteChanged();
+ ZoomInCommand.NotifyCanExecuteChanged();
+ ResetZoomCommand.NotifyCanExecuteChanged();
+ }
+
+ private void OnLanguageChanged(object? sender, EventArgs e) => OnPropertyChanged(nameof(WindowSizeHint));
+
+ public void Dispose()
+ {
+ UiZoom.Changed -= OnZoomChanged;
+ _loc.LanguageChanged -= OnLanguageChanged;
+ }
+
+ partial void OnStyleChanged(Choice<ThemeStyle>? oldValue, Choice<ThemeStyle> newValue)
+ {
+ OnPropertyChanged(nameof(IsMaterialYou));
+ if (!Choices.Restore(oldValue, newValue, v => Style = v))
+ Save(t => t.Style = newValue.Value);
+ }
+
partial void OnModeChanged(Choice<ThemeMode>? oldValue, Choice<ThemeMode> newValue)
{
+ OnPropertyChanged(nameof(PastelPresets));
if (!Choices.Restore(oldValue, newValue, v => Mode = v))
- Save(t => t.Mode = newValue.Value);
+ {
+ _settingPresetOrMode = true;
+ try
+ {
+ Save(t =>
+ {
+ t.Mode = newValue.Value;
+ if (!string.IsNullOrEmpty(t.PresetKey) &&
+ ThemeService.Presets.FirstOrDefault(p => string.Equals(p.Key, t.PresetKey, StringComparison.OrdinalIgnoreCase)) is { } preset)
+ {
+ var isDark = newValue.Value == ThemeMode.Dark ||
+ (newValue.Value == ThemeMode.System && Application.Current?.ActualThemeVariant == ThemeVariant.Dark);
+ var newColor = preset.ActiveColor(isDark);
+ t.Accent = $"#{newColor.R:X2}{newColor.G:X2}{newColor.B:X2}";
+ Accent = newColor;
+ }
+ });
+ }
+ finally
+ {
+ _settingPresetOrMode = false;
+ }
+ }
}
+
+ [RelayCommand]
+ private void PickPreset(PresetItem preset)
+ {
+ _settingPresetOrMode = true;
+ try
+ {
+ Save(t => t.PresetKey = preset.Key);
+ Accent = preset.Color;
+ }
+ finally
+ {
+ _settingPresetOrMode = false;
+ }
+ }
+
+ [RelayCommand]
+ private void PickSwatch(Color color)
+ {
+ Accent = color;
+ }
+
+ [RelayCommand]
+ private void SetStyle(ThemeStyle target)
+ {
+ var match = Styles.FirstOrDefault(s => s.Value == target);
+ if (match != null && Style != match)
+ Style = match;
+ }
+
partial void OnAccentChanged(Color value)
{
var hex = $"#{value.R:X2}{value.G:X2}{value.B:X2}";