File: unit4.pas

package info (click to toggle)
winff 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,908 kB
  • ctags: 171
  • sloc: pascal: 2,794; xml: 2,341; makefile: 61; sh: 14
file content (311 lines) | stat: -rwxr-xr-x 8,416 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
unit Unit4; 

// WInFF 1.0 Copyright 2006-2009 Matthew Weatherford
// http://winff.org
// Licensed under the GPL v3 or any later version
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
  ExtCtrls, StdCtrls, gettext, translations;

type

  { TForm4 }

  TForm4 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    edtThreads: TEdit;
    prioritybox: TComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Notebook1: TNotebook;
    OpenDialog1: TOpenDialog;
    Page1: TPage;
    Page2: TPage;
    Page3: TPage;
    SelectDirectoryDialog1: TSelectDirectoryDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure edtThreadsChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);

  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form4: TForm4; 

resourcestring
    rsform4='WinFF Preferences';
    rsButton1='OK';
    rsButton2='Cancel';
    rsCheckBox1='Remember Last Directory Used';
    rsCheckBox2='Use CHCP for international characters';
    rsCheckBox3='Multithreading for Dual Core Processors';
    rsLabel1='Default Destination Directory';
    rsLabel2='Path to FFmpeg.exe';
    rsLabel3='Path to FFPlay.exe';
    rsLabel4='Path to FFmpeg Executable';
    rsLabel5='Path to FFPlay Executable';
    rsLabel6='Terminal to run FFmpeg';
    rsLabel7='Terminal Options (-e for Xterm , -x for Gnome Terminal';
    rslabel8='Priority';
    rsPage1='General';
    rsPage2='Ms Windows';
    rsPage3='Linux';

    rspriorityhigh='High';
    rsprioritynormal='Normal';
    rspriorityidle='Idle';

implementation

uses unit1;
{ TForm4 }

// load preferences
procedure TForm4.FormCreate(Sender: TObject);

begin
    TranslateUnitResourceStrings('unit4', PODirectory + 'winff.%s.po', unit1.Lang, unit1.FallbackLang);
    form4.Caption:=rsform4;
    button1.caption:=rsButton1;
    button2.caption:=rsButton2;
    checkbox1.caption:=rsCheckBox1;
    checkbox2.caption:=rsCheckBox2;
    checkbox3.caption:=rsCheckBox3;
    label1.caption:=rsLabel1;
    label2.caption:=rsLabel2;
    label3.caption:=rsLabel3;
    label4.caption:=rsLabel4;
    label5.caption:=rsLabel5;
    label6.caption:=rsLabel6;
    label7.caption:=rsLabel7;
    label8.caption:=rslabel8;
    page1.caption:=rsPage1;
    page2.caption:=rsPage2;
    page3.caption:=rsPage3;
    prioritybox.Items.Add(rspriorityhigh);
    prioritybox.Items.Add(rsprioritynormal);
    prioritybox.Items.Add(rspriorityidle);
  {$ifdef win32}
   edit2.Text:= form1.getconfigvalue('win32/ffmpeg');
   edit3.Text:= form1.getconfigvalue('win32/ffplay');
   if form1.getconfigvalue('win32/chcp') = 'true' then
     checkbox2.Checked := true
  else
     checkbox2.Checked := false;
  {$endif}
  {$ifdef unix}

   edit4.Text:= form1.getconfigvalue('unix/ffmpeg');
   edit5.Text:= form1.getconfigvalue('unix/ffplay');
   edit6.Text:= form1.getconfigvalue('unix/terminal');
   edit7.Text:= form1.getconfigvalue('unix/termoptions');
  {$endif}

  edit1.Text:= form1.getconfigvalue('general/destfolder');


  if form1.getconfigvalue('general/rememberlast') = 'true' then
     checkbox1.Checked := true
  else
     checkbox1.Checked := false;

  if form1.getconfigvalue('general/multithreading') = 'true' then
     checkbox3.Checked := true
  else
     checkbox3.Checked := false;
  edtthreads.Text:= form1.getconfigvalue('general/numberofthreads');

  prioritybox.Text := form1.getconfigvalue('general/priority');
