Skip to content

Commit

Permalink
Support mode="lock" on appsettings KeyboardShortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Feb 2, 2025
1 parent dfea4bd commit 585f44d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAPS2.Lib/Config/ConfigSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void SetIfLocked<T>(Expression<Func<CommonConfig, T>> accessor, T value, string
SetIfLocked(x => x.DeleteAfterSaving, c.DeleteAfterSaving, nameof(c.DeleteAfterSaving));
SetIfLocked(x => x.KeepSession, c.KeepSession, nameof(c.KeepSession));
SetIfLocked(x => x.SingleInstance, c.SingleInstance, nameof(c.SingleInstance));
SetIfLocked(x => x.KeyboardShortcuts, MapKeyboardShortcuts(c.KeyboardShortcuts ?? new KeyboardShortcuts()), nameof(c.KeyboardShortcuts));

return storage;
}
Expand Down
8 changes: 3 additions & 5 deletions NAPS2.Lib/EtoForms/Ui/KeyboardShortcutsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ public class KeyboardShortcutsForm : EtoDialogBase
new(UiStrings.Ocr, c => c.KeyboardShortcuts.Ocr),
new(UiStrings.Import, c => c.KeyboardShortcuts.Import),
Shortcut.Separator,
new(UiStrings.SavePdf, c => c.KeyboardShortcuts.SavePDF),
new(UiStrings.SaveAllAsPdf, c => c.KeyboardShortcuts.SavePDFAll),
new(UiStrings.SaveSelectedAsPdf, c => c.KeyboardShortcuts.SavePDFSelected),
new(UiStrings.PdfSettings, c => c.KeyboardShortcuts.PDFSettings),
Shortcut.Separator,
new(UiStrings.SaveImages, c => c.KeyboardShortcuts.SaveImages),
new(UiStrings.SaveAllAsImages, c => c.KeyboardShortcuts.SaveImagesAll),
new(UiStrings.SaveSelectedAsImages, c => c.KeyboardShortcuts.SaveImagesSelected),
new(UiStrings.ImageSettings, c => c.KeyboardShortcuts.ImageSettings),
Shortcut.Separator,
new(UiStrings.EmailPdf, c => c.KeyboardShortcuts.EmailPDF),
new(UiStrings.EmailAllAsPdf, c => c.KeyboardShortcuts.EmailPDFAll),
new(UiStrings.EmailSelectedAsPdf, c => c.KeyboardShortcuts.EmailPDFSelected),
new(UiStrings.EmailSettings, c => c.KeyboardShortcuts.EmailSettings),
Expand Down Expand Up @@ -199,10 +196,11 @@ private void UpdateUi()
}
else
{
bool locked = _transactionConfig.AppLocked.Has(selected.Accessor);
_shortcutText.Text = GetKeyString(selected);
_shortcutText.Enabled = false;
_assign.Enabled = true;
_unassign.Enabled = _shortcutText.Text != "";
_assign.Enabled = !locked;
_unassign.Enabled = !locked && _shortcutText.Text != "";
}
_listBox.Invalidate();
}
Expand Down
4 changes: 3 additions & 1 deletion NAPS2.Setup/appsettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<FlipDuplexedPages>false</FlipDuplexedPages>
<TwainImpl>Default</TwainImpl>
</DefaultProfileSettings>
<KeyboardShortcuts>
<KeyboardShortcuts mode="default">
<ScanDefault>Ctrl+Enter</ScanDefault>
<ScanProfile1>F2</ScanProfile1>
<ScanProfile2>F3</ScanProfile2>
Expand Down Expand Up @@ -127,6 +127,7 @@
<RotateLeft>Ctrl+Shift+Left</RotateLeft>
<RotateRight>Ctrl+Shift+Right</RotateRight>
<RotateFlip>Ctrl+Shift+Down</RotateFlip>
<RotateDeskew></RotateDeskew>
<RotateCustom></RotateCustom>
<MoveUp>Ctrl+Up</MoveUp>
<MoveDown>Ctrl+Down</MoveDown>
Expand All @@ -138,6 +139,7 @@
<ReorderReverseSelected></ReorderReverseSelected>
<Delete></Delete>
<Clear>Ctrl+Shift+Del</Clear>
<Settings></Settings>
<About>F1</About>
<ZoomIn>Ctrl+Oemplus</ZoomIn>
<ZoomOut>Ctrl+OemMinus</ZoomOut>
Expand Down

0 comments on commit 585f44d

Please sign in to comment.