Improved keyboad shortcuts.
This commit is contained in:
@@ -12,6 +12,11 @@ public class KeyboardShortcut
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The application mode this shortcut applies to.
|
||||
/// </summary>
|
||||
public WinoApplicationMode Mode { get; set; } = WinoApplicationMode.Mail;
|
||||
|
||||
/// <summary>
|
||||
/// The key combination string (e.g., "D", "Delete", "F1").
|
||||
/// </summary>
|
||||
@@ -23,9 +28,9 @@ public class KeyboardShortcut
|
||||
public ModifierKeys ModifierKeys { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mail operation this shortcut triggers.
|
||||
/// The shortcut action this shortcut triggers.
|
||||
/// </summary>
|
||||
public MailOperation MailOperation { get; set; }
|
||||
public KeyboardShortcutAction Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this shortcut is enabled.
|
||||
@@ -55,6 +60,6 @@ public class KeyboardShortcut
|
||||
modifierText += "Win+";
|
||||
|
||||
return modifierText + Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Wino.Core.Domain.Enums;
|
||||
|
||||
public enum KeyboardShortcutAction
|
||||
{
|
||||
None,
|
||||
NewMail,
|
||||
ToggleReadUnread,
|
||||
ToggleFlag,
|
||||
ToggleArchive,
|
||||
Delete,
|
||||
Move,
|
||||
Reply,
|
||||
ReplyAll,
|
||||
Send,
|
||||
NewEvent
|
||||
}
|
||||
@@ -37,21 +37,23 @@ public interface IKeyboardShortcutService
|
||||
Task DeleteKeyboardShortcutAsync(Guid shortcutId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mail operation for the given key combination.
|
||||
/// Gets the keyboard shortcut for the given key combination in a specific mode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The application mode to search within.</param>
|
||||
/// <param name="key">The pressed key.</param>
|
||||
/// <param name="modifierKeys">The modifier keys pressed.</param>
|
||||
/// <returns>The mail operation if found, otherwise null.</returns>
|
||||
Task<MailOperation?> GetMailOperationForKeyAsync(string key, ModifierKeys modifierKeys);
|
||||
/// <returns>The matching shortcut if found, otherwise null.</returns>
|
||||
Task<KeyboardShortcut> GetShortcutForKeyAsync(WinoApplicationMode mode, string key, ModifierKeys modifierKeys);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a key combination is already assigned to another shortcut.
|
||||
/// </summary>
|
||||
/// <param name="mode">The application mode to check within.</param>
|
||||
/// <param name="key">The key to check.</param>
|
||||
/// <param name="modifierKeys">The modifier keys to check.</param>
|
||||
/// <param name="excludeShortcutId">Optional ID to exclude from the check (for updates).</param>
|
||||
/// <returns>True if the combination is already used, false otherwise.</returns>
|
||||
Task<bool> IsKeyCombinationInUseAsync(string key, ModifierKeys modifierKeys, Guid? excludeShortcutId = null);
|
||||
Task<bool> IsKeyCombinationInUseAsync(WinoApplicationMode mode, string key, ModifierKeys modifierKeys, Guid? excludeShortcutId = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates default keyboard shortcuts for common mail operations.
|
||||
@@ -62,4 +64,4 @@ public interface IKeyboardShortcutService
|
||||
/// Resets all shortcuts to defaults.
|
||||
/// </summary>
|
||||
Task ResetToDefaultShortcutsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ public class KeyboardShortcutDialogResult
|
||||
/// </summary>
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The application mode selected by the user.
|
||||
/// </summary>
|
||||
public WinoApplicationMode Mode { get; set; } = WinoApplicationMode.Mail;
|
||||
|
||||
/// <summary>
|
||||
/// The key combination entered by the user.
|
||||
/// </summary>
|
||||
@@ -23,21 +28,22 @@ public class KeyboardShortcutDialogResult
|
||||
public ModifierKeys ModifierKeys { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mail operation selected by the user.
|
||||
/// The shortcut action selected by the user.
|
||||
/// </summary>
|
||||
public MailOperation MailOperation { get; set; }
|
||||
public KeyboardShortcutAction Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a successful result.
|
||||
/// </summary>
|
||||
public static KeyboardShortcutDialogResult Success(string key, ModifierKeys modifierKeys, MailOperation mailOperation)
|
||||
public static KeyboardShortcutDialogResult Success(WinoApplicationMode mode, string key, ModifierKeys modifierKeys, KeyboardShortcutAction action)
|
||||
{
|
||||
return new KeyboardShortcutDialogResult
|
||||
{
|
||||
IsSuccess = true,
|
||||
Mode = mode,
|
||||
Key = key,
|
||||
ModifierKeys = modifierKeys,
|
||||
MailOperation = mailOperation
|
||||
Action = action
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,4 +57,4 @@ public class KeyboardShortcutDialogResult
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
namespace Wino.Core.Domain.Models;
|
||||
|
||||
public class KeyboardShortcutTriggerDetails
|
||||
{
|
||||
public Guid ShortcutId { get; init; }
|
||||
public WinoApplicationMode Mode { get; init; }
|
||||
public KeyboardShortcutAction Action { get; init; }
|
||||
public string Key { get; init; } = string.Empty;
|
||||
public ModifierKeys ModifierKeys { get; init; }
|
||||
public bool Handled { get; set; }
|
||||
public object Sender { get; init; }
|
||||
public object Origin { get; init; }
|
||||
}
|
||||
@@ -362,19 +362,29 @@
|
||||
"KeyboardShortcuts_FailedToReset": "Failed to reset keyboard shortcuts.",
|
||||
"KeyboardShortcuts_FailedToUpdate": "Failed to update keyboard shortcuts",
|
||||
"KeyboardShortcuts_MailoperationAction": "Action",
|
||||
"KeyboardShortcuts_Action": "Action",
|
||||
"KeyboardShortcuts_FailedToLoad": "Failed to load keyboard shortcuts.",
|
||||
"KeyboardShortcuts_EnterKeyForShortcut": "Please enter a key for the shortcut.",
|
||||
"KeyboardShortcuts_SelectOperationForShortcut": "Please an action to perform for the shortcut.",
|
||||
"KeyboardShortcuts_EnterKey": "Please enter a key for the shortcut.",
|
||||
"KeyboardShortcuts_SelectOperation": "Please select an action for the shortcut.",
|
||||
"KeyboardShortcuts_ShortcutInUse": "This shortcut is already in use by another s hortcut.",
|
||||
"KeyboardShortcuts_FailedToSave": "Failed to save the shortcut.",
|
||||
"KeyboardShortcuts_FailedToDelete": "Failed to delete the shortcut.",
|
||||
"KeyboardShortcuts_PageDescription": "Set up keyboard shortcuts for quick mail operations. Press keys while focused on the key input field to capture shortcuts.",
|
||||
"KeyboardShortcuts_Add": "Add shortcut",
|
||||
"KeyboardShortcuts_EditTitle": "Edit Keyboard Shortcut",
|
||||
"KeyboardShortcuts_ResetToDefaults": "Reset to Defaults",
|
||||
"KeyboardShortcuts_PressKeysHere": "Press keys here...",
|
||||
"KeyboardShortcuts_KeyCombination": "Key Combination",
|
||||
"KeyboardShortcuts_FocusArea": "Focus the field above and press the desired key combination",
|
||||
"KeyboardShortcuts_Modifiers": "Modifier Keys",
|
||||
"KeyboardShortcuts_Mode": "App Mode",
|
||||
"KeyboardShortcuts_ModeMail": "Mail",
|
||||
"KeyboardShortcuts_ModeCalendar": "Calendar",
|
||||
"KeyboardShortcuts_ActionToggleReadUnread": "Toggle read/unread",
|
||||
"KeyboardShortcuts_ActionToggleFlag": "Toggle flag",
|
||||
"KeyboardShortcuts_ActionToggleArchive": "Toggle archive/unarchive",
|
||||
"ImageRenderingDisabled": "Image rendering is disabled for this message.",
|
||||
"ImapAdvancedSetupDialog_AuthenticationMethod": "Authentication method",
|
||||
"ImapAdvancedSetupDialog_ConnectionSecurity": "Connection security",
|
||||
|
||||
Reference in New Issue
Block a user