Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "فتح الملف",
"home.open_with": "فتح باستخدام",
"home.clear_history": "مسح",
"home.remove_from_history": "إزالة من السجل",
"home.files": "عدد الملفات: {0}",
"home.failed_files": "فشل: {0}",
"home.undo": "تراجع",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/bn-BD.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"home.open_file": "ফাইল খুলুন",
"home.open_with": "এর মাধ্যমে খুলুন",
"home.clear_history": "মুছে ফেলুন",
"home.remove_from_history": "ইতিহাস থেকে সরান",
"home.files": "{0}টি ফাইল",
"home.failed_files": "{0}টি ব্যর্থ",
"home.undo": "পূর্বাবস্থায় ফেরান",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "Datei öffnen",
"home.open_with": "Öffnen mit",
"home.clear_history": "Leeren",
"home.remove_from_history": "Aus dem Verlauf entfernen",
"home.files": "{0} Dateien",
"home.failed_files": "{0} fehlgeschlagen",
"home.undo": "Rückgängig",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Open file",
"home.open_with": "Open with",
"home.clear_history": "Clear",
"home.remove_from_history": "Remove from history",
"home.files": "{0} files",
"home.failed_files": "{0} failed",
"home.undo": "Undo",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "Abrir archivo",
"home.open_with": "Abrir con",
"home.clear_history": "Borrar",
"home.remove_from_history": "Quitar del historial",
"home.files": "{0} archivos",
"home.failed_files": "{0} con error",
"home.undo": "Deshacer",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"home.open_file": "باز کردن فایل",
"home.open_with": "باز کردن با",
"home.clear_history": "پاک کردن",
"home.remove_from_history": "حذف از تاریخچه",
"home.files": "{0} فایل",
"home.failed_files": "{0} ناموفق",
"home.undo": "واگرد",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Ouvrir le fichier",
"home.open_with": "Ouvrir avec",
"home.clear_history": "Effacer",
"home.remove_from_history": "Retirer de l'historique",
"home.files": "{0} fichiers",
"home.failed_files": "{0} en échec",
"home.undo": "Annuler",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "फ़ाइल खोलें",
"home.open_with": "इसके साथ खोलें",
"home.clear_history": "साफ़ करें",
"home.remove_from_history": "इतिहास से हटाएँ",
"home.files": "{0} फ़ाइलें",
"home.failed_files": "{0} विफल",
"home.undo": "पूर्ववत करें",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "Buka file",
"home.open_with": "Buka dengan",
"home.clear_history": "Bersihkan",
"home.remove_from_history": "Hapus dari riwayat",
"home.files": "{0} file",
"home.failed_files": "{0} gagal",
"home.undo": "Urungkan",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"home.open_file": "Apri file",
"home.open_with": "Apri con",
"home.clear_history": "Cancella",
"home.remove_from_history": "Rimuovi dalla cronologia",
"home.files": "{0} file",
"home.failed_files": "{0} non riusciti",
"home.undo": "Annulla",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "ファイルを開く",
"home.open_with": "プログラムから開く",
"home.clear_history": "消去",
"home.remove_from_history": "履歴から削除",
"home.files": "{0}個のファイル",
"home.failed_files": "{0}件失敗",
"home.undo": "元に戻す",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "파일 열기",
"home.open_with": "연결 프로그램",
"home.clear_history": "지우기",
"home.remove_from_history": "기록에서 제거",
"home.files": "파일 {0}개",
"home.failed_files": "{0}개 실패",
"home.undo": "되돌리기",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"home.open_file": "Файл нээх",
"home.open_with": "Програмаар нээх",
"home.clear_history": "Цэвэрлэх",
"home.remove_from_history": "Түүхээс устгах",
"home.files": "{0} файл",
"home.failed_files": "{0} амжилтгүй",
"home.undo": "Буцаах",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/ne.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "फाइल खोल्नुहोस्",
"home.open_with": "यसमार्फत खोल्नुहोस्",
"home.clear_history": "खाली गर्नुहोस्",
"home.remove_from_history": "इतिहासबाट हटाउनुहोस्",
"home.files": "{0} फाइलहरू",
"home.failed_files": "{0} असफल",
"home.undo": "पूर्ववत गर्नुहोस्",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Otwórz plik",
"home.open_with": "Otwórz za pomocą",
"home.clear_history": "Wyczyść",
"home.remove_from_history": "Usuń z historii",
"home.files": "Pliki: {0}",
"home.failed_files": "Błędy: {0}",
"home.undo": "Cofnij",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Abrir arquivo",
"home.open_with": "Abrir com",
"home.clear_history": "Limpar",
"home.remove_from_history": "Remover do histórico",
"home.files": "{0} arquivos",
"home.failed_files": "{0} falharam",
"home.undo": "Desfazer",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Abrir ficheiro",
"home.open_with": "Abrir com",
"home.clear_history": "Limpar",
"home.remove_from_history": "Remover do histórico",
"home.files": "{0} ficheiros",
"home.failed_files": "Falhas: {0}",
"home.undo": "Anular",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Открыть файл",
"home.open_with": "Открыть с помощью",
"home.clear_history": "Очистить",
"home.remove_from_history": "Удалить из истории",
"home.files": "Файлов: {0}",
"home.failed_files": "Ошибок: {0}",
"home.undo": "Отменить",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "เปิดไฟล์",
"home.open_with": "เปิดด้วย",
"home.clear_history": "ล้างประวัติ",
"home.remove_from_history": "ลบออกจากประวัติ",
"home.files": "{0} ไฟล์",
"home.failed_files": "ล้มเหลว {0} ไฟล์",
"home.undo": "เลิกทำ",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"home.open_file": "Dosyayı aç",
"home.open_with": "Birlikte aç",
"home.clear_history": "Temizle",
"home.remove_from_history": "Geçmişten kaldır",
"home.files": "{0} dosya",
"home.failed_files": "{0} başarısız",
"home.undo": "Geri al",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "Mở tệp",
"home.open_with": "Mở bằng",
"home.clear_history": "Xóa",
"home.remove_from_history": "Xóa khỏi lịch sử",
"home.files": "{0} tệp",
"home.failed_files": "{0} lỗi",
"home.undo": "Hoàn tác",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "打开文件",
"home.open_with": "打开方式",
"home.clear_history": "清除",
"home.remove_from_history": "从历史记录中移除",
"home.files": "{0} 个文件",
"home.failed_files": "{0} 个失败",
"home.undo": "撤销",
Expand Down
1 change: 1 addition & 0 deletions src/Filee.App/Assets/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"home.open_file": "開啟檔案",
"home.open_with": "開啟方式",
"home.clear_history": "清除",
"home.remove_from_history": "從歷史記錄中移除",
"home.files": "{0} 個檔案",
"home.failed_files": "{0} 個失敗",
"home.undo": "復原",
Expand Down
7 changes: 7 additions & 0 deletions src/Filee.App/ViewModels/Pages/HomePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ private void Refused(HistoryOutput output, TrashRefusal refusal)
CanUndo = UndoLeft();
}

