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.

Updates on the About page, no engine pre-ticked, search above the lists, excluded apps as tags

KnifeLemon36681bef1fd1
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index a6eed637..18e834f8 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -215,7 +215,10 @@
"triggers.scope.FileManager_linux": "File manager and desktop",
"triggers.scope.Anywhere": "Everywhere",
"triggers.excluded": "Never trigger in these apps",
- "triggers.excluded_hint": "Process names separated by commas, e.g. photoshop, code",
+ "triggers.excluded_hint": "Type an app name and press Enter, e.g. photoshop",
+ "triggers.excluded_pick": "Pick a running app",
+ "triggers.excluded_none_running": "No other app has a window open.",
+ "triggers.excluded_note": "Gestures and shortcuts do nothing while the pointer is over these apps.",
"triggers.paused": "Shortcuts are paused",
"toolbar.title": "Donut toolbar",
@@ -423,6 +426,8 @@
"engines.state.failed": "Failed: {0}",
"about.title": "About",
+ "about.updates": "Updates",
+ "common.search": "Search",
"about.version": "Version {0}",
"about.license": "Filee is free software under the MIT license.",
"about.notices": "Third-party notices",
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index 9ede875e..54ba5f1f 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -215,7 +215,10 @@
"triggers.scope.FileManager_linux": "파일 관리자와 바탕화면",
"triggers.scope.Anywhere": "모든 곳",
"triggers.excluded": "이 앱에서는 동작하지 않기",
- "triggers.excluded_hint": "프로세스 이름을 쉼표로 구분, 예: photoshop, code",
+ "triggers.excluded_hint": "앱 이름을 입력하고 Enter, 예: photoshop",
+ "triggers.excluded_pick": "실행 중인 앱에서 선택",
+ "triggers.excluded_none_running": "창이 열린 다른 앱이 없어요.",
+ "triggers.excluded_note": "마우스가 이 앱 위에 있으면 제스처와 단축키가 동작하지 않아요.",
"triggers.paused": "단축키가 일시 중지되었어요",
"toolbar.title": "원형 툴바",
@@ -423,6 +426,8 @@
"engines.state.failed": "실패: {0}",
"about.title": "정보",
+ "about.updates": "업데이트",
+ "common.search": "검색",
"about.version": "버전 {0}",
"about.license": "Filee는 MIT 라이선스의 무료 소프트웨어예요.",
"about.notices": "서드파티 고지",
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 8172a879..eb3125f5 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -215,7 +215,10 @@
"triggers.scope.FileManager_linux": "文件管理器和桌面",
"triggers.scope.Anywhere": "所有位置",
"triggers.excluded": "在这些应用中不触发",
- "triggers.excluded_hint": "进程名,用逗号分隔,例如 photoshop, code",
+ "triggers.excluded_hint": "输入应用名称后按 Enter,例如 photoshop",
+ "triggers.excluded_pick": "从正在运行的应用中选择",
+ "triggers.excluded_none_running": "没有其他打开窗口的应用。",
+ "triggers.excluded_note": "指针位于这些应用上时,手势和快捷键不起作用。",
"triggers.paused": "快捷操作已暂停",
"toolbar.title": "环形工具栏",
@@ -423,6 +426,8 @@
"engines.state.failed": "失败:{0}",
"about.title": "关于",
+ "about.updates": "更新",
+ "common.search": "搜索",
"about.version": "版本 {0}",
"about.license": "Filee 是基于 MIT 许可证的免费软件。",
"about.notices": "第三方声明",
diff --git a/src/Filee.App/Styles/Icons.axaml b/src/Filee.App/Styles/Icons.axaml
index c0ef6b50..a7429d05 100644
--- a/src/Filee.App/Styles/Icons.axaml
+++ b/src/Filee.App/Styles/Icons.axaml
@@ -13,6 +13,7 @@
<StreamGeometry x:Key="Icon.Engine">M17,17H7V7H17M21,11V9H19V7C19,5.89 18.1,5 17,5H15V3H13V5H11V3H9V5H7C5.89,5 5,5.89 5,7V9H3V11H5V13H3V15H5V17A2,2 0 0,0 7,19H9V21H11V19H13V21H15V19H17A2,2 0 0,0 19,17V15H21V13H19V11M13,13H11V11H13M15,9H9V15H15V9Z</StreamGeometry>
<StreamGeometry x:Key="Icon.Info">M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z</StreamGeometry>
<StreamGeometry x:Key="Icon.Folder">M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z</StreamGeometry>
+ <StreamGeometry x:Key="Icon.Search">M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z</StreamGeometry>
<StreamGeometry x:Key="Icon.Plus">M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z</StreamGeometry>
<StreamGeometry x:Key="Icon.Delete">M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z</StreamGeometry>
<StreamGeometry x:Key="Icon.Copy">M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z</StreamGeometry>
diff --git a/src/Filee.App/ViewModels/EngineSetupViewModel.cs b/src/Filee.App/ViewModels/EngineSetupViewModel.cs
index bb8c9e67..1cd418ff 100644
--- a/src/Filee.App/ViewModels/EngineSetupViewModel.cs
+++ b/src/Filee.App/ViewModels/EngineSetupViewModel.cs
@@ -18,9 +18,10 @@ public sealed partial class EngineSetupViewModel : ObservableObject
{
_downloads = downloads;
_loc = loc;
+ // Nothing is ticked: the user picks what they need (every engine is a download of its own).
foreach (var package in Packages)
{
- package.Selected = package.CanInstall && Filee.Engines.Infrastructure.EngineDownloads.IsSuggested(package.Package);
+ package.Selected = false;
package.PropertyChanged += OnPackageChanged;
}
}
diff --git a/src/Filee.App/ViewModels/FilteredList.cs b/src/Filee.App/ViewModels/FilteredList.cs
new file mode 100644
index 00000000..0b45a1bb
--- /dev/null
+++ b/src/Filee.App/ViewModels/FilteredList.cs
@@ -0,0 +1,61 @@
+// The items of a list that match the search box above it, kept in step with the list as it changes. Items are added
+// and removed one by one (not cleared and refilled), so a ListBox keeps its selection while it stays visible.
+
+using System.Collections.ObjectModel;
+
+namespace Filee.App.ViewModels;
+
+public sealed class FilteredList<T> : ObservableCollection<T> where T : class
+{
+ private readonly ObservableCollection<T> _source;
+ private readonly Func<T, IEnumerable<string?>> _texts;
+ private string _query = "";
+
+ /// <param name="source">The full list.</param>
+ /// <param name="texts">The texts of an item the query is looked for in (name, format, extensions …).</param>
+ public FilteredList(ObservableCollection<T> source, Func<T, IEnumerable<string?>> texts)
+ {
+ _source = source;
+ _texts = texts;
+ source.CollectionChanged += (_, _) => Refresh();
+ Refresh();
+ }
+
+ /// <summary>What was typed; empty shows everything. Matches any part of a text, ignoring case.</summary>
+ public string Query
+ {
+ get => _query;
+ set
+ {
+ var query = value?.Trim() ?? "";
+ if (query == _query)
+ return;
+ _query = query;
+ Refresh();
+ }
+ }
+
+ public bool Matches(T item) =>
+ _query.Length == 0 || _texts(item).Any(text => text?.Contains(_query, StringComparison.CurrentCultureIgnoreCase) == true);
+
+ /// <summary>Brings the list in line with the source and the query (also after an item's text changed).</summary>
+ public void Refresh()
+ {
+ var wanted = _source.Where(Matches).ToList();
+ for (var i = Count - 1; i >= 0; i--)
+ {
+ if (!wanted.Contains(this[i]))
+ RemoveAt(i);
+ }
+ for (var i = 0; i < wanted.Count; i++)
+ {
+ if (i < Count && ReferenceEquals(this[i], wanted[i]))
+ continue;
+ var at = IndexOf(wanted[i]);
+ if (at >= 0)
+ Move(at, i);
+ else
+ Insert(i, wanted[i]);
+ }
+ }
+}
diff --git a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
index eb55e147..22a84c49 100644
--- a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
@@ -2,16 +2,73 @@
using Avalonia.Platform;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using Filee.App.Services;
using Filee.Core.Localization;
+using Filee.Core.Settings;
namespace Filee.App.ViewModels.Pages;
-public sealed partial class AboutPageViewModel(ILocalizer loc) : ObservableObject
+public sealed partial class AboutPageViewModel : ObservableObject, IDisposable
{
- public string Version { get; } = loc.Format("about.version", UpdateService.CurrentVersion);
+ private readonly ILocalizer _loc;
+ private readonly UserDataStore _store;
+ private readonly UpdateService _updates;
+
+ public AboutPageViewModel(ILocalizer loc, UserDataStore store, UpdateService updates)
+ {
+ _loc = loc;
+ _store = store;
+ _updates = updates;
+ Version = loc.Format("about.version", UpdateService.CurrentVersion);
+ _checkForUpdates = store.Settings.CheckForUpdates;
+ ShowUpdateState(updates.LatestVersion);
+ updates.PropertyChanged += OnUpdatesChanged;
+ }
+
+ public string Version { get; }
public string RepositoryUrl { get; } = UpdateService.RepositoryUrl;
+ /// <summary>The page is rebuilt on every visit; the update service lives on.</summary>
+ public void Dispose() => _updates.PropertyChanged -= OnUpdatesChanged;
+
+ // ── Updates: the automatic check and "Check now" ──
+
+ [ObservableProperty] private bool _checkForUpdates;
+ [ObservableProperty] private bool _updateAvailable;
+ [ObservableProperty] private string _updateStatus = "";
+
+ /// <summary>"Update" in an installed copy, "Download" in a portable one.</summary>
+ public string UpdateButtonText => _loc[UpdateTexts.ButtonKey];
+
+ partial void OnCheckForUpdatesChanged(bool value)
+ {
+ _store.Settings.CheckForUpdates = value;
+ _store.SaveSettings();
+ }
+
+ private void OnUpdatesChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (UpdateTexts.Affects(e.PropertyName))
+ ShowUpdateState(_updates.LatestVersion);
+ }
+
+ [RelayCommand]
+ private async Task CheckNow() => ShowUpdateState(await _updates.CheckAsync(), afterCheck: true);
+
+ /// <summary>Downloads and runs the new installer, which updates Filee in place (a portable copy opens the download page).</summary>
+ [RelayCommand]
+ private Task DownloadUpdate() => _updates.UpdateAsync();
+
+ private void ShowUpdateState(string? newer, bool afterCheck = false)
+ {
+ UpdateAvailable = newer is not null && !_updates.IsBusy;
+ UpdateStatus = UpdateTexts.Status(_updates, _loc) is { } progress ? progress
+ : newer is not null ? _loc.Format("general.update_available", newer)
+ : afterCheck ? _loc.Format("general.update_none", UpdateService.CurrentVersion)
+ : "";
+ }
+
public string Notices { get; } = ReadNotices();
private static string ReadNotices()
diff --git a/src/Filee.App/ViewModels/Pages/ExcludedAppsViewModel.cs b/src/Filee.App/ViewModels/Pages/ExcludedAppsViewModel.cs
new file mode 100644
index 00000000..bedb4f6a
--- /dev/null
+++ b/src/Filee.App/ViewModels/Pages/ExcludedAppsViewModel.cs
@@ -0,0 +1,129 @@
+// "Never trigger in these apps" on the Shortcuts page: the apps as tags. A name is typed (the box suggests the apps
+// running now) or picked from the list of apps that have a window open; a tag's ✕ removes it. The names are the ones
+// TriggerService compares with the window under the cursor (process name, without ".exe").
+
+using System.Collections.ObjectModel;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Filee.App.Controls;
+using Filee.Core.Platform;
+
+namespace Filee.App.ViewModels.Pages;
+
+public sealed partial class ExcludedAppsViewModel : ObservableObject
+{
+ private readonly List<string> _excluded;
+ private readonly IPlatformServices? _platform;
+ private readonly Action _save;
+ private IReadOnlyList<string> _running = [];
+ private bool _loaded;
+
+ /// <param name="excluded">The settings' list, changed in place.</param>
+ /// <param name="save">Persists the settings after every change.</param>
+ public ExcludedAppsViewModel(List<string> excluded, IPlatformServices? platform, Action save)
+ {
+ _excluded = excluded;
+ _platform = platform;
+ _save = save;
+ VisibleRunningApps = new FilteredList<string>(RunningApps, name => [name]);
+ Refresh();
+ }
+
+ [ObservableProperty] private IReadOnlyList<TagChip> _tags = [];
+ [ObservableProperty] private IReadOnlyList<TagSuggestion> _suggestions = [];
+ [ObservableProperty] private string _text = "";
+
+ /// <summary>Apps with a window open now, not excluded yet (the "pick a running app" list).</summary>
+ public ObservableCollection<string> RunningApps { get; } = [];
+
+ public FilteredList<string> VisibleRunningApps { get; }
+
+ /// <summary>The list was read and has nothing to offer.</summary>
+ [ObservableProperty] private bool _noRunningApps;
+
+ [ObservableProperty] private string _runningSearch = "";
+
+ partial void OnRunningSearchChanged(string value) => VisibleRunningApps.Query = value;
+
+ partial void OnTextChanged(string value) => UpdateSuggestions();
+
+ /// <summary>Reads the running apps again (when the list opens, and when typing starts).</summary>
+ [RelayCommand]
+ public void LoadRunningApps()
+ {
+ _loaded = true;
+ try
+ {
+ _running = _platform?.RunningAppNames() ?? [];
+ }
+ catch (Exception ex) when (ex is InvalidOperationException or System.ComponentModel.Win32Exception or NotSupportedException)
+ {
+ _running = [];
+ }
+ RefreshRunning();
+ }
+
+ /// <summary>Adds a typed or picked app name.</summary>
+ [RelayCommand]
+ private void Add(string? name)
+ {
+ var app = Normalize(name);
+ if (app is null || _excluded.Contains(app, StringComparer.OrdinalIgnoreCase))
+ {
+ Text = "";
+ return;
+ }
+ _excluded.Add(app);
+ _save();
+ Text = "";
+ Refresh();
+ }
+
+ [RelayCommand]
+ private void Remove(TagChip? chip)
+ {
+ if (chip is null || _excluded.RemoveAll(n => n.Equals(chip.Value, StringComparison.OrdinalIgnoreCase)) == 0)
+ return;
+ _save();
+ Refresh();
+ }
+
+ /// <summary>"Photoshop.exe " → "Photoshop": the name TriggerService compares with.</summary>
+ internal static string? Normalize(string? name)
+ {
+ var app = name?.Trim();
+ if (string.IsNullOrEmpty(app))
+ return null;
+ if (app.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
+ app = app[..^4];
+ return app.Length == 0 ? null : app;
+ }
+
+ private void Refresh()
+ {
+ Tags = [.. _excluded.Select(name => new TagChip(name, name))];
+ RefreshRunning();
+ }
+
+ private void RefreshRunning()
+ {
+ var available = _running.Where(n => !_excluded.Contains(n, StringComparer.OrdinalIgnoreCase)).ToList();
+ if (!available.SequenceEqual(RunningApps))
+ {
+ RunningApps.Clear();
+ foreach (var name in available)
+ RunningApps.Add(name);
+ }
+ NoRunningApps = _loaded && RunningApps.Count == 0;
+ UpdateSuggestions();
+ }
+
+ private void UpdateSuggestions()
+ {
+ var typed = Text.Trim();
+ if (typed.Length > 0 && !_loaded)
+ LoadRunningApps(); // first keystroke: read the running apps once
+ Suggestions = typed.Length == 0 ? []
+ : [.. RunningApps.Where(n => n.Contains(typed, StringComparison.CurrentCultureIgnoreCase)).Take(12).Select(n => new TagSuggestion(n, n))];
+ }
+}
diff --git a/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs b/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
index 60592c0a..cd03b1fe 100644
--- a/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/GeneralPageViewModel.cs
@@ -1,4 +1,4 @@
-// General settings: language, start-up, Explorer integration, updates, preset library import/export.
+// General settings: language, start-up, Explorer integration, preset library import/export. Updates are on the About page.
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -10,21 +10,18 @@ using Filee.Core.Settings;
namespace Filee.App.ViewModels.Pages;
-public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
+public sealed partial class GeneralPageViewModel : ObservableObject
{
private readonly UserDataStore _store;
private readonly ILocalizer _loc;
private readonly IPlatformServices _platform;
- private readonly UpdateService _updates;
private readonly SystemIntegrationService? _integration;
- public GeneralPageViewModel(UserDataStore store, ILocalizer loc, IPlatformServices platform, UpdateService updates,
- SystemIntegrationService? integration = null)
+ public GeneralPageViewModel(UserDataStore store, ILocalizer loc, IPlatformServices platform, SystemIntegrationService? integration = null)
{
_store = store;
_loc = loc;
_platform = platform;
- _updates = updates;
_integration = integration;
Languages =
@@ -35,7 +32,6 @@ public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
_language = Languages.FirstOrDefault(l => l.Value == store.Settings.Language) ?? Languages[0];
_startWithSystem = store.Settings.StartWithSystem;
_contextMenu = store.Settings.ContextMenuEnabled;
- _checkForUpdates = store.Settings.CheckForUpdates;
_noHistory = !store.Settings.KeepHistory;
OutputLocations = new[] { OutputLocation.SameFolder, OutputLocation.Subfolder, OutputLocation.CustomFolder }
.Select(v => new Choice<OutputLocation>(v, loc[$"presets.location.{v}"])).ToList();
@@ -45,23 +41,9 @@ public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
_defaultFolder = output.CustomFolder;
_keepFileDates = store.Settings.KeepFileDates;
_historyCount = store.History.Count;
- ShowUpdateState(updates.LatestVersion);
- updates.PropertyChanged += OnUpdatesChanged;
RefreshModernMenu();
}
- /// <summary>The page is rebuilt on every visit; the update service lives on.</summary>
- public void Dispose() => _updates.PropertyChanged -= OnUpdatesChanged;
-
- private void OnUpdatesChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (UpdateTexts.Affects(e.PropertyName))
- ShowUpdateState(_updates.LatestVersion);
- }
-
- /// <summary>"Update" in an installed copy, "Download" in a portable one.</summary>
- public string UpdateButtonText => _loc[UpdateTexts.ButtonKey];
-
public IReadOnlyList<Choice<string>> Languages { get; }
public string DataFolder => _store.Directory;
public bool IsWindows => OperatingSystem.IsWindows();
@@ -97,9 +79,6 @@ public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
[ObservableProperty] private Choice<string> _language;
[ObservableProperty] private bool _startWithSystem;
[ObservableProperty] private bool _contextMenu;
- [ObservableProperty] private bool _checkForUpdates;
- [ObservableProperty] private string? _updateStatus;
- [ObservableProperty] private bool _updateAvailable;
[ObservableProperty] private string? _libraryMessage;
// Windows 11 top-level Explorer menu entry (see ExplorerMenuRegistration). Only shown when this build ships it.
@@ -169,7 +148,6 @@ public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
_ => "general.modern_menu_hint",
}];
}
- partial void OnCheckForUpdatesChanged(bool value) => Save(s => s.CheckForUpdates = value);
// Conversion history (home page): don't record it, or clear what is there.
[ObservableProperty] private bool _noHistory;
@@ -207,22 +185,6 @@ public sealed partial class GeneralPageViewModel : ObservableObject, IDisposable
[RelayCommand]
private void OpenDataFolder() => _platform.RevealInFileManager(_store.Directory);
- [RelayCommand]
- private async Task CheckNow() => ShowUpdateState(await _updates.CheckAsync(), afterCheck: true);
-
- /// <summary>Downloads and runs the new installer, which updates Filee in place (a portable copy opens the download page).</summary>
- [RelayCommand]
- private Task DownloadUpdate() => _updates.UpdateAsync();
-
- private void ShowUpdateState(string? newer, bool afterCheck = false)
- {
- UpdateAvailable = newer is not null && !_updates.IsBusy;
- UpdateStatus = UpdateTexts.Status(_updates, _loc) is { } progress ? progress
- : newer is not null ? _loc.Format("general.update_available", newer)
- : afterCheck ? _loc.Format("general.update_none", UpdateService.CurrentVersion)
- : _loc.Format("about.version", UpdateService.CurrentVersion);
- }
-
public void Export(string path)
{
_store.Export(path);
diff --git a/src/Filee.App/ViewModels/Pages/PresetsPageViewModel.cs b/src/Filee.App/ViewModels/Pages/PresetsPageViewModel.cs
index b786b7d1..a0eb939e 100644
--- a/src/Filee.App/ViewModels/Pages/PresetsPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/PresetsPageViewModel.cs
@@ -42,6 +42,7 @@ public sealed partial class PresetsPageViewModel : ObservableObject, IFitsWindow
_store = store;
_loc = loc;
_windows = windows;
+ VisiblePresets = new FilteredList<PresetListItem>(Presets, p => [p.Name, p.Target, p.Preset.TargetFormat]);
foreach (var preset in store.Presets)
Presets.Add(new PresetListItem(preset, loc));
SelectedPreset = Presets.FirstOrDefault();
@@ -49,6 +50,13 @@ public sealed partial class PresetsPageViewModel : ObservableObject, IFitsWindow
public ObservableCollection<PresetListItem> Presets { get; } = [];
+ /// <summary>The presets the search box above the list lets through (name or target format).</summary>
+ public FilteredList<PresetListItem> VisiblePresets { get; }
+
+ [ObservableProperty] private string _search = "";
+
+ partial void OnSearchChanged(string value) => VisiblePresets.Query = value;
+
[ObservableProperty] private PresetListItem? _selectedPreset;
[ObservableProperty] private PresetEditorViewModel? _editor;
[ObservableProperty] private string? _savedMessage;
diff --git a/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs b/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs
index d8263e34..3b651bdd 100644
--- a/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/ToolbarPageViewModel.cs
@@ -51,6 +51,9 @@ public sealed partial class ToolbarPageViewModel : ObservableObject
_store = store;
_loc = loc;
_windows = windows;
+ // A profile is found by its name or by an extension it handles ("png" finds the photo donut).
+ VisibleProfiles = new FilteredList<ProfileItemViewModel>(Profiles, p => [p.Name, .. p.Profile.Extensions]);
+ VisiblePalette = new FilteredList<PaletteChip>(Palette, c => [c.Label, c.Caption]);
foreach (var profile in store.Profiles)
Profiles.Add(new ProfileItemViewModel(profile, loc));
@@ -66,6 +69,16 @@ public sealed partial class ToolbarPageViewModel : ObservableObject
public ObservableCollection<ProfileItemViewModel> Profiles { get; } = [];
public ObservableCollection<PaletteChip> Palette { get; } = [];
+ /// <summary>The profiles and the presets the search boxes above the two lists let through.</summary>
+ public FilteredList<ProfileItemViewModel> VisibleProfiles { get; }
+ public FilteredList<PaletteChip> VisiblePalette { get; }
+
+ [ObservableProperty] private string _profileSearch = "";
+ [ObservableProperty] private string _paletteSearch = "";
+
+ partial void OnProfileSearchChanged(string value) => VisibleProfiles.Query = value;
+ partial void OnPaletteSearchChanged(string value) => VisiblePalette.Query = value;
+
[ObservableProperty] private ProfileItemViewModel? _selectedProfile;
[ObservableProperty] private IReadOnlyList<DonutItem> _donutItems = [];
[ObservableProperty] private string _centerTitle = "";
diff --git a/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs b/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs
index 5408ae9c..cf1c8bd2 100644
--- a/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs
@@ -157,7 +157,7 @@ public sealed partial class TriggersPageViewModel : ObservableObject, IDisposabl
triggers.StatusChanged += OnTriggerStatusChanged;
foreach (var gesture in store.Settings.Triggers)
Gestures.Add(new TriggerGestureViewModel(gesture, loc, Save));
- _excluded = string.Join(", ", store.Settings.ExcludedProcesses);
+ ExcludedApps = new ExcludedAppsViewModel(store.Settings.ExcludedProcesses, platform, Save);
}
public ObservableCollection<TriggerGestureViewModel> Gestures { get; } = [];
@@ -209,15 +209,8 @@ public sealed partial class TriggersPageViewModel : ObservableObject, IDisposabl
_triggers.StatusChanged -= OnTriggerStatusChanged;
}
- [ObservableProperty] private string _excluded;
-
- partial void OnExcludedChanged(string value)
- {
- _store.Settings.ExcludedProcesses = value
- .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
- .ToList();
- Save();
- }
+ /// <summary>"Never trigger in these apps" as tags.</summary>
+ public ExcludedAppsViewModel ExcludedApps { get; }
[RelayCommand]
private void Add()
diff --git a/src/Filee.App/Views/Pages/AboutPage.axaml b/src/Filee.App/Views/Pages/AboutPage.axaml
index e8a36418..a0d2101c 100644
--- a/src/Filee.App/Views/Pages/AboutPage.axaml
+++ b/src/Filee.App/Views/Pages/AboutPage.axaml
@@ -22,6 +22,22 @@
</StackPanel>
</StackPanel>
</Border>
+ <Border Classes="card">
+ <StackPanel Spacing="12">
+ <TextBlock Classes="h2" Text="{DynamicResource about.updates}" />
+ <ToggleSwitch Content="{DynamicResource general.check_updates}" IsChecked="{Binding CheckForUpdates}" />
+ <WrapPanel>
+ <Button Content="{DynamicResource general.check_now}" Command="{Binding CheckNowCommand}" Margin="0,0,10,0" />
+ <Button Classes="accent" Command="{Binding DownloadUpdateCommand}" IsVisible="{Binding UpdateAvailable}" Margin="0,0,10,0">
+ <StackPanel Orientation="Horizontal" Spacing="6">
+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Download}" />
+ <TextBlock Text="{Binding UpdateButtonText}" />
+ </StackPanel>
+ </Button>
+ <TextBlock Classes="muted" VerticalAlignment="Center" Text="{Binding UpdateStatus}" />
+ </WrapPanel>
+ </StackPanel>
+ </Border>
<Border Classes="card">
<StackPanel Spacing="10">
<TextBlock Classes="h2" Text="{DynamicResource about.support_title}" />
diff --git a/src/Filee.App/Views/Pages/GeneralPage.axaml b/src/Filee.App/Views/Pages/GeneralPage.axaml
index 6317b9a0..1ab3a965 100644
--- a/src/Filee.App/Views/Pages/GeneralPage.axaml
+++ b/src/Filee.App/Views/Pages/GeneralPage.axaml
@@ -49,22 +49,6 @@
</StackPanel>
</Border>
- <Border Classes="card">
- <StackPanel Spacing="12">
- <ToggleSwitch Content="{DynamicResource general.check_updates}" IsChecked="{Binding CheckForUpdates}" />
- <StackPanel Orientation="Horizontal" Spacing="10">
- <Button Content="{DynamicResource general.check_now}" Command="{Binding CheckNowCommand}" />
- <Button Classes="accent" Command="{Binding DownloadUpdateCommand}" IsVisible="{Binding UpdateAvailable}">
- <StackPanel Orientation="Horizontal" Spacing="6">
- <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Download}" />
- <TextBlock Text="{Binding UpdateButtonText}" />
- </StackPanel>
- </Button>
- <TextBlock Classes="muted" VerticalAlignment="Center" Text="{Binding UpdateStatus}" />
- </StackPanel>
- </StackPanel>
- </Border>
-
<Border Classes="card">
<StackPanel Spacing="12">
<TextBlock Classes="h2" Text="{DynamicResource general.history}" />
diff --git a/src/Filee.App/Views/Pages/PresetsPage.axaml b/src/Filee.App/Views/Pages/PresetsPage.axaml
index 3903e6a5..3da5b6da 100644
--- a/src/Filee.App/Views/Pages/PresetsPage.axaml
+++ b/src/Filee.App/Views/Pages/PresetsPage.axaml
@@ -23,7 +23,12 @@
<PathIcon Width="14" Height="14" Data="{StaticResource Icon.Delete}" />
</Button>
</WrapPanel>
- <ListBox Classes="soft" ItemsSource="{Binding Presets}" SelectedItem="{Binding SelectedPreset}">
+ <TextBox Classes="search" DockPanel.Dock="Top" Margin="0,0,0,8" Text="{Binding Search}" Watermark="{DynamicResource common.search}">
+ <TextBox.InnerLeftContent>
+ <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
+ </TextBox.InnerLeftContent>
+ </TextBox>
+ <ListBox Classes="soft" ItemsSource="{Binding VisiblePresets}" SelectedItem="{Binding SelectedPreset}">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:PresetListItem">
<StackPanel>
diff --git a/src/Filee.App/Views/Pages/ToolbarPage.axaml b/src/Filee.App/Views/Pages/ToolbarPage.axaml
index 51ec06c1..bb5c0013 100644
--- a/src/Filee.App/Views/Pages/ToolbarPage.axaml
+++ b/src/Filee.App/Views/Pages/ToolbarPage.axaml
@@ -106,7 +106,12 @@
<!-- 1. Profiles -->
<StackPanel Spacing="8">
<TextBlock Classes="label" Text="{DynamicResource toolbar.step_profile}" />
- <ListBox Classes="soft" ItemsSource="{Binding Profiles}" SelectedItem="{Binding SelectedProfile}">
+ <TextBox Classes="search" Text="{Binding ProfileSearch}" Watermark="{DynamicResource common.search}">
+ <TextBox.InnerLeftContent>
+ <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
+ </TextBox.InnerLeftContent>
+ </TextBox>
+ <ListBox Classes="soft" ItemsSource="{Binding VisibleProfiles}" SelectedItem="{Binding SelectedProfile}">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:ProfileItemViewModel">
<DockPanel>
@@ -265,9 +270,14 @@
<!-- Palette -->
<StackPanel Grid.Column="4" Spacing="8">
<TextBlock Classes="label" Text="{DynamicResource toolbar.available}" />
+ <TextBox Classes="search" Text="{Binding PaletteSearch}" Watermark="{DynamicResource common.search}">
+ <TextBox.InnerLeftContent>
+ <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
+ </TextBox.InnerLeftContent>
+ </TextBox>
<Border x:Name="PaletteBox" MinHeight="180" Padding="6" CornerRadius="{DynamicResource SoftRadius}"
BorderThickness="2" BorderBrush="{DynamicResource SubtleBorderBrush}" Background="Transparent">
- <ItemsControl ItemsSource="{Binding Palette}">
+ <ItemsControl ItemsSource="{Binding VisiblePalette}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
diff --git a/src/Filee.App/Views/Pages/TriggersPage.axaml b/src/Filee.App/Views/Pages/TriggersPage.axaml
index 70001b8e..dbe420e2 100644
--- a/src/Filee.App/Views/Pages/TriggersPage.axaml
+++ b/src/Filee.App/Views/Pages/TriggersPage.axaml
@@ -1,6 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Filee.App.ViewModels.Pages"
+ xmlns:c="using:Filee.App.Controls"
x:Class="Filee.App.Views.Pages.TriggersPage"
x:DataType="vm:TriggersPageViewModel">
<StackPanel Spacing="18">
@@ -119,9 +120,42 @@
</ItemsControl>
<Border Classes="card">
- <StackPanel>
+ <StackPanel Spacing="8" DataContext="{Binding ExcludedApps}" x:DataType="vm:ExcludedAppsViewModel">
<TextBlock Classes="label" Text="{DynamicResource triggers.excluded}" />
- <TextBox Text="{Binding Excluded}" PlaceholderText="{DynamicResource triggers.excluded_hint}" />
+ <c:TagEditor Tags="{Binding Tags}" Suggestions="{Binding Suggestions}" Text="{Binding Text}"
+ AddCommand="{Binding AddCommand}" RemoveCommand="{Binding RemoveCommand}"
+ PlaceholderText="{DynamicResource triggers.excluded_hint}" />
+ <!-- Pick from the apps that have a window open now -->
+ <Button HorizontalAlignment="Left" Command="{Binding LoadRunningAppsCommand}">
+ <StackPanel Orientation="Horizontal" Spacing="6">
+ <PathIcon Width="12" Height="12" Data="{StaticResource Icon.Plus}" />
+ <TextBlock Text="{DynamicResource triggers.excluded_pick}" />
+ </StackPanel>
+ <Button.Flyout>
+ <Flyout Placement="BottomEdgeAlignedLeft">
+ <StackPanel Spacing="8" Width="280">
+ <TextBox Text="{Binding RunningSearch}" Watermark="{DynamicResource common.search}">
+ <TextBox.InnerLeftContent>
+ <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
+ </TextBox.InnerLeftContent>
+ </TextBox>
+ <TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource triggers.excluded_none_running}"
+ IsVisible="{Binding NoRunningApps}" />
+ <ScrollViewer MaxHeight="280">
+ <ItemsControl ItemsSource="{Binding VisibleRunningApps}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate x:DataType="x:String">
+ <Button Classes="ghost" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Content="{Binding}"
+ Command="{Binding $parent[ItemsControl].((vm:ExcludedAppsViewModel)DataContext).AddCommand}" CommandParameter="{Binding}" />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </StackPanel>
+ </Flyout>
+ </Button.Flyout>
+ </Button>
+ <TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource triggers.excluded_note}" />
</StackPanel>
</Border>
</StackPanel>
diff --git a/src/Filee.Core/Platform/IPlatformServices.cs b/src/Filee.Core/Platform/IPlatformServices.cs
index 21bd05ff..7a440a48 100644
--- a/src/Filee.Core/Platform/IPlatformServices.cs
+++ b/src/Filee.Core/Platform/IPlatformServices.cs
@@ -12,6 +12,22 @@ public interface IPlatformServices
/// <summary>Process name (without extension) owning the window under the point, or <c>null</c>.</summary>
string? ProcessNameAt(int x, int y);
+ /// <summary>
+ /// Names of the apps that have a window open now, as <see cref="ProcessNameAt"/> reports them, sorted, without
+ /// Filee. Windows reports a main window per process; macOS and Linux list the windows on screen.
+ /// </summary>
+ IReadOnlyList<string> RunningAppNames() => AppNames(System.Diagnostics.Process.GetProcesses()
+ .Where(p => { try { return p.MainWindowHandle != 0; } catch (InvalidOperationException) { return false; } })
+ .Select(p => { using (p) return p.ProcessName; }));
+
+ /// <summary>Distinct, sorted, Filee itself left out.</summary>
+ static IReadOnlyList<string> AppNames(IEnumerable<string?> names)
+ {
+ var own = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
+ return [.. names.OfType<string>().Where(n => n.Length > 0 && !n.Equals(own, StringComparison.OrdinalIgnoreCase))
+ .Distinct(StringComparer.OrdinalIgnoreCase).Order(StringComparer.CurrentCultureIgnoreCase)];
+ }
+
/// <summary>Files currently selected in the foreground file manager window (empty if none).</summary>
IReadOnlyList<string> GetFileManagerSelection();
diff --git a/src/Filee.Platform.Linux/LinuxPlatformServices.cs b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
index 7ee2d013..4c62ffb6 100644
--- a/src/Filee.Platform.Linux/LinuxPlatformServices.cs
+++ b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
@@ -33,6 +33,8 @@ public sealed class LinuxPlatformServices : IPlatformServices
public bool IsFileManagerAt(int x, int y) => ProcessNameAt(x, y) is { } name && FileManagers.Contains(name);
public string? ProcessNameAt(int x, int y) => X11WindowSystem.ProcessNameAt(x, y);
+
+ public IReadOnlyList<string> RunningAppNames() => IPlatformServices.AppNames(X11WindowSystem.ClientProcessNames());
public IReadOnlyList<string> GetFileManagerSelection() => throw new NotSupportedException(SelectionShortcutUnavailableReason);
public int SystemDragThreshold => 8;
diff --git a/src/Filee.Platform.Linux/X11WindowSystem.cs b/src/Filee.Platform.Linux/X11WindowSystem.cs
index 96cfaac3..4d97c514 100644
--- a/src/Filee.Platform.Linux/X11WindowSystem.cs
+++ b/src/Filee.Platform.Linux/X11WindowSystem.cs
@@ -43,6 +43,45 @@ internal static class X11WindowSystem
}
}
+ /// <summary>Process names of the windows the window manager lists (_NET_CLIENT_LIST).</summary>
+ internal static IReadOnlyList<string> ClientProcessNames()
+ {
+ if (!IsAvailable)
+ return [];
+ var display = OpenDisplay();
+ if (display == 0)
+ return [];
+ try
+ {
+ var list = XInternAtom(display, "_NET_CLIENT_LIST", 1);
+ if (list == 0 || XGetWindowProperty(display, XDefaultRootWindow(display), list, 0, 4096, 0, 0,
+ out _, out var format, out var count, out _, out var data) != 0)
+ return [];
+ try
+ {
+ if (data == 0 || format != 32 || count == 0)
+ return [];
+ var names = new List<string>();
+ for (var i = 0; i < (int)count; i++)
+ {
+ // Format-32 properties come back as C longs, one per window.
+ var window = (nuint)(ulong)Marshal.ReadIntPtr(data, i * IntPtr.Size);
+ if (ReadProcessName(display, window) is { } name)
+ names.Add(name);
+ }
+ return names;
+ }
+ finally
+ {
+ XFree(data);
+ }
+ }
+ finally
+ {
+ XCloseDisplay(display);
+ }
+ }
+
internal static void RaiseTopmost(nint window)
{
if (window == 0 || !IsAvailable)
diff --git a/src/Filee.Platform.MacOS/MacOSPlatformServices.cs b/src/Filee.Platform.MacOS/MacOSPlatformServices.cs
index 4b838c56..894ea02f 100644
--- a/src/Filee.Platform.MacOS/MacOSPlatformServices.cs
+++ b/src/Filee.Platform.MacOS/MacOSPlatformServices.cs
@@ -31,6 +31,8 @@ public sealed class MacOSPlatformServices : IPlatformServices
public string? ProcessNameAt(int x, int y) => NativeMethods.ProcessNameAt(x, y);
+ public IReadOnlyList<string> RunningAppNames() => IPlatformServices.AppNames(NativeMethods.WindowOwnerNames().ToList());
+
public IReadOnlyList<string> GetFileManagerSelection()
{
LastSelectionError = null;
diff --git a/src/Filee.Platform.MacOS/NativeMethods.cs b/src/Filee.Platform.MacOS/NativeMethods.cs
index 3a7af6cd..79ce6885 100644
--- a/src/Filee.Platform.MacOS/NativeMethods.cs
+++ b/src/Filee.Platform.MacOS/NativeMethods.cs
@@ -17,6 +17,42 @@ internal static class NativeMethods
private static readonly nint AlphaKey = CFStringCreateWithCString(0, "kCGWindowAlpha", 0x08000100);
private static readonly nint LayerKey = CFStringCreateWithCString(0, "kCGWindowLayer", 0x08000100);
+ /// <summary>Process names of the app windows on screen (layer 0), front to back.</summary>
+ internal static IEnumerable<string> WindowOwnerNames()
+ {
+ var windows = CGWindowListCopyWindowInfo(1, 0);
+ if (windows == 0)
+ yield break;
+ try
+ {
+ for (nint index = 0; index < CFArrayGetCount(windows); index++)
+ {
+ var window = CFArrayGetValueAtIndex(windows, index);
+ var layerValue = CFDictionaryGetValue(window, LayerKey);
+ if (layerValue == 0 || !CFNumberGetInt(layerValue, 3, out var layer) || layer != 0)
+ continue;
+ var pidValue = CFDictionaryGetValue(window, PidKey);
+ if (pidValue == 0 || !CFNumberGetInt(pidValue, 3, out var pid))
+ continue;
+ string? name = null;
+ try
+ {
+ using var process = Process.GetProcessById(pid);
+ name = process.ProcessName;
+ }
+ catch (ArgumentException) { }
+ catch (InvalidOperationException) { }
+ catch (System.ComponentModel.Win32Exception) { }
+ if (name is not null)
+ yield return name;
+ }
+ }
+ finally
+ {
+ CFRelease(windows);
+ }
+ }
+
internal static string? ProcessNameAt(int x, int y)
{
var windows = CGWindowListCopyWindowInfo(1, 0);
diff --git a/tests/Filee.App.Tests/ListSearchTests.cs b/tests/Filee.App.Tests/ListSearchTests.cs
new file mode 100644
index 00000000..858634bb
--- /dev/null
+++ b/tests/Filee.App.Tests/ListSearchTests.cs
@@ -0,0 +1,131 @@
+// The search boxes above the profile, palette and preset lists, and the excluded apps on the Shortcuts page.
+
+using System.Collections.ObjectModel;
+using Avalonia.Headless.XUnit;
+using Filee.App.Controls;
+using Filee.App.Services;
+using Filee.App.ViewModels;
+using Filee.App.ViewModels.Pages;
+using Filee.Core.Platform;
+using Filee.Core.Settings;
+
+namespace Filee.App.Tests;
+
+public class ListSearchTests
+{
+ private sealed record Item(string Name, string Format);
+
+ [Fact]
+ public void Filtered_list_follows_the_query_and_the_source()
+ {
+ var photo = new Item("Photos", "jpg");
+ var docs = new Item("Documents", "pdf");
+ var source = new ObservableCollection<Item> { photo, docs };
+ var list = new FilteredList<Item>(source, i => [i.Name, i.Format]);
+ Assert.Equal([photo, docs], list);
+
+ list.Query = "PDF ";
+ Assert.Equal([docs], list); // any of the texts, ignoring case and spaces around the query
+
+ var scans = new Item("Scans", "pdf");
+ source.Insert(0, scans);
+ Assert.Equal([scans, docs], list); // in the source's order
+
+ source.Remove(docs);
+ Assert.Equal([scans], list);
+
+ list.Query = "";
+ Assert.Equal([scans, photo], list);
+ }
+
+ [Fact]
+ public void Filtered_list_keeps_the_items_that_still_match()
+ {
+ var a = new Item("Alpha", "a");
+ var b = new Item("Beta", "b");
+ var source = new ObservableCollection<Item> { a, b };
+ var list = new FilteredList<Item>(source, i => [i.Name]);
+ var removed = 0;
+ list.CollectionChanged += (_, e) => removed += e.OldItems?.Count ?? 0;
+
+ list.Query = "a"; // both match ("Alpha", "Beta")
+ Assert.Equal(0, removed);
+ list.Query = "al";
+ Assert.Equal(1, removed); // only Beta went: a ListBox keeps Alpha selected
+ }
+
+ private sealed class Apps(params string[] names) : IPlatformServices
+ {
+ public IReadOnlyList<string> RunningAppNames() => IPlatformServices.AppNames(names);
+ public bool IsFileManagerAt(int x, int y) => false;
+ public string? ProcessNameAt(int x, int y) => null;
+ public IReadOnlyList<string> GetFileManagerSelection() => [];
+ public int SystemDragThreshold => 4;
+ public bool PrefersReducedMotion => false;
+ public void SetStartWithSystem(bool enabled, string executablePath) { }
+ public void SetContextMenu(bool enabled, string executablePath, string label) { }
+ public ModernContextMenuState GetModernContextMenuState(string executablePath) => ModernContextMenuState.Unsupported;
+ public Task<ModernContextMenuResult> SetModernContextMenuAsync(bool enabled, string executablePath) => Task.FromResult(new ModernContextMenuResult(false));
+ public void RevealInFileManager(string path) { }
+ public void RaiseTopmost(nint windowHandle) { }
+ }
+
+ [Fact]
+ public void Excluded_apps_are_tags_picked_or_typed()
+ {
+ var excluded = new List<string> { "code" };
+ var saves = 0;
+ var vm = new ExcludedAppsViewModel(excluded, new Apps("Photoshop", "code", "Finder", "photoshop"), () => saves++);
+ Assert.Equal(["code"], vm.Tags.Select(t => t.Value));
+
+ // Typing suggests the running apps that aren't excluded yet.
+ vm.Text = "sho";
+ Assert.Equal(["Photoshop"], vm.Suggestions.Select(s => s.Value));
+
+ // The list to pick from: apps with a window, sorted, without duplicates or excluded ones.
+ vm.LoadRunningApps();
+ Assert.Equal(["Finder", "Photoshop"], vm.RunningApps);
+ vm.RunningSearch = "fin";
+ Assert.Equal(["Finder"], vm.VisibleRunningApps);
+
+ vm.AddCommand.Execute("Finder");
+ vm.AddCommand.Execute(" Photoshop.exe "); // typed like Windows shows it
+ vm.AddCommand.Execute("CODE"); // already there
+ Assert.Equal(["code", "Finder", "Photoshop"], excluded);
+ Assert.Equal(2, saves);
+ Assert.Empty(vm.RunningApps);
+ Assert.True(vm.NoRunningApps);
+
+ vm.RemoveCommand.Execute(new TagChip("finder", "finder"));
+ Assert.Equal(["code", "Photoshop"], excluded);
+ Assert.Equal(["Finder"], vm.RunningApps);
+ }
+
+ [Fact]
+ public void Running_app_names_leave_out_filee_itself()
+ {
+ var own = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
+ Assert.Equal(["a", "B"], IPlatformServices.AppNames(["B", own, "a", "", null, "b"]));
+ }
+
+ [AvaloniaFact]
+ public void Updates_are_set_on_the_about_page()
+ {
+ TestServices.EnsureInitialized("en");
+ var store = AppHost.Get<UserDataStore>();
+ var before = store.Settings.CheckForUpdates;
+ try
+ {
+ using var about = new AboutPageViewModel(AppHost.Get<Filee.Core.Localization.ILocalizer>(), store, AppHost.Get<UpdateService>());
+ Assert.Equal(before, about.CheckForUpdates);
+ about.CheckForUpdates = !before;
+ Assert.Equal(!before, store.Settings.CheckForUpdates);
+ Assert.True(about.CheckNowCommand.CanExecute(null));
+ }
+ finally
+ {
+ store.Settings.CheckForUpdates = before;
+ store.SaveSettings();
+ }
+ }
+}
diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.cs
index ca1d6424..a10795ce 100644
--- a/tests/Filee.App.Tests/RenderTests.cs
+++ b/tests/Filee.App.Tests/RenderTests.cs
@@ -174,14 +174,13 @@ public class RenderTests
window.Show();
Pump();
- // Everything not installed is offered; small downloads are pre-selected, the large LibreOffice, FFmpeg and calibre and the
- // EPS-only Ghostscript not.
- // (On macOS FFmpeg and Ghostscript come from Homebrew: listed, but not offered for download.)
- Assert.All(vm.Packages.Where(p => !p.IsInstalled && p.CanInstall), p => Assert.Equal(
- Filee.Engines.Infrastructure.EngineDownloads.DownloadSize(p.Package) < Filee.Engines.Infrastructure.EngineDownloads.SuggestLimit
- && p.Package.Id != "ghostscript", p.Selected));
- Assert.DoesNotContain(vm.Packages, p => p.Package.Id is "libreoffice" or "ffmpeg" or "calibre" or "ghostscript" && p.Selected);
- Assert.Equal(vm.Packages.Any(p => p.Selected && p.CanInstall), vm.InstallCommand.CanExecute(null));
+ // Everything not installed is offered, nothing is ticked: installing needs a choice first.
+ Assert.Contains(vm.Packages, p => !p.IsInstalled && p.CanInstall);
+ Assert.DoesNotContain(vm.Packages, p => p.Selected);
+ Assert.False(vm.InstallCommand.CanExecute(null));
+ vm.Packages.First(p => p.CanInstall && !p.IsInstalled).Selected = true;
+ Assert.True(vm.InstallCommand.CanExecute(null));
+ vm.Packages.First(p => p.Selected).Selected = false;
Save(window, $"engine-setup-{language}.png");
window.Close();
}
@@ -511,6 +510,33 @@ public class RenderTests
}
}
+ [AvaloniaTheory]
+ [InlineData("en")]
+ [InlineData("ko")]
+ public void Excluded_apps_render_as_tags(string language)
+ {
+ TestServices.EnsureInitialized(language);
+ var store = AppHost.Get<UserDataStore>();
+ var before = store.Settings.ExcludedProcesses.ToList();
+ try
+ {
+ store.Settings.ExcludedProcesses.Clear();
+ store.Settings.ExcludedProcesses.AddRange(["Photoshop", "code"]);
+ var vm = new TriggersPageViewModel(store, AppHost.Get<Filee.Core.Localization.ILocalizer>());
+ var window = new Window { Content = new Filee.App.Views.Pages.TriggersPage { DataContext = vm }, Width = 820, Height = 1500 };
+ window.Show();
+ Pump();
+ Assert.Equal(["Photoshop", "code"], vm.ExcludedApps.Tags.Select(t => t.Value));
+ Save(window, $"triggers-excluded-{language}.png");
+ window.Close();
+ }
+ finally
+ {
+ store.Settings.ExcludedProcesses.Clear();
+ store.Settings.ExcludedProcesses.AddRange(before);
+ }
+ }
+
private static void Pump()
{
// Let layout, bindings and a few animation frames run.