end;

// save preference
procedure TForm4.Button1Click(Sender: TObject);

begin
  form1.setconfigvalue('general/destfolder',edit1.text);
  form1.DestFolder.Text := edit1.text;
  
  if checkbox1.Checked then
   begin
    form1.setconfigvalue('general/rememberlast','true');
    unit1.rememberlast:='true';
   end
  else
   begin
    form1.setconfigvalue('general/rememberlast','false');
    unit1.rememberlast:='false';
   end;

  if checkbox3.Checked then
   begin
    form1.setconfigvalue('general/multithreading','true');
    unit1.multithreading:='true';
   end
  else
   begin
    form1.setconfigvalue('general/multithreading','false');
    unit1.multithreading:='false';
   end;
  edtthreads.Text:=trim(edtthreads.Text);
  form1.setconfigvalue('general/numberofthreads', edtthreads.Text);

  form1.setconfigvalue('general/priority', prioritybox.Text);

  edit1.Text := trim(edit1.Text);
  edit2.Text := trim(edit2.Text);
  edit3.Text := trim(edit3.Text);
  edit4.Text := trim(edit4.Text);
  edit5.Text := trim(edit5.Text);
  edit6.Text := trim(edit6.Text);
  edit7.Text := trim(edit7.Text);

  {$ifdef win32}
  if edit2.Text ='' then
   edit2.Text := unit1.extrasPath + 'ffmpeg.exe';
  if edit3.Text ='' then
   edit3.Text := unit1.extrasPath + 'ffplay.exe';

  unit1.ffmpeg := edit2.text;
  unit1.ffplay := edit3.text;
  form1.setconfigvalue('win32/ffmpeg',edit2.text);
  form1.setconfigvalue('win32/ffplay',edit3.text);
  
  if checkbox2.Checked then
   begin
    form1.setconfigvalue('win32/chcp','true');
    unit1.usechcp:='true';
   end
  else
   begin
    form1.setconfigvalue('win32/chcp','false');
    unit1.usechcp:='false';
   end;
  {$endif}

  {$ifdef unix}
  if edit4.Text ='' then
   edit4.Text := '/usr/bin/ffmpeg';
  if edit5.Text ='' then
   edit5.Text := '/usr/bin/ffplay';
  if edit6.Text ='' then
   edit6.Text := '/usr/bin/xterm';

  unit1.ffmpeg := edit4.text;
  unit1.ffplay := edit5.text;
  unit1.terminal :=edit6.text;
  unit1.termoptions := edit7.text;
  form1.setconfigvalue('unix/ffmpeg',edit4.text);
  form1.setconfigvalue('unix/ffplay',edit5.text);
  form1.setconfigvalue('unix/terminal',edit6.text);
  form1.setconfigvalue('unix/termoptions',edit7.text);
  {$endif}
  

  form4.close;

end;

procedure TForm4.Button3Click(Sender: TObject);
begin
 if selectdirectorydialog1.Execute then
    edit1.Text := selectdirectorydialog1.FileName;
end;

procedure TForm4.Button2Click(Sender: TObject);
begin
  form4.close;
end;

procedure TForm4.Button4Click(Sender: TObject);
begin
  if opendialog1.Execute then
    edit2.Text := opendialog1.FileName;
end;

procedure TForm4.Button5Click(Sender: TObject);
begin
   if opendialog1.Execute then
    edit3.Text := opendialog1.FileName;
end;

procedure TForm4.Button6Click(Sender: TObject);
begin
  if opendialog1.Execute then
    edit4.Text := opendialog1.FileName;
end;

procedure TForm4.Button7Click(Sender: TObject);
begin
  if opendialog1.Execute then
    edit5.Text := opendialog1.FileName;
end;

procedure TForm4.Button8Click(Sender: TObject);
begin
   if opendialog1.Execute then
    edit6.Text := opendialog1.FileName;
end;

procedure TForm4.edtThreadsChange(Sender: TObject);
begin

end;


initialization
  {$I unit4.lrs}

end.