mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Changed tooltip styles
Removed useless isdirty field in entry When an app can't be saved on suspend, don't reopen it to avoid possible de-sync
This commit is contained in:
@@ -17,6 +17,8 @@ namespace ModernKeePass.Application.Database.Commands.CloseDatabase
|
|||||||
public void Handle(CloseDatabaseCommand message)
|
public void Handle(CloseDatabaseCommand message)
|
||||||
{
|
{
|
||||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||||
|
// Prevent reopening the database due to possible de-synchronization between app and data
|
||||||
|
if (_database.IsDirty) _database.FileAccessToken = null;
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,8 @@ namespace ModernKeePass
|
|||||||
/// Provides application-specific behavior to supplement the default Application class.
|
/// Provides application-specific behavior to supplement the default Application class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
sealed partial class App
|
sealed partial class App
|
||||||
{
|
{ public static IServiceProvider Services { get; private set; }
|
||||||
|
|
||||||
private readonly IResourceProxy _resource;
|
private readonly IResourceProxy _resource;
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
private readonly ISettingsProxy _settings;
|
private readonly ISettingsProxy _settings;
|
||||||
@@ -41,9 +42,7 @@ namespace ModernKeePass
|
|||||||
private readonly INotificationService _notification;
|
private readonly INotificationService _notification;
|
||||||
private readonly IFileProxy _file;
|
private readonly IFileProxy _file;
|
||||||
private readonly IMessenger _messenger;
|
private readonly IMessenger _messenger;
|
||||||
|
|
||||||
public static IServiceProvider Services { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the singleton application object. This is the first line of authored code
|
/// Initializes the singleton application object. This is the first line of authored code
|
||||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||||
@@ -206,7 +205,7 @@ namespace ModernKeePass
|
|||||||
}
|
}
|
||||||
catch (SaveException ex)
|
catch (SaveException ex)
|
||||||
{
|
{
|
||||||
_notification.Show(_resource.GetResourceValue("MessageDialogSaveErrorTitle"), ex.Message);
|
_notification.Show(ex.Source, ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@@ -47,7 +47,6 @@
|
|||||||
<SolidColorBrush x:Key="HyperlinkForegroundThemeBrush" Color="{ThemeResource MainColor}" />
|
<SolidColorBrush x:Key="HyperlinkForegroundThemeBrush" Color="{ThemeResource MainColor}" />
|
||||||
<SolidColorBrush x:Key="HyperlinkPointerOverForegroundThemeBrush" Color="{ThemeResource MainColorLight}" />
|
<SolidColorBrush x:Key="HyperlinkPointerOverForegroundThemeBrush" Color="{ThemeResource MainColorLight}" />
|
||||||
|
|
||||||
<!--<SolidColorBrush x:Key="SearchBoxPointerOverBorderThemeBrush" Color="{ThemeResource MainColorLight}" />-->
|
|
||||||
<SolidColorBrush x:Key="SearchBoxPointerOverTextThemeBrush" Color="{ThemeResource MainColorLight}" />
|
<SolidColorBrush x:Key="SearchBoxPointerOverTextThemeBrush" Color="{ThemeResource MainColorLight}" />
|
||||||
<SolidColorBrush x:Key="SearchBoxBorderThemeBrush" Color="{ThemeResource BorderColor}" />
|
<SolidColorBrush x:Key="SearchBoxBorderThemeBrush" Color="{ThemeResource BorderColor}" />
|
||||||
<SolidColorBrush x:Key="SearchBoxFocusedBorderThemeBrush" Color="{ThemeResource MainColor}" />
|
<SolidColorBrush x:Key="SearchBoxFocusedBorderThemeBrush" Color="{ThemeResource MainColor}" />
|
||||||
|
@@ -44,14 +44,46 @@ namespace ModernKeePass.ViewModels
|
|||||||
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
|
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
|
||||||
public bool HasExpired => HasExpirationDate && ExpiryDate < DateTime.Now;
|
public bool HasExpired => HasExpirationDate && ExpiryDate < DateTime.Now;
|
||||||
public double PasswordComplexityIndicator => _mediator.Send(new EstimatePasswordComplexityQuery {Password = Password}).GetAwaiter().GetResult();
|
public double PasswordComplexityIndicator => _mediator.Send(new EstimatePasswordComplexityQuery {Password = Password}).GetAwaiter().GetResult();
|
||||||
public bool UpperCasePatternSelected { get; set; } = true;
|
public bool UpperCasePatternSelected
|
||||||
public bool LowerCasePatternSelected { get; set; } = true;
|
{
|
||||||
public bool DigitsPatternSelected { get; set; } = true;
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.UpperCasePattern, true); }
|
||||||
public bool MinusPatternSelected { get; set; }
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.UpperCasePattern, value); }
|
||||||
public bool UnderscorePatternSelected { get; set; }
|
}
|
||||||
public bool SpacePatternSelected { get; set; }
|
public bool LowerCasePatternSelected
|
||||||
public bool SpecialPatternSelected { get; set; }
|
{
|
||||||
public bool BracketsPatternSelected { get; set; }
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.LowerCasePattern, true); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.LowerCasePattern, value); }
|
||||||
|
}
|
||||||
|
public bool DigitsPatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.DigitsPattern, true); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.DigitsPattern, value); }
|
||||||
|
}
|
||||||
|
public bool MinusPatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.MinusPattern, false); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.MinusPattern, value); }
|
||||||
|
}
|
||||||
|
public bool UnderscorePatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.UnderscorePattern, false); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.UnderscorePattern, value); }
|
||||||
|
}
|
||||||
|
public bool SpacePatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.SpacePattern, false); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.SpacePattern, value); }
|
||||||
|
}
|
||||||
|
public bool SpecialPatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.SpecialPattern, true); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.SpecialPattern, value); }
|
||||||
|
}
|
||||||
|
public bool BracketsPatternSelected
|
||||||
|
{
|
||||||
|
get { return _settings.GetSetting(Constants.Settings.PasswordGenerationOptions.BracketsPattern, false); }
|
||||||
|
set { _settings.PutSetting(Constants.Settings.PasswordGenerationOptions.BracketsPattern, value); }
|
||||||
|
}
|
||||||
public string CustomChars { get; set; } = string.Empty;
|
public string CustomChars { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Id => SelectedItem.Id;
|
public string Id => SelectedItem.Id;
|
||||||
@@ -95,7 +127,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
Attachments.CollectionChanged += (sender, args) =>
|
Attachments.CollectionChanged += (sender, args) =>
|
||||||
{
|
{
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = true;
|
|
||||||
};
|
};
|
||||||
RaisePropertyChanged(string.Empty);
|
RaisePropertyChanged(string.Empty);
|
||||||
}
|
}
|
||||||
@@ -282,6 +313,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
private readonly IDialogService _dialog;
|
private readonly IDialogService _dialog;
|
||||||
private readonly INotificationService _notification;
|
private readonly INotificationService _notification;
|
||||||
private readonly IFileProxy _file;
|
private readonly IFileProxy _file;
|
||||||
|
private readonly ISettingsProxy _settings;
|
||||||
private GroupVm _parent;
|
private GroupVm _parent;
|
||||||
private EntryVm _selectedItem;
|
private EntryVm _selectedItem;
|
||||||
private int _selectedIndex;
|
private int _selectedIndex;
|
||||||
@@ -289,9 +321,8 @@ namespace ModernKeePass.ViewModels
|
|||||||
private bool _isEditMode;
|
private bool _isEditMode;
|
||||||
private bool _isRevealPassword;
|
private bool _isRevealPassword;
|
||||||
private double _passwordLength = 25;
|
private double _passwordLength = 25;
|
||||||
private bool _isDirty;
|
|
||||||
|
|
||||||
public EntryDetailVm(IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification, IFileProxy file)
|
public EntryDetailVm(IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification, IFileProxy file, ISettingsProxy settings)
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
@@ -299,6 +330,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
_dialog = dialog;
|
_dialog = dialog;
|
||||||
_notification = notification;
|
_notification = notification;
|
||||||
_file = file;
|
_file = file;
|
||||||
|
_settings = settings;
|
||||||
|
|
||||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||||
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
||||||
@@ -351,7 +383,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public async Task AddHistory()
|
public async Task AddHistory()
|
||||||
{
|
{
|
||||||
if (_isDirty) await _mediator.Send(new AddHistoryCommand { Entry = History[0] });
|
if (Database.IsDirty) await _mediator.Send(new AddHistoryCommand { Entry = History[0] });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToGroup(string groupId)
|
public void GoToGroup(string groupId)
|
||||||
@@ -370,7 +402,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
await _mediator.Send(new UpsertFieldCommand { EntryId = Id, FieldName = fieldName, FieldValue = value, IsProtected = isProtected});
|
await _mediator.Send(new UpsertFieldCommand { EntryId = Id, FieldName = fieldName, FieldValue = value, IsProtected = isProtected});
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateFieldName(string oldName, string newName, string value, bool isProtected)
|
private async Task UpdateFieldName(string oldName, string newName, string value, bool isProtected)
|
||||||
@@ -392,7 +423,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
await _mediator.Send(new DeleteFieldCommand {EntryId = Id, FieldName = field.Name});
|
await _mediator.Send(new DeleteFieldCommand {EntryId = Id, FieldName = field.Name});
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,7 +480,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
MessengerInstance.Send(new SaveErrorMessage { Message = e.Message });
|
MessengerInstance.Send(new SaveErrorMessage { Message = e.Message });
|
||||||
}
|
}
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Delete()
|
private async Task Delete()
|
||||||
@@ -483,7 +512,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
await _mediator.Send(new AddAttachmentCommand { Entry = SelectedItem, AttachmentName = fileInfo.Name, AttachmentContent = contents });
|
await _mediator.Send(new AddAttachmentCommand { Entry = SelectedItem, AttachmentName = fileInfo.Name, AttachmentContent = contents });
|
||||||
Attachments.Add(new Attachment { Name = fileInfo.Name, Content = contents });
|
Attachments.Add(new Attachment { Name = fileInfo.Name, Content = contents });
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteAttachment(Attachment attachment)
|
private async Task DeleteAttachment(Attachment attachment)
|
||||||
@@ -491,7 +519,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
await _mediator.Send(new DeleteAttachmentCommand { Entry = SelectedItem, AttachmentName = attachment.Name });
|
await _mediator.Send(new DeleteAttachmentCommand { Entry = SelectedItem, AttachmentName = attachment.Name });
|
||||||
Attachments.Remove(attachment);
|
Attachments.Remove(attachment);
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
_isDirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
||||||
|
|
||||||
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut => from e in Entries
|
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut => from e in Entries
|
||||||
group e by e.Title.Name.ToUpper().FirstOrDefault() into grp
|
group e by (e.Title.Value ?? string.Empty).ToUpper().FirstOrDefault() into grp
|
||||||
orderby grp.Key
|
orderby grp.Key
|
||||||
select grp;
|
select grp;
|
||||||
|
|
||||||
|
@@ -21,6 +21,18 @@
|
|||||||
public static string DefaultFileFormat => nameof(DefaultFileFormat);
|
public static string DefaultFileFormat => nameof(DefaultFileFormat);
|
||||||
public static string ClipboardTimeout => nameof(ClipboardTimeout);
|
public static string ClipboardTimeout => nameof(ClipboardTimeout);
|
||||||
public static string HistoryMaxCount => nameof(HistoryMaxCount);
|
public static string HistoryMaxCount => nameof(HistoryMaxCount);
|
||||||
|
|
||||||
|
public static class PasswordGenerationOptions
|
||||||
|
{
|
||||||
|
public static string UpperCasePattern => nameof(UpperCasePattern);
|
||||||
|
public static string LowerCasePattern => nameof(LowerCasePattern);
|
||||||
|
public static string DigitsPattern => nameof(DigitsPattern);
|
||||||
|
public static string MinusPattern => nameof(MinusPattern);
|
||||||
|
public static string UnderscorePattern => nameof(UnderscorePattern);
|
||||||
|
public static string SpacePattern => nameof(SpacePattern);
|
||||||
|
public static string SpecialPattern => nameof(SpecialPattern);
|
||||||
|
public static string BracketsPattern => nameof(BracketsPattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user