mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Auto create new recycle bin if needed
Entries now also make use of the recycle bin New path indication below groups and entries title Password generator now has custom characters back (working thanks to lib 2.37)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -31,8 +32,13 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _app.Database.RecycleBinEnabled && _app.Database.RecycleBin.Id == Id; }
|
||||
set
|
||||
{
|
||||
// TODO: if _pwGroup is null, create a new group
|
||||
if (value && _pwGroup != null) _app.Database.RecycleBin = this;
|
||||
else if (value && _pwGroup == null)
|
||||
{
|
||||
var recycleBin = _app.Database.RootGroup.AddNewGroup("Recycle bin");
|
||||
recycleBin.IsSelected = true;
|
||||
recycleBin.IconSymbol = Symbol.Delete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +62,7 @@ namespace ModernKeePass.ViewModels
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwGroup.IconId);
|
||||
return result == Symbol.More ? Symbol.Folder : result;
|
||||
}
|
||||
set { _pwGroup.IconId = PwIconToSegoeMapping.GetIconFromSymbol(value); }
|
||||
}
|
||||
|
||||
public bool IsEditMode
|
||||
@@ -64,6 +71,17 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetProperty(ref _isEditMode, value); }
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ParentGroup == null) return string.Empty;
|
||||
var path = new StringBuilder(ParentGroup.Path);
|
||||
path.Append($" > {ParentGroup.Name}");
|
||||
return path.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly PwGroup _pwGroup;
|
||||
private readonly App _app = (App)Application.Current;
|
||||
private bool _isEditMode;
|
||||
@@ -82,16 +100,16 @@ namespace ModernKeePass.ViewModels
|
||||
Groups.Insert(0, new GroupVm ());
|
||||
}
|
||||
|
||||
public GroupVm CreateNewGroup()
|
||||
public GroupVm AddNewGroup(string name = "")
|
||||
{
|
||||
var pwGroup = new PwGroup(true, true, string.Empty, PwIcon.Folder);
|
||||
var pwGroup = new PwGroup(true, true, name, PwIcon.Folder);
|
||||
_pwGroup.AddGroup(pwGroup, true);
|
||||
var newGroup = new GroupVm(pwGroup, this) {IsEditMode = true};
|
||||
var newGroup = new GroupVm(pwGroup, this) {Name = name, IsEditMode = string.IsNullOrEmpty(name)};
|
||||
Groups.Add(newGroup);
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
public EntryVm CreateNewEntry()
|
||||
public EntryVm AddNewEntry()
|
||||
{
|
||||
var pwEntry = new PwEntry(true, true);
|
||||
_pwGroup.AddEntry(pwEntry, true);
|
||||
@@ -99,6 +117,11 @@ namespace ModernKeePass.ViewModels
|
||||
Entries.Add(newEntry);
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
public void AddPwEntry(PwEntry entry)
|
||||
{
|
||||
_pwGroup.AddEntry(entry, true);
|
||||
}
|
||||
|
||||
public void MarkForDelete()
|
||||
{
|
||||
@@ -111,6 +134,7 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
_pwGroup.ParentGroup.Groups.Remove(_pwGroup);
|
||||
if (_app.Database.RecycleBinEnabled && !IsSelected) _app.Database.RecycleBin._pwGroup.AddGroup(_pwGroup, true);
|
||||
else _app.Database.AddDeletedItem(IdUuid);
|
||||
}
|
||||
|
||||
public void UndoDelete()
|
||||
|
Reference in New Issue
Block a user