mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-17 18:16:28 +03:00
basic recent files list, no persistence
This commit is contained in:
@@ -24,9 +24,10 @@ public partial class App : Application
|
||||
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
|
||||
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
|
||||
DisableAvaloniaDataAnnotationValidation();
|
||||
desktop.MainWindow = new MainWindow
|
||||
var recentFilesService = new RecentFilesService();
|
||||
desktop.MainWindow = new MainWindow(recentFilesService)
|
||||
{
|
||||
DataContext = new MainWindowViewModel(new RecentFilesService()),
|
||||
DataContext = new MainWindowViewModel(recentFilesService),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,16 +20,6 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
this.recentFilesService = recentFilesService;
|
||||
}
|
||||
|
||||
public void OpenVault(string filename)
|
||||
{
|
||||
recentFilesService.Remember(filename);
|
||||
}
|
||||
|
||||
public void CreateVault(string filename)
|
||||
{
|
||||
recentFilesService.Remember(filename);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OpenSettings()
|
||||
{
|
||||
|
||||
@@ -78,9 +78,14 @@
|
||||
ItemsSource="{Binding RecentFiles}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:RecentFile">
|
||||
<TextBlock Text="{Binding DisplayPath}"
|
||||
Foreground="#000"
|
||||
Margin="5"/>
|
||||
<Border Background="Transparent"
|
||||
Cursor="Hand"
|
||||
DoubleTapped="RecentVaultsListItem_DoubleTapped"
|
||||
Padding="10">
|
||||
<TextBlock Text="{Binding DisplayPath}"
|
||||
Foreground="#000"
|
||||
Margin="5"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.Styles>
|
||||
@@ -93,7 +98,5 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -3,8 +3,10 @@ using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using KeyKeeper.Models;
|
||||
using KeyKeeper.PasswordStore;
|
||||
using KeyKeeper.PasswordStore.Crypto;
|
||||
using KeyKeeper.Services;
|
||||
using KeyKeeper.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,8 +17,11 @@ namespace KeyKeeper.Views
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
private IRecentFilesService recentFilesService;
|
||||
|
||||
public MainWindow(IRecentFilesService recentFilesService)
|
||||
{
|
||||
this.recentFilesService = recentFilesService;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -40,6 +45,9 @@ namespace KeyKeeper.Views
|
||||
Key = compositeKey,
|
||||
LockTimeoutSeconds = 800
|
||||
});
|
||||
|
||||
recentFilesService.Remember(path);
|
||||
|
||||
IPassStore passStore = passStoreAccessor;
|
||||
OpenRepositoryWindow(passStore);
|
||||
}
|
||||
@@ -69,11 +77,20 @@ namespace KeyKeeper.Views
|
||||
var file = files[0];
|
||||
if (file.TryGetLocalPath() is string path)
|
||||
{
|
||||
recentFilesService.Remember(path);
|
||||
OpenRepositoryWindow(new PassStoreFileAccessor(path, false, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RecentVaultsListItem_DoubleTapped(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Control c && c.DataContext is RecentFile recentFile)
|
||||
{
|
||||
OpenRepositoryWindow(new PassStoreFileAccessor(recentFile.Path, false, null));
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenRepositoryWindow(IPassStore passStore)
|
||||
{
|
||||
var repositoryWindow = new RepositoryWindow(new RepositoryWindowViewModel(passStore))
|
||||
|
||||
Reference in New Issue
Block a user