From d8337750e14a095263a0fe29106b39437f75a45b Mon Sep 17 00:00:00 2001 From: Steve Wilson Date: Sun, 31 Aug 2025 21:01:40 +0100 Subject: [PATCH 1/2] Add settting checkbox "Prompt Before Delete Page?" --- NAPS2.Lib/Config/CommonConfig.cs | 3 +++ NAPS2.Lib/Config/InternalDefaults.cs | 3 ++- NAPS2.Lib/EtoForms/Desktop/DesktopController.cs | 13 +++++++++---- NAPS2.Lib/EtoForms/Ui/SettingsForm.cs | 6 +++++- NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs | 12 +++++++++++- NAPS2.Lib/Lang/Resources/UiStrings.resx | 3 +++ NAPS2.Lib/NAPS2.Lib.csproj | 12 ++++++++++++ 7 files changed, 45 insertions(+), 7 deletions(-) diff --git a/NAPS2.Lib/Config/CommonConfig.cs b/NAPS2.Lib/Config/CommonConfig.cs index 5e719d33cd..77f2db4476 100644 --- a/NAPS2.Lib/Config/CommonConfig.cs +++ b/NAPS2.Lib/Config/CommonConfig.cs @@ -110,6 +110,9 @@ public class CommonConfig [Common] public bool DeleteAfterSaving { get; set; } + + [Common] + public bool PromptBeforeDeletePage { get; set; } [Common] public bool KeepSession { get; set; } diff --git a/NAPS2.Lib/Config/InternalDefaults.cs b/NAPS2.Lib/Config/InternalDefaults.cs index 354eac1b76..93e397d35b 100644 --- a/NAPS2.Lib/Config/InternalDefaults.cs +++ b/NAPS2.Lib/Config/InternalDefaults.cs @@ -202,6 +202,7 @@ public static CommonConfig GetCommonConfig() => ZoomIn = "Mod+Oemplus", ZoomOut = "Mod+OemMinus" }, - DefaultProfileSettings = new ScanProfile { Version = ScanProfile.CURRENT_VERSION } + DefaultProfileSettings = new ScanProfile { Version = ScanProfile.CURRENT_VERSION }, + PromptBeforeDeletePage=true }; } \ No newline at end of file diff --git a/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs b/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs index 2048650d9e..9d6fe6c68b 100644 --- a/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs +++ b/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs @@ -425,10 +425,15 @@ public void Delete() { if (_imageList.Selection.Any()) { - if (MessageBox.Show(_desktopFormProvider.DesktopForm, - string.Format(MiscResources.ConfirmDeleteItems, _imageList.Selection.Count), - MiscResources.Delete, MessageBoxButtons.OKCancel, - MessageBoxType.Question, MessageBoxDefaultButton.OK) == DialogResult.Ok) + + + if (!_config.Get(c => c.PromptBeforeDeletePage) || + (MessageBox.Show(_desktopFormProvider.DesktopForm, + string.Format(MiscResources.ConfirmDeleteItems, _imageList.Selection.Count), + MiscResources.Delete, + MessageBoxButtons.OKCancel, + MessageBoxType.Question, + MessageBoxDefaultButton.OK) == DialogResult.Ok)) { _imageListActions.DeleteSelected(); GC.Collect(); diff --git a/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs index 74b530d227..9ede3398ae 100644 --- a/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs @@ -24,6 +24,7 @@ internal class SettingsForm : EtoDialogBase private readonly ActionCommand _emailSettingsCommand; private readonly ActionCommand _keyboardShortcutsCommand; private readonly Button _restoreDefaults = new() { Text = UiStrings.RestoreDefaults }; + private readonly CheckBox _promptBeforeDeletePage = C.CheckBox(UiStrings.PromptBeforeDeletePage); public SettingsForm(Naps2Config config, DesktopSubFormController desktopSubFormController, DesktopFormProvider desktopFormProvider, IIconProvider iconProvider) : base(config) @@ -99,7 +100,8 @@ protected override void BuildLayout() _keepSession, PlatformCompat.System.SupportsSingleInstance ? _singleInstance - : C.None() + : C.None(), + _promptBeforeDeletePage ) ), // TODO: Probably only show these after we start adding tabs @@ -138,6 +140,7 @@ void UpdateCheckbox(CheckBox checkBox, Expression> acce UpdateCheckbox(_clearAfterSaving, c => c.DeleteAfterSaving); UpdateCheckbox(_keepSession, c => c.KeepSession); UpdateCheckbox(_singleInstance, c => c.SingleInstance); + UpdateCheckbox(_promptBeforeDeletePage, c => c.PromptBeforeDeletePage); } private void Save() @@ -162,6 +165,7 @@ bool SetIfChanged(Expression> accessor, T value) SetIfChanged(c => c.DeleteAfterSaving, _clearAfterSaving.IsChecked()); SetIfChanged(c => c.KeepSession, _keepSession.IsChecked()); SetIfChanged(c => c.SingleInstance, _singleInstance.IsChecked()); + SetIfChanged(c => c.PromptBeforeDeletePage, _promptBeforeDeletePage.IsChecked()); transact.Commit(); _desktopFormProvider.DesktopForm.Invalidate(); diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs index 80cb3e39d0..4028c12137 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs +++ b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -18,7 +19,7 @@ namespace NAPS2.Lang.Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class UiStrings { @@ -1751,6 +1752,15 @@ internal static string ProfilesFormTitle { } } + /// + /// Looks up a localized string similar to Prompt before deleting a page. + /// + internal static string PromptBeforeDeletePage { + get { + return ResourceManager.GetString("PromptBeforeDeletePage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Prompt for file path. /// diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.resx b/NAPS2.Lib/Lang/Resources/UiStrings.resx index ee2f198c70..cd9260b768 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.resx @@ -993,4 +993,7 @@ Stop Scanner Sharing + + Prompt before deleting a page + \ No newline at end of file diff --git a/NAPS2.Lib/NAPS2.Lib.csproj b/NAPS2.Lib/NAPS2.Lib.csproj index 88eb1d3435..c46ab946cc 100644 --- a/NAPS2.Lib/NAPS2.Lib.csproj +++ b/NAPS2.Lib/NAPS2.Lib.csproj @@ -110,5 +110,17 @@ + + + True + True + UiStrings.resx + + + + + UiStrings.Designer.cs + + \ No newline at end of file From e3b0b44c8d7eaa2c474f83f3bc90ac57e7c35763 Mon Sep 17 00:00:00 2001 From: Steve Wilson Date: Sun, 31 Aug 2025 21:07:55 +0100 Subject: [PATCH 2/2] Fix Issue 613 - add setting to Prompt Before Delete Page --- NAPS2.Lib/Lang/Resources/UiStrings.fr.resx | 109 ++++++++++++++++++ NAPS2.Lib/Lang/Resources/UiStrings.he.resx | 108 +++++++++++++++++ NAPS2.Lib/Lang/Resources/UiStrings.pt-BR.resx | 108 +++++++++++++++++ 3 files changed, 325 insertions(+) diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.fr.resx b/NAPS2.Lib/Lang/Resources/UiStrings.fr.resx index 6acbe3e57d..20c9772056 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.fr.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.fr.resx @@ -1,5 +1,110 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -885,4 +990,8 @@ Arrêt du partage du scanner + + Demander avant de supprimer une page + + \ No newline at end of file diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.he.resx b/NAPS2.Lib/Lang/Resources/UiStrings.he.resx index b97aaecc24..8caf23841b 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.he.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.he.resx @@ -1,5 +1,110 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -885,4 +990,7 @@ הפסקת שיתוף סורק + + בקשה לפני מחיקת דף + \ No newline at end of file diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.pt-BR.resx b/NAPS2.Lib/Lang/Resources/UiStrings.pt-BR.resx index ee335f3afd..140ebf0892 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.pt-BR.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.pt-BR.resx @@ -1,5 +1,110 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -885,4 +990,7 @@ Parar Compartilhamento de Scanner + + Solicitar antes de excluir uma página + \ No newline at end of file