Browse Source

working on scanning

main
Stephan Richter 6 years ago
parent
commit
246f0cb02c
  1. 74
      Belegscanner.lps
  2. 101
      scanner.lfm
  3. 30
      scanner.pas

74
Belegscanner.lps

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<ProjectSession>
<Version Value="10"/>
<BuildModes Active="Default"/>
<Units Count="5">
<Units Count="6">
<Unit0>
<Filename Value="Belegscanner.lpr"/>
<IsPartOfProject Value="True"/>
@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
<ComponentName Value="ScanForm"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="136"/>
<CursorPos X="22" Y="183"/>
<TopLine Value="54"/>
<CursorPos X="159" Y="97"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -46,127 +46,135 @@ @@ -46,127 +46,135 @@
<CursorPos X="14" Y="437"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="/usr/share/fpcsrc/3.0.4/packages/fcl-process/src/process.pp"/>
<EditorIndex Value="1"/>
<TopLine Value="99"/>
<CursorPos X="14" Y="131"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit5>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="scanner.pas"/>
<Caret Line="55" Column="16"/>
<Caret Line="172" Column="11" TopLine="71"/>
</Position1>
<Position2>
<Filename Value="scanner.pas"/>
<Caret Line="51" Column="38" TopLine="2"/>
<Caret Line="173" Column="45" TopLine="120"/>
</Position2>
<Position3>
<Filename Value="scanner.pas"/>
<Caret Line="56" Column="19" TopLine="25"/>
<Caret Line="179" TopLine="139"/>
</Position3>
<Position4>
<Filename Value="scanner.pas"/>
<Caret Line="51" Column="54"/>
<Caret Line="175" TopLine="138"/>
</Position4>
<Position5>
<Filename Value="scanner.pas"/>
<Caret Line="117" Column="77" TopLine="112"/>
<Caret Line="154" Column="5" TopLine="138"/>
</Position5>
<Position6>
<Filename Value="scanner.pas"/>
<Caret Line="141" Column="148" TopLine="114"/>
<Caret Line="30" Column="73"/>
</Position6>
<Position7>
<Filename Value="scanner.pas"/>
<Caret Line="13" Column="140"/>
<Caret Line="140" Column="144" TopLine="137"/>
</Position7>
<Position8>
<Filename Value="scanner.pas"/>
<Caret Column="13"/>
<Caret Line="132" Column="3" TopLine="126"/>
</Position8>
<Position9>
<Filename Value="scanner.pas"/>
<Caret Line="19" Column="53" TopLine="38"/>
<Caret Line="107" Column="27" TopLine="96"/>
</Position9>
<Position10>
<Filename Value="scanner.pas"/>
<Caret Line="165" Column="35" TopLine="120"/>
<Caret Line="141" Column="32" TopLine="118"/>
</Position10>
<Position11>
<Filename Value="scanner.pas"/>
<Caret Line="145" Column="74" TopLine="128"/>
<Caret Line="142" Column="32" TopLine="119"/>
</Position11>
<Position12>
<Filename Value="scanner.pas"/>
<Caret Line="71" Column="52" TopLine="31"/>
<Caret Line="143" Column="32" TopLine="120"/>
</Position12>
<Position13>
<Filename Value="scanner.pas"/>
<Caret Line="161" Column="117" TopLine="127"/>
<Caret Line="144" Column="32" TopLine="121"/>
</Position13>
<Position14>
<Filename Value="scanner.pas"/>
<Caret Line="151" Column="70" TopLine="118"/>
<Caret Line="145" Column="32" TopLine="122"/>
</Position14>
<Position15>
<Filename Value="scanner.pas"/>
<Caret Line="34" Column="160" TopLine="26"/>
<Caret Line="146" Column="32" TopLine="123"/>
</Position15>
<Position16>
<Filename Value="scanner.pas"/>
<Caret Line="100" Column="100" TopLine="76"/>
<Caret Line="147" Column="32" TopLine="124"/>
</Position16>
<Position17>
<Filename Value="scanner.pas"/>
<Caret Line="163" Column="12" TopLine="126"/>
<Caret Line="18" Column="12"/>
</Position17>
<Position18>
<Filename Value="scanner.pas"/>
<Caret Line="158" Column="14" TopLine="126"/>
<Caret Line="36" Column="61"/>
</Position18>
<Position19>
<Filename Value="scanner.pas"/>
<Caret Line="164" Column="3" TopLine="125"/>
<Caret Line="171" Column="79" TopLine="156"/>
</Position19>
<Position20>
<Filename Value="scanner.pas"/>
<Caret Line="158" Column="13" TopLine="125"/>
<Caret Line="202" Column="3" TopLine="162"/>
</Position20>
<Position21>
<Filename Value="scanner.pas"/>
<Caret Line="166" Column="5" TopLine="125"/>
<Caret Line="124" Column="63" TopLine="108"/>
</Position21>
<Position22>
<Filename Value="scanner.pas"/>
<Caret Line="164" Column="38" TopLine="130"/>
<Caret Line="196" Column="89" TopLine="164"/>
</Position22>
<Position23>
<Filename Value="scanner.pas"/>
<Caret Line="166" Column="46" TopLine="130"/>
<Caret Line="67" Column="27" TopLine="31"/>
</Position23>
<Position24>
<Filename Value="scanner.pas"/>
<Caret Line="171" TopLine="130"/>
<Caret Line="69" Column="34" TopLine="34"/>
</Position24>
<Position25>
<Filename Value="scanner.pas"/>
<Caret Line="172" Column="11" TopLine="71"/>
<Caret Line="74" Column="17" TopLine="36"/>
</Position25>
<Position26>
<Filename Value="scanner.pas"/>
<Caret Line="173" Column="45" TopLine="120"/>
<Caret Line="79" Column="66" TopLine="36"/>
</Position26>
<Position27>
<Filename Value="scanner.pas"/>
<Caret Line="179" TopLine="139"/>
<Caret Line="74" Column="28" TopLine="41"/>
</Position27>
<Position28>
<Filename Value="scanner.pas"/>
<Caret Line="175" TopLine="138"/>
<Caret Line="97" Column="69" TopLine="59"/>
</Position28>
<Position29>
<Filename Value="scanner.pas"/>
<Caret Line="154" Column="5" TopLine="138"/>
<Caret Line="74" Column="77" TopLine="65"/>
</Position29>
<Position30>
<Filename Value="scanner.pas"/>
<Caret Line="30" Column="73"/>
<Caret Line="9" Column="17"/>
</Position30>
</JumpHistory>
</ProjectSession>

101
scanner.lfm

@ -1,11 +1,11 @@ @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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

30
scanner.pas

@ -6,13 +6,21 @@ interface @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -137,7 +153,7 @@ begin
finally
config.Free;
end;
ScanImage();
end;
procedure TScanForm.DestinationChange(Sender: TObject);
@ -159,6 +175,7 @@ var @@ -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 @@ -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

Loading…
Cancel
Save