Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.7 KiB

3 years ago
  1. unit AdvOptionsForm;
  2. interface
  3. uses
  4. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  5. ExtCtrls, Spin, ActnList, Options, Config;
  6. type
  7. { TFormAdvOptions }
  8. TFormAdvOptions = class(TForm)
  9. ActResetOptions: TAction;
  10. AtcBrowseDeskewExe: TAction;
  11. ActionList: TActionList;
  12. BtnBrowseDeskewExePath: TButton;
  13. BtnResetOptions: TButton;
  14. CheckDefaultExecutable: TCheckBox;
  15. ComboOutputFormat: TComboBox;
  16. EdDeskewExePath: TEdit;
  17. LabDeskewExe: TLabel;
  18. LabTitle: TLabel;
  19. LabForcedFormat: TLabel;
  20. LabMaxAngle: TLabel;
  21. LabSkipAngle: TLabel;
  22. Panel1: TPanel;
  23. SpinEditMaxAngle: TFloatSpinEdit;
  24. SpinEditSkipAngle: TFloatSpinEdit;
  25. procedure ActResetOptionsExecute(Sender: TObject);
  26. procedure AtcBrowseDeskewExeExecute(Sender: TObject);
  27. procedure FormCreate(Sender: TObject);
  28. procedure FormDestroy(Sender: TObject);
  29. public
  30. procedure ApplyOptions(AOptions: TOptions);
  31. procedure GatherOptions(AOptions: TOptions);
  32. procedure DoIdle;
  33. end;
  34. var
  35. FormAdvOptions: TFormAdvOptions;
  36. implementation
  37. uses
  38. DataModule, MainForm;
  39. {$R *.lfm}
  40. { TFormAdvOptions }
  41. procedure TFormAdvOptions.FormCreate(Sender: TObject);
  42. begin
  43. ComboOutputFormat.Items.Clear;
  44. ComboOutputFormat.Items.AddObject('Default (usually same as input)', TObject(fofNone));
  45. ComboOutputFormat.Items.AddObject('1bit black and white', TObject(fofBinary1));
  46. ComboOutputFormat.Items.AddObject('8bit grayscale', TObject(fofGray8));
  47. ComboOutputFormat.Items.AddObject('24bit RGB', TObject(fofRgb24));
  48. ComboOutputFormat.Items.AddObject('32bit RGB + opacity', TObject(fofRgba32));
  49. ComboOutputFormat.ItemIndex := 0;
  50. if not Config.ShowDeskewExeOption then
  51. begin
  52. CheckDefaultExecutable.Visible := False;
  53. LabDeskewExe.Visible := False;
  54. EdDeskewExePath.Visible := False;
  55. BtnBrowseDeskewExePath.Visible := False;
  56. Height := EdDeskewExePath.BoundsRect.Bottom;
  57. end;
  58. ApplyOptions(Module.Options);
  59. end;
  60. procedure TFormAdvOptions.FormDestroy(Sender: TObject);
  61. begin
  62. GatherOptions(Module.Options);
  63. end;
  64. procedure TFormAdvOptions.ApplyOptions(AOptions: TOptions);
  65. begin
  66. CheckDefaultExecutable.Checked := AOptions.DefaultExecutable;
  67. EdDeskewExePath.Text := AOptions.CustomExecutablePath;
  68. EdDeskewExePath.SelStart := Length(EdDeskewExePath.Text);
  69. SpinEditMaxAngle.Value := AOptions.MaxAngle;
  70. SpinEditSkipAngle.Value := AOptions.SkipAngle;
  71. ComboOutputFormat.ItemIndex := Integer(AOptions.ForcedOutputFormat);
  72. end;
  73. procedure TFormAdvOptions.GatherOptions(AOptions: TOptions);
  74. begin
  75. AOptions.MaxAngle := SpinEditMaxAngle.Value;
  76. AOptions.SkipAngle := SpinEditSkipAngle.Value;
  77. AOptions.ForcedOutputFormat := TForcedOutputFormat(PtrUInt(ComboOutputFormat.Items.Objects[ComboOutputFormat.ItemIndex]));
  78. AOptions.DefaultExecutable := CheckDefaultExecutable.Checked;
  79. AOptions.CustomExecutablePath := EdDeskewExePath.Text;
  80. end;
  81. procedure TFormAdvOptions.DoIdle;
  82. begin
  83. AtcBrowseDeskewExe.Enabled := not CheckDefaultExecutable.Checked;
  84. EdDeskewExePath.Enabled := AtcBrowseDeskewExe.Enabled;
  85. end;
  86. procedure TFormAdvOptions.AtcBrowseDeskewExeExecute(Sender: TObject);
  87. begin
  88. Module.OpenDialogSingle.Title := 'Select Deskew Binary Executable';
  89. if Module.OpenDialogSingle.Execute then
  90. begin
  91. EdDeskewExePath.Text := Module.OpenDialogSingle.FileName;
  92. EdDeskewExePath.SelStart := Length(EdDeskewExePath.Text);
  93. end;
  94. end;
  95. procedure TFormAdvOptions.ActResetOptionsExecute(Sender: TObject);
  96. begin
  97. if Dialogs.QuestionDlg('Reset Options', 'Do you really want to reset the options to default?',
  98. mtConfirmation, [mrOk, 'Reset', mrCancel], 0) = mrOk then
  99. begin
  100. Module.Options.Reset;
  101. ApplyOptions(Module.Options);
  102. FormMain.ApplyOptions(Module.Options);
  103. end;
  104. end;
  105. end.