/// <summary>
/// The card's X: drops this conversion from the history. Its results and sources stay where they are; only the entry
/// is forgotten (Clear drops them all). The list is rebuilt from the store's change notification.
/// </summary>
[RelayCommand]
private void RemoveFromHistory() => _store?.RemoveHistory(_entry);

[RelayCommand]
private void OpenFolder()
{
Expand Down
57 changes: 32 additions & 25 deletions src/Filee.App/Views/Pages/HomePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,31 +161,38 @@
<Border Classes="card history-card" Padding="14,10">
<StackPanel Spacing="8">
<DockPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="6" VerticalAlignment="Center"
IsVisible="{Binding HasOutputs}">
<Button Command="{Binding OpenFileCommand}" IsVisible="{Binding CanOpen}" Padding="10,5">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.File}" />
<TextBlock Text="{DynamicResource home.open_file}" />
</StackPanel>
</Button>
<!-- Only where the system has an "Open with" dialog (Windows). -->
<Button Command="{Binding OpenWithCommand}" IsVisible="{Binding CanOpenWith}" Padding="8,5"
ToolTip.Tip="{DynamicResource home.open_with}" AutomationProperties.Name="{DynamicResource home.open_with}">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.OpenWith}" />
</Button>
<Button Command="{Binding OpenFolderCommand}" Padding="10,5">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />
<TextBlock Text="{DynamicResource home.open_folder}" />
</StackPanel>
</Button>
<!-- Only while every result is as the job left it: they go to the Recycle Bin / Trash. -->
<Button Command="{Binding UndoCommand}" IsVisible="{Binding CanUndo}" Padding="10,5" ToolTip.Tip="{DynamicResource home.undo_hint}">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.Undo}" />
<TextBlock Text="{DynamicResource home.undo}" />
</StackPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" Spacing="6" IsVisible="{Binding HasOutputs}">
<Button Command="{Binding OpenFileCommand}" IsVisible="{Binding CanOpen}" Padding="10,5">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.File}" />
<TextBlock Text="{DynamicResource home.open_file}" />
</StackPanel>
</Button>
<!-- Only where the system has an "Open with" dialog (Windows). -->
<Button Command="{Binding OpenWithCommand}" IsVisible="{Binding CanOpenWith}" Padding="8,5"
ToolTip.Tip="{DynamicResource home.open_with}" AutomationProperties.Name="{DynamicResource home.open_with}">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.OpenWith}" />
</Button>
<Button Command="{Binding OpenFolderCommand}" Padding="10,5">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />
<TextBlock Text="{DynamicResource home.open_folder}" />
</StackPanel>
</Button>
<!-- Only while every result is as the job left it: they go to the Recycle Bin / Trash. -->
<Button Command="{Binding UndoCommand}" IsVisible="{Binding CanUndo}" Padding="10,5" ToolTip.Tip="{DynamicResource home.undo_hint}">
<StackPanel Orientation="Horizontal" Spacing="6">
<PathIcon Width="13" Height="13" Data="{StaticResource Icon.Undo}" />
<TextBlock Text="{DynamicResource home.undo}" />
</StackPanel>
</Button>
</StackPanel>
<!-- The card's X: forgets this conversion, leaving its files where they are. -->
<Button Classes="ghost" Padding="8,5" Command="{Binding RemoveFromHistoryCommand}"
ToolTip.Tip="{DynamicResource home.remove_from_history}"
AutomationProperties.Name="{DynamicResource home.remove_from_history}">
<PathIcon Width="12" Height="12" Data="{StaticResource Icon.Close}" />
</Button>
</StackPanel>
<!-- The result: its picture, else its format; the corner says whether the job went well. -->
Expand Down
17 changes: 17 additions & 0 deletions src/Filee.Core/Settings/UserDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,23 @@ public void ClearHistory()
HistoryChanged?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// Drops one finished conversion from the history (the card's X in Recent conversions). The files it made stay where
/// they are: this only forgets the entry, unlike <see cref="ClearHistory"/> which forgets all of them.
/// </summary>
/// <returns>Whether the entry was in the history and has been removed.</returns>
public bool RemoveHistory(HistoryEntry entry)
{
bool removed;
lock (_saveLock)
removed = History.Remove(entry);
if (!removed)
return false;
Write(HistoryPath, History, FileeJsonContext.Default.ListHistoryEntry);
HistoryChanged?.Invoke(this, EventArgs.Empty);
return true;
}

