diff --git a/Belegscanner.lps b/Belegscanner.lps index 18ca75e..c57c301 100644 --- a/Belegscanner.lps +++ b/Belegscanner.lps @@ -3,7 +3,7 @@ - + @@ -17,8 +17,8 @@ - - + + @@ -46,127 +46,135 @@ + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/scanner.lfm b/scanner.lfm index 259cd80..d2768da 100644 --- a/scanner.lfm +++ b/scanner.lfm @@ -1,11 +1,11 @@ object ScanForm: TScanForm - Left = 2207 - Height = 95 - Top = 221 - Width = 664 + Left = 1901 + Height = 180 + Top = 631 + Width = 663 Caption = 'Belegscanner' - ClientHeight = 95 - ClientWidth = 664 + ClientHeight = 180 + ClientWidth = 663 OnCreate = FormCreate LCLVersion = '1.8.2.0' object DateView: TLabel @@ -31,7 +31,7 @@ object ScanForm: TScanForm object TypeSelector: TComboBox Left = 8 Height = 29 - Top = 32 + Top = 40 Width = 216 Enabled = False ItemHeight = 0 @@ -42,7 +42,7 @@ object ScanForm: TScanForm object Origin: TComboBox Left = 232 Height = 29 - Top = 32 + Top = 40 Width = 184 Enabled = False ItemHeight = 0 @@ -53,7 +53,7 @@ object ScanForm: TScanForm object Destination: TComboBox Left = 424 Height = 29 - Top = 32 + Top = 40 Width = 196 Enabled = False ItemHeight = 0 @@ -64,7 +64,7 @@ object ScanForm: TScanForm object FolderName: TLabel Left = 8 Height = 19 - Top = 64 + Top = 96 Width = 103 Caption = 'Ordnername' Font.Height = -16 @@ -75,7 +75,7 @@ object ScanForm: TScanForm object Product: TComboBox Left = 232 Height = 29 - Top = 32 + Top = 40 Width = 184 Enabled = False ItemHeight = 0 @@ -85,19 +85,90 @@ object ScanForm: TScanForm Visible = False end object ScnaButton: TButton - Left = 320 + Left = 545 Height = 25 - Top = 8 + Top = 72 Width = 75 Caption = 'scannen!' + Enabled = False OnClick = ScnaButtonClick TabOrder = 5 end + object IWidth: TEdit + Left = 320 + Height = 27 + Top = 8 + Width = 80 + Alignment = taRightJustify + TabOrder = 6 + Text = '209' + end + object Times: TLabel + Left = 402 + Height = 17 + Top = 13 + Width = 6 + Caption = 'x' + ParentColor = False + end + object IHeight: TEdit + Left = 416 + Height = 27 + Top = 8 + Width = 80 + TabOrder = 7 + Text = '297' + end + object Pixels: TLabel + Left = 500 + Height = 17 + Top = 13 + Width = 27 + Caption = 'px @' + ParentColor = False + end + object Resolution: TComboBox + Left = 536 + Height = 29 + Top = 8 + Width = 68 + ItemHeight = 0 + Items.Strings = ( + '150' + '300' + ) + TabOrder = 8 + Text = '150' + end + object DPI: TLabel + Left = 608 + Height = 17 + Top = 13 + Width = 17 + Caption = 'dpi' + ParentColor = False + end + object BaseFolder: TLabel + Left = 8 + Height = 19 + Top = 76 + Width = 88 + Caption = 'BaseFolder' + Font.Height = -16 + Font.Name = 'Sans' + ParentColor = False + ParentFont = False + OnClick = BaseFolderClick + end object DateSelector: TCalendarDialog Date = 43775 OKCaption = '&Ok' CancelCaption = 'Abbrechen' - left = 472 - top = 8 + left = 352 + top = 72 + end + object BaseFolderDialog: TSelectDirectoryDialog + left = 251 + top = 85 end end diff --git a/scanner.pas b/scanner.pas index 916446a..5600942 100644 --- a/scanner.pas +++ b/scanner.pas @@ -6,13 +6,21 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtDlgs, - StdCtrls; + StdCtrls, Unix; type { TScanForm } TScanForm = class(TForm) + DPI: TLabel; + BaseFolder: TLabel; + Resolution: TComboBox; + IHeight: TEdit; + Pixels: TLabel; + BaseFolderDialog: TSelectDirectoryDialog; + Times: TLabel; + IWidth: TEdit; ScnaButton: TButton; Product: TComboBox; Destination: TComboBox; @@ -23,6 +31,7 @@ type DateSelector: TCalendarDialog; DateView: TLabel; + procedure BaseFolderClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ProductChange(Sender: TObject); procedure DestinationChange(Sender: TObject); @@ -35,6 +44,7 @@ type procedure UpdateTypes(); procedure UpdateFolder(); procedure MixLocations(d1: TComboBox; d2: TComboBox); + procedure ScanImage(); private date: TDateTime; public @@ -50,6 +60,11 @@ implementation { TScanForm } +procedure TScanForm.ScanImage(); +begin + fpSystem('scanimage -x '+IWidth.Caption+' -y '+IHeight.Caption+' --mode Gray --resolution '+Resolution.Caption+' --format jpeg > /home/srichter/tmp/test.jpg'); +end; + procedure TScanForm.MixLocations(d1: TComboBox; d2: TComboBox); var list: TStringList; @@ -104,6 +119,7 @@ begin Destination.Enabled := state; Product.Enabled := not state; Product.Visible := not state; + ScnaButton.Enabled:=true; UpdateFolder(); end; @@ -137,7 +153,7 @@ begin finally config.Free; end; - + ScanImage(); end; procedure TScanForm.DestinationChange(Sender: TObject); @@ -159,6 +175,7 @@ var line: String; index: integer; begin + BaseFolder.Caption:=GetEnvironmentVariable('HOME') + '/Documents/Quittungen/'; filename := GetEnvironmentVariable('HOME') + '/.config/belegscanner.conf'; lines := TStringList.Create; try @@ -187,12 +204,19 @@ begin end; end; +procedure TScanForm.BaseFolderClick(Sender: TObject); +begin + BaseFolderDialog.FileName:=BaseFolder.Caption; + BaseFolderDialog.Execute; + BaseFolder.Caption := BaseFolderDialog.FileName; +end; + procedure TScanForm.UpdateFolder(); var tx: string; begin - tx := FormatDateTime('YYYY-MM-DD', date) + ' - '; + tx := FormatDateTime('YYYY', date) + '/' + FormatDateTime('YYYY-MM-DD', date) + ' - '; if (Product.Enabled and (Product.Tag > 0)) then tx := tx + Product.Text + ' von '; if (TypeSelector.Tag > 0) then