From d1ad7df811c7a363d4284f79ddddbc910002fe5a Mon Sep 17 00:00:00 2001 From: Slavasil Date: Thu, 7 May 2026 22:28:20 +0300 Subject: [PATCH] fix copying linked passwords --- src/KeyKeeper/Views/RepositoryWindow.axaml.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/KeyKeeper/Views/RepositoryWindow.axaml.cs b/src/KeyKeeper/Views/RepositoryWindow.axaml.cs index ef16083..b0065ce 100644 --- a/src/KeyKeeper/Views/RepositoryWindow.axaml.cs +++ b/src/KeyKeeper/Views/RepositoryWindow.axaml.cs @@ -206,10 +206,9 @@ public partial class RepositoryWindow : Window private void Entry_DoubleTapped(object sender, TappedEventArgs args) { - if (args.Source is StyledElement s && s.DataContext is PassStoreEntryPassword pwd) + if (args.Source is StyledElement s && s.DataContext is PassStoreEntry ent) { - Clipboard!.SetTextAsync(pwd.Password.Value); - this.FindControlRecursive("NotificationHost")?.Show("Password copied to clipboard"); + CopyPassword(ent); } } @@ -217,14 +216,24 @@ public partial class RepositoryWindow : Window { if (args.Key == Key.C && args.KeyModifiers == KeyModifiers.Control) { - if (sender is ListBox list && list.SelectedItem is PassStoreEntryPassword pwd) + if (sender is ListBox list && list.SelectedItem is PassStoreEntry ent) { - Clipboard!.SetTextAsync(pwd.Password.Value); - this.FindControlRecursive("NotificationHost")?.Show("Password copied to clipboard"); + CopyPassword(ent); } } } + private void CopyPassword(PassStoreEntry ent) + { + PassStoreEntryPassword? pwd = null; + if (ent is PassStoreEntryPassword p) pwd = p; + else if (ent is PassStoreEntryLink lnk && lnk.LinkTarget is PassStoreEntryPassword p1) pwd = p1; + if (pwd == null) return; + + Clipboard!.SetTextAsync(pwd.Password.Value); + this.FindControlRecursive("NotificationHost")?.Show("Password copied to clipboard"); + } + private void EntryContextMenu_Opening(object? sender, RoutedEventArgs args) { if (sender is not ContextMenu contextMenu || DataContext is not RepositoryWindowViewModel vm ||