diff --git a/Belegscanner.lps b/Belegscanner.lps
index ee148ed..a8bbc1b 100644
--- a/Belegscanner.lps
+++ b/Belegscanner.lps
@@ -9,7 +9,7 @@
-
+
@@ -18,18 +18,18 @@
-
-
-
+
+
+
-
+
-
+
@@ -81,123 +81,123 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/scanner.lfm b/scanner.lfm
index 5d90e83..559602b 100644
--- a/scanner.lfm
+++ b/scanner.lfm
@@ -1,50 +1,50 @@
object ScanForm: TScanForm
Left = 1534
- Height = 1018
+ Height = 869
Top = 299
- Width = 1215
+ Width = 1188
Caption = 'Belegscanner'
- ClientHeight = 1018
- ClientWidth = 1215
+ ClientHeight = 869
+ ClientWidth = 1188
OnCreate = FormCreate
LCLVersion = '1.8.2.0'
object TypeSelector: TComboBox
- Left = 344
+ Left = 904
Height = 29
- Top = 32
- Width = 216
+ Top = 208
+ Width = 276
Enabled = False
ItemHeight = 0
OnChange = TypeSelectorChange
- TabOrder = 3
+ TabOrder = 1
Text = 'Select Type'
end
object Origin: TComboBox
- Left = 568
+ Left = 904
Height = 29
- Top = 32
- Width = 192
+ Top = 240
+ Width = 272
Enabled = False
ItemHeight = 0
OnChange = OriginChange
- TabOrder = 5
+ TabOrder = 3
Text = 'Start'
end
object Destination: TComboBox
- Left = 948
+ Left = 904
Height = 29
- Top = 32
- Width = 196
+ Top = 304
+ Width = 272
Enabled = False
ItemHeight = 0
OnChange = DestinationChange
- TabOrder = 7
+ TabOrder = 5
Text = 'Ziel'
end
object FolderName: TLabel
- Left = 344
+ Left = 8
Height = 19
- Top = 64
+ Top = 840
Width = 103
Caption = 'Ordnername'
Font.Height = -16
@@ -53,86 +53,53 @@ object ScanForm: TScanForm
ParentFont = False
end
object Product: TComboBox
- Left = 568
+ Left = 904
Height = 29
- Top = 32
- Width = 192
+ Top = 240
+ Width = 276
Enabled = False
ItemHeight = 0
OnChange = ProductChange
- TabOrder = 4
+ TabOrder = 2
Text = 'Produkt'
Visible = False
end
object ScanButton: TButton
- Left = 664
+ Left = 904
Height = 49
- Top = 88
- Width = 112
+ Top = 400
+ Width = 272
Caption = 'scannen!'
Enabled = False
OnClick = ScanButtonClick
TabOrder = 8
end
- object IWidth: TEdit
- Left = 344
- Height = 27
- Top = 88
- Width = 80
- Alignment = taRightJustify
- TabOrder = 0
- Text = '209'
- end
- object Times: TLabel
- Left = 426
- Height = 17
- Top = 93
- Width = 6
- Caption = 'x'
- ParentColor = False
- end
- object IHeight: TEdit
- Left = 440
- Height = 27
- Top = 88
- Width = 80
- TabOrder = 1
- Text = '297'
- end
- object Pixels: TLabel
- Left = 524
- Height = 17
- Top = 93
- Width = 27
- Caption = 'px @'
- ParentColor = False
- end
object Resolution: TComboBox
- Left = 560
+ Left = 904
Height = 29
- Top = 88
- Width = 68
+ Top = 368
+ Width = 120
ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'150'
'300'
)
- TabOrder = 2
+ TabOrder = 7
Text = '150'
end
object DPI: TLabel
- Left = 632
+ Left = 1032
Height = 17
- Top = 93
+ Top = 376
Width = 17
Caption = 'dpi'
ParentColor = False
end
object BaseFolder: TLabel
- Left = 344
+ Left = 8
Height = 19
- Top = 8
+ Top = 816
Width = 88
Caption = 'BaseFolder'
Font.Height = -16
@@ -142,31 +109,50 @@ object ScanForm: TScanForm
OnClick = BaseFolderClick
end
object Stop: TComboBox
- Left = 768
+ Left = 904
Height = 29
- Top = 32
- Width = 176
+ Top = 272
+ Width = 272
Enabled = False
ItemHeight = 0
OnChange = StopChange
- TabOrder = 6
+ TabOrder = 4
Text = 'Zwischenhalt'
end
object Preview: TImage
Left = 8
Height = 800
- Top = 208
- Width = 1200
+ Top = 8
+ Width = 880
Center = True
Proportional = True
end
object Calendar: TCalendar
- Left = 8
+ Left = 904
Height = 190
Top = 8
- Width = 324
+ Width = 276
DateTime = 43775
OnChange = CalendarChange
+ TabOrder = 0
+ end
+ object PicSize: TComboBox
+ Left = 904
+ Height = 29
+ Top = 336
+ Width = 272
+ ItemHeight = 0
+ TabOrder = 6
+ Text = '209 x 297 mm'
+ end
+ object DropButton: TButton
+ Left = 904
+ Height = 32
+ Top = 776
+ Width = 276
+ Caption = 'Löschen'
+ Enabled = False
+ OnClick = DropButtonClick
TabOrder = 9
end
object BaseFolderDialog: TSelectDirectoryDialog
diff --git a/scanner.pas b/scanner.pas
index e3b4014..05eb388 100644
--- a/scanner.pas
+++ b/scanner.pas
@@ -13,28 +13,27 @@ type
{ ScanThread }
ScanThread = class(TThread)
private
- btn : TButton;
- folder,w,h,r :String;
+ dbtn, sbtn : TButton;
+ folder,r :String;
+ s:TPoint;
p:TImage;
protected
procedure Execute; override;
public
- constructor Create(button: TButton; dir: String; width: String; height: String; resolution: String; preview: TImage);
+ constructor Create(scanButton: TButton; dir: String; size: TPoint; resolution: String; preview: TImage; dropButton: TButton);
end;
{ TScanForm }
TScanForm = class(TForm)
+ DropButton: TButton;
Calendar: TCalendar;
+ PicSize: TComboBox;
Preview: TImage;
Stop: TComboBox;
DPI: TLabel;
BaseFolder: TLabel;
Resolution: TComboBox;
- IHeight: TEdit;
- Pixels: TLabel;
BaseFolderDialog: TSelectDirectoryDialog;
- Times: TLabel;
- IWidth: TEdit;
ScanButton: TButton;
Product: TComboBox;
Destination: TComboBox;
@@ -43,6 +42,7 @@ type
TypeSelector: TComboBox;
procedure BaseFolderClick(Sender: TObject);
+ procedure DropButtonClick(Sender: TObject);
procedure CalendarChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ProductChange(Sender: TObject);
@@ -58,6 +58,7 @@ type
procedure MixLocations(d1: TComboBox; d2: TComboBox; d3: TComboBox);
private
date: TDateTime;
+ function getSize(): TPoint;
public
end;
@@ -71,12 +72,12 @@ implementation
{ ScanThread }
-constructor ScanThread.Create(button: TButton; dir: String; width: String; height: String; resolution: String; preview: TImage);
+constructor ScanThread.Create(scanButton: TButton; dir: String; size: TPoint; resolution: String; preview: TImage; dropButton: TButton );
begin
- btn := button;
+ sbtn := scanButton;
+ dbtn := dropButton;
folder:=dir;
- w:=width;
- h:=height;
+ s:=size;
r:=resolution;
p:=preview;
inherited Create(false);
@@ -92,18 +93,31 @@ begin
num := 0;
repeat
num := num +1;
- fname := '/scan_';
+ fname := 'scan_';
if (num<10) then fname:=fname+'0';
fname := fname+IntToStr(num)+'.jpg';
until not FileExists(folder+fname);
- fpSystem('scanimage -x '+w+' -y '+h+' --mode Color --resolution '+r+' --format jpeg > "'+folder+fname+'"');
+ fpSystem('scanimage -x '+IntToStr(s.x)+' -y '+IntToStr(s.y)+' --mode Color --resolution '+r+' --format jpeg > "'+folder+fname+'"');
try
pic:=TPicture.Create;
pic.LoadFromFile(folder+fname);
p.Picture:=pic;
+ p.Hint:=folder+fname;
finally
end;
- btn.Enabled:=true;
+ dbtn.Hint:=folder+fname;
+ dbtn.Caption:=fname+' löschen';
+ dbtn.Enabled:=true;
+ sbtn.Enabled:=true;
+end;
+
+function allowed(s: String): boolean;
+begin
+ Result := true;
+ if (s = '') then Result := false;
+ if (s = 'Start') then Result := false;
+ if (s = 'Ziel') then Result := false;
+ if (s = 'Zwischenhalt') then Result := false;
end;
procedure TScanForm.MixLocations(d1: TComboBox; d2: TComboBox; d3: TComboBox);
@@ -112,9 +126,9 @@ var
begin
list := TStringList.Create;
list.Sorted := True;
- d1.Items.Add(d1.Text);
- d2.Items.Add(d2.Text);
- if not (d3.Text = '') then d3.Items.Add(d3.Text);
+ if (allowed(d1.Text)) then d1.Items.Add(d1.Text);
+ if (allowed(d2.Text)) then d2.Items.Add(d2.Text);
+ if (allowed(d3.Text)) then d3.Items.Add(d3.Text);
list.Assign(d1.Items);
list.AddStrings(d2.Items);
list.AddStrings(d3.Items);
@@ -129,6 +143,7 @@ begin
Result := Result + 'items:' + ExportOptions(Product) + #13;
MixLocations(Origin, Destination, Stop);
Result := Result + 'locations:' + ExportOPtions(Origin) + #13;
+ Result := Result + 'sizes:' + ExportOptions(PicSize) +#13;
end;
function TScanForm.ExportOptions(dropDown: TComboBox): string;
@@ -184,14 +199,30 @@ begin
UpdateFolder();
end;
+function TScanForm.getSize(): TPoint;
+var
+ arr: TStringArray;
+ s: String;
+ w, h: Integer;
+begin
+ s:=PicSize.Text;
+ arr:=s.Split(['x','m']);
+ w:=StrToInt(arr[0].Trim);
+ h:=StrToInt(arr[1].Trim);
+ PicSize.Caption:=IntToStr(w)+' x '+IntToStr(h)+' mm';
+ Result := TPoint.Create(w,h);
+end;
+
procedure TScanForm.ScanButtonClick(Sender: TObject);
var
config: TFileStream;
filename: string;
json: string;
+ size: TPoint;
begin
ScanButton.Enabled:=false;
filename := GetEnvironmentVariable('HOME') + '/.config/belegscanner.conf';
+ size := getSize();
json := ExportConfig();
try
config := TFilestream.Create(filename, fmCreate);
@@ -199,7 +230,7 @@ begin
finally
config.Free;
end;
- ScanThread.Create(ScanButton,BaseFolder.Caption+FolderName.Caption,IWidth.Caption,IHeight.Caption,Resolution.Caption,Preview);
+ ScanThread.Create(ScanButton,BaseFolder.Caption+FolderName.Caption+'/',size,Resolution.Caption,Preview,DropButton);
end;
procedure TScanForm.StopChange(Sender: TObject);
@@ -245,6 +276,11 @@ begin
line := line.Substring(6);
Product.Items.AddStrings(line.Split(','));
end;
+ if line.StartsWith('sizes:') then
+ begin
+ line := line.Substring(6);
+ PicSize.Items.AddStrings(line.Split(','));
+ end;
if line.StartsWith('locations:') then
begin
line := line.Substring(10);
@@ -264,13 +300,20 @@ begin
BaseFolder.Caption := BaseFolderDialog.FileName;
end;
+procedure TScanForm.DropButtonClick(Sender: TObject);
+begin
+ DeleteFile(DropButton.Hint);
+ Preview.Picture:=nil;
+ DropButton.Enabled:=false;
+end;
+
procedure TScanForm.UpdateFolder();
var
tx: string;
begin
tx := FormatDateTime('YYYY', date) + '/' + FormatDateTime('YYYY-MM-DD', date) + ' - ';
- if (Product.Enabled and (Product.Tag > 0)) then
+ if (Product.Enabled and (Product.Tag > 0) and not( Product.Text = '') and not (Product.Text = 'Produkt')) then
tx := tx + Product.Text + ' von ';
if (TypeSelector.Tag > 0) then
tx := tx + TypeSelector.Text;