Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 4 additions & 171 deletions NAPS2.Lib/Config/InternalDefaults.cs
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
using System.Collections.Immutable;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Email;
using NAPS2.ImportExport.Email.Oauth;
using NAPS2.ImportExport.Images;
using NAPS2.Ocr;
using NAPS2.Pdf;
using NAPS2.Scan;
using NAPS2.Scan.Batch;

namespace NAPS2.Config;

public static class InternalDefaults
{
public static CommonConfig GetCommonConfig() =>
new CommonConfig
{
Version = CommonConfig.CURRENT_VERSION,
Culture = "en",
FormStates = ImmutableList<FormState>.Empty,
BackgroundOperations = ImmutableHashSet<string>.Empty,
CustomPageSizePresets = ImmutableList<NamedPageSize>.Empty,
StartupMessageTitle = "",
StartupMessageText = "",
StartupMessageIcon = MessageBoxIcon.None,
Theme = Theme.Default,
ScanChangesDefaultProfile = true,
ScanButtonDefaultAction = ScanButtonDefaultAction.ScanWithDefaultProfile,
SaveButtonDefaultAction = SaveButtonDefaultAction.SaveAll,
HiddenButtons = ToolbarButtons.None,
DisableAutoSave = false,
LockSystemProfiles = false,
LockUnspecifiedDevices = false,
NoUserProfiles = false,
AlwaysRememberDevice = false,
NoUpdatePrompt = false,
CheckForUpdates = false,
HasCheckedForUpdates = false,
LastUpdateCheckDate = null,
HasBeenRun = false,
FirstRunDate = null,
HasBeenPromptedForDonation = false,
LastDonatePromptDate = null,
HasBeenPromptedForReview = false,
LastReviewPromptDate = null,
DeleteAfterSaving = false,
DisableSaveNotifications = false,
DisableExitConfirmation = false,
SingleInstance = false,
ComponentsPath = "",
OcrTimeoutInSeconds = 10 * 60, // 10 minutes
EnableOcr = false,
OcrLanguageCode = "",
LastOcrMultiLangCode = "",
OcrMode = LocalizedOcrMode.Fast,
OcrPreProcessing = false,
OcrAfterScanning = true,
LastImageExt = "",
LastPdfOrImageExt = "",
ThumbnailSize = ThumbnailSizes.DEFAULT_SIZE,
DesktopToolStripDock = DockStyle.Top,
EventLogging = EventType.None,
ShowPageNumbers = false,
SidebarVisible = true,
SidebarWidth = 230,
EditWithAppPath = "",
EditWithAppName = "",
ApplyToAllSelected = false,
PdfSettings = new PdfSettings
{
Metadata = new PdfMetadata
Expand Down Expand Up @@ -93,7 +25,8 @@ public static CommonConfig GetCommonConfig() =>
Compat = PdfCompat.Default,
DefaultFileName = "",
SkipSavePrompt = false,
SinglePagePdfs = false
SinglePagePdfs = false,
UseDefaultFileNamePlaceholder = true
},
RememberPdfSettings = false,
ImageSettings = new ImageSettings
Expand All @@ -102,106 +35,6 @@ public static CommonConfig GetCommonConfig() =>
SkipSavePrompt = false,
JpegQuality = 75,
SinglePageTiff = false,
TiffCompression = TiffCompression.Auto
TiffCompression = TiffCompression.Auto,
UseDefaultFileNamePlaceholder = true
},
RememberImageSettings = false,
EmailSettings = new EmailSettings
{
AttachmentName = "Scan.pdf"
},
RememberEmailSettings = false,
EmailSetup = new EmailSetup
{
SystemProviderName = "",
ProviderType = EmailProviderType.System,
SmtpUser = "",
GmailUser = "",
OutlookWebToken = new OauthToken(),
SmtpHost = "",
GmailToken = new OauthToken(),
OutlookWebUser = "",
SmtpFrom = "",
SmtpPassword = "",
SmtpPort = 0,
SmtpTls = false
},
BatchSettings = new BatchSettings
{
OutputType = BatchOutputType.Load,
SaveSeparator = SaveSeparator.FilePerPage,
ScanType = BatchScanType.Single,
SavePath = "",
ScanIntervalSeconds = 0,
ScanCount = 1,
ProfileDisplayName = ""
},
KeyboardShortcuts = new KeyboardShortcuts
{
ScanDefault = "Mod+Enter",
ScanProfile1 = "F2",
ScanProfile2 = "F3",
ScanProfile3 = "F4",
ScanProfile4 = "F5",
ScanProfile5 = "F6",
ScanProfile6 = "F7",
ScanProfile7 = "F8",
ScanProfile8 = "F9",
ScanProfile9 = "F10",
ScanProfile10 = "F11",
ScanProfile11 = "F12",
ScanProfile12 = "",
NewProfile = "Mod+N",
BatchScan = "Mod+B",
Profiles = "Mod+L",
ScannerSharing = "Mod+G",
Ocr = "Mod+Alt+O",
Import = "Mod+O",
SavePDF = "",
SavePDFAll = "Mod+S",
SavePDFSelected = "Mod+Shift+S",
PDFSettings = "Mod+Alt+P",
SaveImages = "",
SaveImagesAll = "Mod+I",
SaveImagesSelected = "Mod+Shift+I",
ImageSettings = "Mod+Alt+I",
EmailPDF = "",
EmailPDFAll = "Mod+E",
EmailPDFSelected = "Mod+Shift+E",
EmailSettings = "Mod+Alt+E",
Print = "Mod+P",
ImageView = "",
ImageBlackWhite = "",
ImageBrightness = "",
ImageContrast = "",
ImageCrop = "",
ImageHue = "",
ImageReset = "",
ImageSaturation = "",
ImageSharpen = "",
ImageDocumentCorrection = "",
ImageSplit = "",
ImageCombine = "",
ImageEditWith = "",
RotateLeft = "Mod+Shift+Left",
RotateRight = "Mod+Shift+Right",
RotateFlip = "Mod+Shift+Down",
RotateCustom = "",
RotateDeskew = "",
MoveUp = "Mod+Up",
MoveDown = "Mod+Down",
ReorderInterleave = "",
ReorderDeinterleave = "",
ReorderAltInterleave = "",
ReorderAltDeinterleave = "",
ReorderReverseAll = "",
ReorderReverseSelected = "",
Delete = "",
Clear = "Mod+Shift+Del",
Settings = "",
About = "F1",
ZoomIn = "Mod+Oemplus",
ZoomOut = "Mod+OemMinus"
},
DefaultProfileSettings = new ScanProfile { Version = ScanProfile.CURRENT_VERSION }
};
}
7 changes: 4 additions & 3 deletions NAPS2.Lib/EtoForms/EtoDialogHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Eto.Forms;
using Eto.Forms;
using NAPS2.ImportExport;

