diff --git a/App/UI/MainWindow/MainWindow.cs b/App/UI/MainWindow/MainWindow.cs index fece2e9..664728b 100644 --- a/App/UI/MainWindow/MainWindow.cs +++ b/App/UI/MainWindow/MainWindow.cs @@ -92,7 +92,7 @@ public class MainWindow shortcuts.Add(newShortcut); // This will automatically update the UI } - private void RemoveShortcut(PasswordStoreShortcut shortcut) + private void RemoveShortcut(PasswordStoreViewModel shortcut) { shortcuts.Remove(shortcut); // This will automatically update the UI } @@ -102,7 +102,7 @@ public class MainWindow shortcuts.Add(new PasswordStoreShortcut(displayName: "Default", path: Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.password_store")); } - private void UpdateShortcutName(PasswordStoreShortcut shortcut, string newName) + private void UpdateShortcutName(PasswordStoreViewModel shortcut, string newName) { shortcut.DisplayName = newName; // This will automatically update the UI row } diff --git a/App/ViewModels/PasswordStoreShortcut.cs b/App/ViewModels/PasswordStoreShortcut.cs deleted file mode 100644 index 6437ae0..0000000 --- a/App/ViewModels/PasswordStoreShortcut.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.ComponentModel; -using Logic; - -namespace Keychain.ViewModels; - -public class PasswordStoreShortcut : INotifyPropertyChanged -{ - private IPasswordStoreService passwordService; - public event PropertyChangedEventHandler? PropertyChanged; - - public string DisplayName - { - get => displayName; - set - { - displayName = value; - displayNameSet = true; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DisplayName))); - } - } - - public string? IconName - { - get => iconName; - set { iconName = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IconName))); } - } - - public string Path - { - get => path; - } - - public PasswordStoreShortcut(string path, string iconName = "text-x-generic-symbolic", string? displayName = null) - { - this.path = path; - - this.iconName = iconName; - - this.displayName = path; - - if (displayName != null) - { - DisplayName = displayName; - } - } -} diff --git a/App/ViewModels/PasswordStoreShortcutCollection.cs b/App/ViewModels/PasswordStoreShortcutCollection.cs index ba79899..d81d041 100644 --- a/App/ViewModels/PasswordStoreShortcutCollection.cs +++ b/App/ViewModels/PasswordStoreShortcutCollection.cs @@ -5,10 +5,10 @@ using Gtk; using System.Collections.ObjectModel; using System.Collections.Specialized; -public class PasswordStoreShortcutCollection : ObservableCollection +public class PasswordStoreShortcutCollection : ObservableCollection { private readonly PreferencesGroup shortcutsGroup; - private readonly Dictionary itemToRowMap = new(); + private readonly Dictionary itemToRowMap = new(); public PasswordStoreShortcutCollection(PreferencesGroup shortcutsGroup) { @@ -21,7 +21,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection _model.DisplayName; + } + + public string? IconName + { + get => _model.IconName; + } + + public string Path + { + get => _model.Path; + } + + public PasswordStoreViewModel(PasswordStore item) + { + _model = item; + } +}