make Ctrl+C on an entry copy its password

This commit is contained in:
2026-03-27 14:07:50 +03:00
parent 3b8b7217a1
commit 9ed68588c3
2 changed files with 16 additions and 2 deletions

View File

@@ -100,7 +100,8 @@
Margin="286 10 10 10"
ItemsSource="{Binding Passwords}"
Background="Transparent"
SelectionMode="Single">
SelectionMode="Single"
KeyDown="PasswordsListBox_KeyDown">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@@ -110,7 +111,8 @@
<ListBox.ItemTemplate>
<DataTemplate>
<Border Background="Transparent" DoubleTapped="Entry_DoubleTapped">
<Border Background="Transparent"
DoubleTapped="Entry_DoubleTapped">
<StackPanel Width="100"
Margin="10"

View File

@@ -155,6 +155,18 @@ public partial class RepositoryWindow : Window
}
}
private void PasswordsListBox_KeyDown(object sender, KeyEventArgs args)
{
if (args.Key == Key.C && args.KeyModifiers == KeyModifiers.Control)
{
if (sender is ListBox list && list.SelectedItem is PassStoreEntryPassword pwd)
{
Clipboard!.SetTextAsync(pwd.Password.Value);
this.FindControlRecursive<ToastNotificationHost>("NotificationHost")?.Show("Password copied to clipboard");
}
}
}
private async void EntryContextMenuItem_Click(object sender, RoutedEventArgs args)
{
if (args.Source is StyledElement s && s.DataContext is PassStoreEntryPassword pwd)