refactor(ui): remove redundant "Open wallet from file" menu item
The wizard already covers opening existing wallets; a separate file-picker entry in the menu duplicates that flow without adding value. Remove the menu item, its click handler, the OpenFromPath VM method, and the loc key.
This commit is contained in:
@@ -45,7 +45,6 @@ public sealed class Loc
|
|||||||
// Menu it en es fr pt de
|
// Menu it en es fr pt de
|
||||||
["menu.file"] = ["_File", "_File", "_Archivo", "_Fichier", "_Arquivo", "_Datei"],
|
["menu.file"] = ["_File", "_File", "_Archivo", "_Fichier", "_Arquivo", "_Datei"],
|
||||||
["menu.file.new"] = ["Nuovo / ripristina wallet…", "New / restore wallet…", "Nuevo / restaurar wallet…", "Nouveau / restaurer le wallet…", "Novo / restaurar carteira…", "Neu / Wallet wiederherstellen…"],
|
["menu.file.new"] = ["Nuovo / ripristina wallet…", "New / restore wallet…", "Nuevo / restaurar wallet…", "Nouveau / restaurer le wallet…", "Novo / restaurar carteira…", "Neu / Wallet wiederherstellen…"],
|
||||||
["menu.file.open"] = ["Apri wallet da file…", "Open wallet from file…", "Abrir wallet desde archivo…", "Ouvrir le wallet depuis un fichier…", "Abrir carteira de arquivo…", "Wallet aus Datei öffnen…"],
|
|
||||||
["menu.file.close"] = ["Chiudi wallet", "Close wallet", "Cerrar wallet", "Fermer le wallet", "Fechar carteira", "Wallet schließen"],
|
["menu.file.close"] = ["Chiudi wallet", "Close wallet", "Cerrar wallet", "Fermer le wallet", "Fechar carteira", "Wallet schließen"],
|
||||||
["menu.file.quit"] = ["Esci", "Quit", "Salir", "Quitter", "Sair", "Beenden"],
|
["menu.file.quit"] = ["Esci", "Quit", "Salir", "Quitter", "Sair", "Beenden"],
|
||||||
["menu.net"] = ["_Rete", "_Network", "_Red", "_Réseau", "_Rede", "_Netzwerk"],
|
["menu.net"] = ["_Rete", "_Network", "_Red", "_Réseau", "_Rede", "_Netzwerk"],
|
||||||
|
|||||||
@@ -477,41 +477,6 @@ public partial class MainWindowViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenFromPath(string path)
|
|
||||||
{
|
|
||||||
var newLock = WalletLock.TryAcquire(path);
|
|
||||||
if (newLock is null) { StatusMessage = Loc.Tr("msg.wallet.locked"); return; }
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var doc = WalletStore.Load(path);
|
|
||||||
if (IsWalletOpen)
|
|
||||||
CloseWallet();
|
|
||||||
OpenLoaded(doc, WalletLoader.ToAccount(doc), path, password: null, newLock);
|
|
||||||
}
|
|
||||||
catch (WrongPasswordException)
|
|
||||||
{
|
|
||||||
newLock.Dispose();
|
|
||||||
if (IsWalletOpen)
|
|
||||||
CloseWallet();
|
|
||||||
_pendingOpenPath = path;
|
|
||||||
WalletFileExists = true;
|
|
||||||
PasswordInput = "";
|
|
||||||
SetupStep = StepOpen;
|
|
||||||
StatusMessage = "";
|
|
||||||
}
|
|
||||||
catch (UnauthorizedAccessException)
|
|
||||||
{
|
|
||||||
newLock.Dispose();
|
|
||||||
StatusMessage = Loc.Tr("msg.wallet.noaccess");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
newLock.Dispose();
|
|
||||||
StatusMessage = $"Errore: {ex.Message}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void NewWallet()
|
private void NewWallet()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,8 +31,6 @@
|
|||||||
<Menu Grid.Row="0" IsVisible="{Binding IsDesktop}">
|
<Menu Grid.Row="0" IsVisible="{Binding IsDesktop}">
|
||||||
<MenuItem Header="{Binding Loc[menu.file]}">
|
<MenuItem Header="{Binding Loc[menu.file]}">
|
||||||
<MenuItem Header="{Binding Loc[menu.file.new]}" Command="{Binding NewWalletCommand}"/>
|
<MenuItem Header="{Binding Loc[menu.file.new]}" Command="{Binding NewWalletCommand}"/>
|
||||||
<MenuItem Header="{Binding Loc[menu.file.open]}" Click="OnOpenWalletFileClick"
|
|
||||||
IsVisible="{Binding IsDesktop}"/>
|
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem Header="{Binding Loc[menu.file.close]}" Command="{Binding CloseWalletCommand}"
|
<MenuItem Header="{Binding Loc[menu.file.close]}" Command="{Binding CloseWalletCommand}"
|
||||||
IsEnabled="{Binding IsWalletOpen}"/>
|
IsEnabled="{Binding IsWalletOpen}"/>
|
||||||
|
|||||||
@@ -23,25 +23,6 @@ public partial class MainView : UserControl
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnOpenWalletFileClick(object? sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (DataContext is not MainWindowViewModel vm) return;
|
|
||||||
if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storage) return;
|
|
||||||
|
|
||||||
var files = await storage.OpenFilePickerAsync(new FilePickerOpenOptions
|
|
||||||
{
|
|
||||||
Title = "Apri file wallet",
|
|
||||||
AllowMultiple = false,
|
|
||||||
FileTypeFilter =
|
|
||||||
[
|
|
||||||
new FilePickerFileType("Wallet Palladium") { Patterns = ["*.wallet.json", "*.json"] },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (files.FirstOrDefault()?.TryGetLocalPath() is { } path)
|
|
||||||
vm.OpenFromPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnHistoryRowDoubleTapped(object? sender, TappedEventArgs e)
|
private void OnHistoryRowDoubleTapped(object? sender, TappedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is not ListBox lb || DataContext is not MainWindowViewModel vm) return;
|
if (sender is not ListBox lb || DataContext is not MainWindowViewModel vm) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user