namespace NAPS2.EtoForms;
Expand Down Expand Up @@ -88,7 +88,8 @@ public override bool PromptToSaveImage(string? defaultPath, out string? savePath
{
if (string.IsNullOrEmpty(defaultPath))
{
return _addExt ? $".{ext}" : null;
// Provide a default timestamped placeholder when no path is configured
return _addExt ? $"NAPS2_Scanned_$(YYYY)-$(MM)-$(DD)$(hh)-$(mm)-$(ss).{ext}" : null;
}
var normPath = NormalizePath(defaultPath);
return _addExt && !Path.HasExtension(normPath)
Expand Down Expand Up @@ -149,4 +150,4 @@ public override bool PromptToImport(out string[]? filePaths)
filePaths = null;
return false;
}
}
}
6 changes: 5 additions & 1 deletion NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class PdfSettingsForm : EtoDialogBase
{
private readonly FilePathWithPlaceholders _defaultFilePath;
private readonly CheckBox _skipSavePrompt = new() { Text = UiStrings.SkipSavePrompt };
private readonly CheckBox _useDefaultFileNamePlaceholder = new() { Text = UiStrings.UseDefaultFileNamePlaceholder };
private readonly CheckBox _singlePagePdfs = new() { Text = UiStrings.SinglePageFiles };
private readonly TextBox _title = new();
private readonly TextBox _author = new();
Expand Down Expand Up @@ -69,6 +70,7 @@ protected override void BuildLayout()
C.Label(UiStrings.DefaultFilePathLabel),
_defaultFilePath,
_skipSavePrompt,
_useDefaultFileNamePlaceholder,
_singlePagePdfs,
L.GroupBox(
UiStrings.Metadata,
Expand Down Expand Up @@ -114,6 +116,7 @@ private void UpdateValues(Naps2Config config)
{
_defaultFilePath.Text = config.Get(c => c.PdfSettings.DefaultFileName);
_skipSavePrompt.Checked = config.Get(c => c.PdfSettings.SkipSavePrompt);
_useDefaultFileNamePlaceholder.Checked = config.Get(c => c.PdfSettings.UseDefaultFileNamePlaceholder);
_singlePagePdfs.Checked = config.Get(c => c.PdfSettings.SinglePagePdfs);
_title.Text = config.Get(c => c.PdfSettings.Metadata.Title);
_author.Text = config.Get(c => c.PdfSettings.Metadata.Author);
Expand Down Expand Up @@ -148,6 +151,7 @@ private void Save()
{
DefaultFileName = _defaultFilePath.Text,
SkipSavePrompt = _skipSavePrompt.IsChecked(),
UseDefaultFileNamePlaceholder = _useDefaultFileNamePlaceholder.IsChecked(),
SinglePagePdfs = _singlePagePdfs.IsChecked(),
Metadata = new PdfMetadata
{
Expand Down Expand Up @@ -202,4 +206,4 @@ private void EncryptPdf_CheckedChanged(object? sender, EventArgs e)
{
UpdateEnabled();
}
}
}
6 changes: 4 additions & 2 deletions NAPS2.Lib/ImportExport/Images/ImageSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NAPS2.ImportExport.Images;
namespace NAPS2.ImportExport.Images;

public record ImageSettings
{
Expand All @@ -11,4 +11,6 @@ public record ImageSettings
public TiffCompression TiffCompression { get; init; } = TiffCompression.Auto;

public bool SinglePageTiff { get; init; }
}

public bool UseDefaultFileNamePlaceholder { get; init; } = true;
}
4 changes: 3 additions & 1 deletion NAPS2.Lib/Pdf/PdfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public PdfSettings()

public bool SinglePagePdfs { get; set; }

public bool UseDefaultFileNamePlaceholder { get; set; } = true;

[Config]
public PdfMetadata Metadata
{
Expand All @@ -34,4 +36,4 @@ public PdfEncryption Encryption
}

public PdfCompat Compat { get; set; }
}
}