/// <summary>Replaces presets and profiles with factory defaults.</summary>
public void ResetLibrary()
{
Expand Down
39 changes: 39 additions & 0 deletions tests/Filee.App.Tests/RecentConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,45 @@ public async Task Undo_moves_the_results_to_the_trash_while_they_are_as_the_job_
}
}

[AvaloniaFact]
public void A_card_can_be_removed_from_the_history_leaving_its_files()
{
TestServices.EnsureInitialized("en");
var loc = AppHost.Get<ILocalizer>();
var store = AppHost.Get<UserDataStore>();
var folder = Directory.CreateTempSubdirectory("filee-remove-").FullName;
store.ClearHistory();
try
{
var keep = Path.Combine(folder, "keep.png");
var gone = Path.Combine(folder, "gone.png");
File.WriteAllBytes(keep, [1]);
File.WriteAllBytes(gone, [2]);
store.AddHistory(Entry([keep], "PNG", [Path.Combine(folder, "keep.heic")]));
store.AddHistory(Entry([gone], "PNG", [Path.Combine(folder, "gone.heic")]));
Assert.Equal(2, store.History.Count);
var goneEntry = store.History[0]; // the newest, listed first

// The card's X forgets that entry only, and the file it made stays where it is.
var item = new HistoryItemViewModel(goneEntry, loc, new OpeningPlatform(false), store: store);
item.RemoveFromHistoryCommand.Execute(null);
Assert.DoesNotContain(goneEntry, store.History);
Assert.Single(store.History);
Assert.True(File.Exists(gone));

// It is saved: the next application loads it without that entry.
var reloaded = new UserDataStore(store.Directory);
reloaded.Load();
Assert.Single(reloaded.History);
Assert.DoesNotContain(goneEntry, reloaded.History);
}
finally
{
store.ClearHistory();
Directory.Delete(folder, true);
}
}

private static HistoryOutput Stamp(string path)
{
var info = new FileInfo(path);
Expand Down
27 changes: 27 additions & 0 deletions tests/Filee.Core.Tests/UserDataStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,33 @@ public void History_is_kept_until_turned_off_and_can_be_cleared()
Assert.Empty(reloaded.History);
}

[Fact]
public void One_history_entry_can_be_removed_and_the_rest_are_saved()
{
using var dir = new TempDir();
var store = new UserDataStore(dir.Path);
store.Load();

var a = new Filee.Core.History.HistoryEntry { JobId = "a" };
var b = new Filee.Core.History.HistoryEntry { JobId = "b" };
var c = new Filee.Core.History.HistoryEntry { JobId = "c" };
store.AddHistory(a);
store.AddHistory(b);
store.AddHistory(c); // newest first: c, b, a
Assert.Equal(["c", "b", "a"], store.History.Select(e => e.JobId));

// Removing the middle one leaves the others, and is written to disk.
Assert.True(store.RemoveHistory(b));
Assert.Equal(["c", "a"], store.History.Select(e => e.JobId));
var reloaded = new UserDataStore(dir.Path);
reloaded.Load();
Assert.Equal(["c", "a"], reloaded.History.Select(e => e.JobId));

// Removing one that is no longer there changes nothing and says so.
Assert.False(store.RemoveHistory(b));
Assert.Equal(2, store.History.Count);
}

[Fact]
public void History_keeps_the_newest_entries_up_to_the_limit()
{
Expand Down