3
// WInFF 1.0 Copyright 2006-2009 Matthew Weatherford
4
// WinFF 1.3.2 Copyright 2011 Alexey Osipov <lion-simba@pridelands.ru>
6
// Licensed under the GPL v3 or any later version
8
// This program is free software: you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 3 of the License, or
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with this program. If not, see <http://www.gnu.org/licenses/>.
26
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
27
{$IFDEF WIN32} windows, shellapi, dos,{$endif}
28
{$IFDEF unix} baseunix, unix, {$endif}
29
laz_xmlcfg, dom, xmlread, xmlwrite, StdCtrls, Buttons, ActnList, Menus, unit2, unit3,
30
unit4, unit5, gettext, translations, process
31
{$IFDEF TRANSLATESTRING}, DefaultTranslator{$ENDIF}, ExtCtrls, ComCtrls, MaskEdit, Spin,
38
TfrmMain = class(TForm)
41
audsamplingrate: TEdit;
45
categorybox: TComboBox;
47
cbxDeinterlace: TCheckBox;
49
ChooseFolderBtn: TButton;
50
commandlineparams: TEdit;
52
edtAspectRatio: TEdit;
65
gbxSettings: TGroupBox;
66
grpOutputSettings: TGroupBox;
80
lblAspectRatio: TLabel;
81
lblCropBottom: TLabel;
85
lblCropRight2: TLabel;
88
lblVideoBitRate: TLabel;
90
// mitPlaySoundonFinish: TMenuItem;
91
mitDisplayCmdline: TMenuItem;
92
dlgOpenFile: TOpenDialog;
100
MenuItem9: TMenuItem;
101
dlgOpenPreset: TOpenDialog;
102
nbkSettings: TNotebook;
118
PresetBox: TComboBox;
119
StatusBar1: TStatusBar;
123
pnlAdditionalOptions: TPanel;
125
mitPauseOnFinish: TMenuItem;
126
mitPlaySoundOnFinish: TMenuItem;
128
mitShutdownOnFinish: TMenuItem;
131
mitPresets: TMenuItem;
132
mitPreferences: TMenuItem;
133
mitImportPreset: TMenuItem;
134
mitShowOptions: TMenuItem;
135
mnuOptions: TMenuItem;
137
MainMenu1: TMainMenu;
138
//dlgOpenFile: TOpenDialog;
139
SelectDirectoryDialog1: TSelectDirectoryDialog;
141
tabAudioSettings: TPage;
142
tabCmdLineSettings: TPage;
145
tabVideoSettings: TPage;
158
procedure btnPreviewClick(Sender: TObject);
159
procedure Button1Click(Sender: TObject);
160
procedure categoryboxChange(Sender: TObject);
161
procedure edtCropBottomChange(Sender: TObject);
162
procedure edtCropLeftChange(Sender: TObject);
163
procedure edtCropRightChange(Sender: TObject);
164
procedure edtCropTopChange(Sender: TObject);
165
procedure edtSeekMMChange(Sender: TObject);
166
procedure filelistKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
167
procedure LaunchBrowser(URL:string);
168
procedure LaunchPdf(pdffile:string);
169
procedure ChooseFolderBtnClick(Sender: TObject);
170
procedure btnAddClick(Sender: TObject);
171
procedure btnClearClick(Sender: TObject);
172
procedure lblCropRight1Click(Sender: TObject);
173
procedure edtSeekHHChange(Sender: TObject);
174
procedure mitDisplayCmdlineClick(Sender: TObject);
175
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
176
procedure FormCreate(Sender: TObject);
177
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
178
procedure mitImportPresetClick(Sender: TObject);
179
procedure mitAboutClick(Sender: TObject);
180
procedure MenuItem2Click(Sender: TObject);
181
procedure mitExitClick(Sender: TObject);
182
procedure mitPlaySoundonFinishClick(Sender: TObject);
183
procedure mitPresetsClick(Sender: TObject);
184
procedure mitPreferencesClick(Sender: TObject);
185
procedure mitDocsClick(Sender: TObject);
186
procedure mitForumsClick(Sender: TObject);
187
procedure mitWinffClick(Sender: TObject);
188
procedure mitPauseOnFinishClick(Sender: TObject);
189
procedure btnPlayClick(Sender: TObject);
190
procedure btnRemoveClick(Sender: TObject);
191
function GetDeskTopPath() : string;
192
function GetMydocumentsPath() : string ;
193
procedure PresetBoxChange(Sender: TObject);
194
procedure setconfigvalue(key:string;value:string);
195
function getconfigvalue(key:string):string;
196
procedure populatepresetbox(selectedcategory:string);
197
function getcurrentpresetname(currentpreset:string):string;
198
function getpresetparams(presetname:string):string;
199
function getpresetcategory(presetname:string):string;
200
function getpresetextension(presetname:string):string;
201
procedure mitShowOptionsClick(Sender: TObject);
202
procedure mitShutdownOnFinishClick(Sender: TObject);
203
procedure btnConvertClick(Sender: TObject);
204
procedure importpresetfromfile(presetfilename: string);
205
function GetappdataPath() : string ;
206
function replaceparam(commandline:string;param:string;replacement:string):string;
207
procedure VidbitrateChange(Sender: TObject);
208
{$IFDEF WIN32}function GetWin32System(): Integer;{$endif}
211
{ private declarations }
214
{ public declarations }
221
shfolder = 'ShFolder.dll';
222
{ win32 custom directory constants }
223
CSIDL_PERSONAL: longint = $0005;
224
CSIDL_DESKTOPDIRECTORY: longint = $0010;
225
CSIDL_APPDATA: longint = $001a;
226
{ win32 operating system (OS)constants }
227
cOsUnknown: Integer = -1;
228
cOsWin95: Integer = 0;
229
cOsWin98: Integer = 1;
230
cOsWin98SE: Integer = 2;
231
cOsWinME: Integer = 3;
232
cOsWinNT: Integer = 4;
233
cOsWin2000: Integer = 5;
241
ansicodepage: longint;
246
presetsfile: Txmldocument;
254
rememberlast: string;
257
rememberpreset: string;
258
pass2encoding: string ;
261
multithreading: string;
262
PODirectory, Lang, FallbackLang, POFile: String;
267
rsCouldNotFindPresetFile = 'Could not find presets file.';
268
rsCouldNotFindFFmpeg = 'Could not find FFmpeg.';
269
rsCouldNotFindFFplay = 'Could not find FFPlay.';
270
rsSelectVideoFiles = 'Select Video Files';
271
rsSelectPresetFile = 'Select Preset File';
272
rsPleaseSelectAPreset = 'Please select a preset';
273
rsPleaseAdd1File = 'Please add at least 1 file to convert';
274
rsConverting = 'Converting';
275
rsPressEnter = 'Press Enter to Continue';
276
rsCouldNotFindFile = 'Could Not Find File';
277
rsInvalidPreset = 'Invalid Preset File';
278
rsPresetAlreadyExist = 'Preset: %s%s%s already exists';
279
rsPresetHasNoLabel = 'The preset to import does not have a label';
280
rsThePresetHasIllegalChars = 'The preset contains illegal characters';
281
rsPresetWithLabelExists = 'Preset with label: %s%s%s already exists';
282
rsPresethasnoExt = 'The preset to import does not have an extension';
283
rsNameMustBeAllpha = 'Name Must be alphanumeric (a-z,A-Z,0-9)';
284
rsExtensionnoperiod = 'Extension can not contain a period';
285
rsFileDoesNotExist = 'file does not exist';
286
rsPresettoExport = 'Please select a preset to export';
287
rsSelectDirectory = 'Select Directory';
292
// Initialize everything
293
procedure TfrmMain.FormCreate(Sender: TObject);
298
formheight,formwidth,formtop,formleft:integer;
299
sformheight,sformwidth,sformtop,sformleft:string;
300
currentpreset, destdir: string;
303
ExtrasPath:= ExtractFilePath(ParamStr(0));
307
TranslateUnitResourceStrings('unit1', PODirectory + 'winff.%s.po', Lang, FallbackLang);
311
ansicodepage:=getacp();
312
presetspath :=GetappdataPath() + '\Winff\';
314
if not DirectoryExists(presetspath) then
315
createdir(presetspath);
317
ffmpeg := getconfigvalue('win32/ffmpeg');
320
ffmpeg := extraspath + 'ffmpeg.exe';
321
setconfigvalue('win32/ffmpeg',ffmpeg);
324
ffplay := getconfigvalue('win32/ffplay');
327
ffplay := extraspath + 'ffplay.exe';
328
setconfigvalue('win32/ffplay',ffplay);
331
if (GetWIn32System >=0) and (GetWIn32System <4)
333
terminal:='command.com'
338
usechcp:= getconfigvalue('win32/chcp');
342
setconfigvalue('win32/chcp','true');
348
presetbox.Height:=30;
349
categorybox.Height:=30;
351
extraspath:='/usr/share/winff/';
352
if not directoryexists(extraspath) then
353
ExtrasPath:= ExtractFilePath(ParamStr(0));
355
presetspath := GetMydocumentsPath() + '/.winff/';
357
if not DirectoryExists(presetspath) then
358
createdir(presetspath);
360
ffmpeg := getconfigvalue('unix/ffmpeg');
363
ffmpeg := '/usr/bin/ffmpeg';
364
if not fileexists(ffmpeg) then
365
if fileexists('/usr/local/bin/ffmpeg') then
366
ffmpeg := '/usr/local/bin/ffmpeg'
368
showmessage(rsCouldNotFindFFmpeg);
369
setconfigvalue('unix/ffmpeg',ffmpeg)
372
ffplay := getconfigvalue('unix/ffplay');
375
ffplay := '/usr/bin/ffplay';
376
if not fileexists(ffplay) then
377
if fileexists('/usr/local/bin/ffplay') then
378
ffplay := '/usr/local/bin/ffplay'
380
showmessage(rsCouldNotFindFFPlay);
381
setconfigvalue('unix/ffplay',ffplay);
384
terminal := getconfigvalue('unix/terminal');
385
if terminal = '' then
387
terminal := '/usr/bin/xterm';
388
if fileexists('/usr/bin/gnome-terminal') then terminal:='/usr/bin/gnome-terminal';
389
if fileexists('/usr/bin/x-terminal-emulator') then terminal:='/usr/bin/x-terminal-emulator';
390
setconfigvalue('unix/terminal',terminal);
393
termoptions := getconfigvalue('unix/termoptions');
394
if termoptions = '' then
397
if terminal = '/usr/bin/gnome-terminal' then termoptions := '-x';
398
setconfigvalue('unix/termoptions',termoptions);
405
if (not fileexists(presetspath + 'presets.xml')) and (fileexists(extraspath + directoryseparator +'presets.xml')) then
407
AssignFile(F1, extraspath + directoryseparator +'presets.xml');
409
AssignFile(F2, presetspath + 'presets.xml');
420
if not fileexists(presetspath + 'presets.xml') then
422
showmessage(rsCouldNotFindPresetFile);
426
presetsfile.Create; // load the presets file
428
ReadXMLFile(presetsfile, presetspath+'presets.xml');
429
presets:=presetsfile.DocumentElement;
431
showmessage(rsCouldNotFindPresetFile);
434
// import preset from command line
435
if upcase(rightstr(paramstr(1),4)) = '.WFF' then
437
importpresetfromfile(paramstr(1));
440
// fill combobox with presets
441
rememberpreset:=getconfigvalue('general/currentpreset');
442
currentpreset:=getcurrentpresetname(rememberpreset);
443
populatepresetbox(getpresetcategory(currentpreset));
444
for i:= 0 to presetbox.items.Count - 1 do
446
if presetbox.Items[i]=rememberpreset then
448
presetbox.ItemIndex:=i;
452
// set window size and position
453
showopts:=getconfigvalue('general/showoptions');
454
sformheight:=getconfigvalue('window/height');
455
sformwidth:=getconfigvalue('window/width');
456
sformtop:=getconfigvalue('window/top');
457
sformleft:=getconfigvalue('window/left');
460
if sformtop <> '' then formtop:=strtoint(sformtop);
461
if formtop > 0 then frmMain.Top := formtop;
464
if sformleft <> '' then formleft:=strtoint(sformleft);
465
if formleft >0 then frmMain.Left := formleft;
467
if sformheight = '' then formheight:=400
468
else formheight := strtoint(sformheight);
470
if sformwidth = '' then formwidth:=400
471
else formwidth := strtoint(sformwidth);
473
if formheight<400 then formheight:=400;
474
if formwidth<400 then formheight:=400;
475
if showopts='' then showopts:='false';
476
if showopts='true' then
478
mitShowOptions.Checked:=true;
479
pnlAdditionalOptions.Visible :=true;
480
frmMain.height := formheight;
481
frmMain.width := formwidth;
486
mitShowOptions.Checked:=false;
487
pnlAdditionalOptions.Visible :=false;
488
frmMain.height := formheight;
489
frmMain.width := formwidth;
494
destfolder.text := getconfigvalue('general/destfolder'); // get destination folder
495
if destfolder.text='' then DestFolder.Text:= getmydocumentspath();
496
rememberlast := getconfigvalue('general/rememberlast');
499
// check 2 pass encoding
500
pass2encoding:=getconfigvalue('general/pass2');
501
if pass2encoding='' then cbx2Pass.checked:=false;
502
if pass2encoding='true' then cbx2Pass.checked:=true;
504
// check pause before finished
505
pausescript:=getconfigvalue('general/pause');
506
if pausescript='' then
508
pausescript:= 'true';
509
setconfigvalue('general/pause',pausescript);
511
if pausescript='true' then
512
mitPauseOnFinish.Checked:=true
514
mitPauseOnFinish.Checked:=false;
516
playscript:=getconfigvalue('general/playsound');
517
if playscript='' then
520
setconfigvalue('general/playsound',playscript);
522
if playscript='true' then
523
mitplaysoundOnFinish.Checked:=true
525
mitplaysoundOnFinish.Checked:=false;
529
// check for multithreading
530
multithreading:=getconfigvalue('general/multithreading');
536
// clean up and shut down
537
procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
541
if rememberlast = 'true' then // save destination folder
542
setconfigvalue('general/destfolder',destfolder.text);
544
s := presetbox.text; // save default preset
545
if s <> '' then setconfigvalue('general/currentpreset',s);
547
if mitShowOptions.Checked then // save show mnuOptions
548
setconfigvalue('general/showoptions','true')
550
setconfigvalue('general/showoptions','false');
552
if mitPauseOnFinish.Checked then // save pause on finish
553
setconfigvalue('general/pause','true')
555
setconfigvalue('general/pause','false');
558
if mitPlaySoundOnFinish.Checked then // save pause on finish
559
setconfigvalue('general/playsound','true')
561
setconfigvalue('general/playsound','false');
564
if cbx2Pass.Checked then // save 2 pass
565
setconfigvalue('general/pass2','true')
567
setconfigvalue('general/pass2','false');
569
// save window position and size
570
setconfigvalue('window/height',inttostr(frmMain.height));
571
setconfigvalue('window/width',inttostr(frmMain.width));
572
setconfigvalue('window/top',inttostr(frmMain.Top));
573
setconfigvalue('window/left',inttostr(frmMain.Left));
575
presetsfile.Free; // cleanup
579
// get the params from the preset
580
function TfrmMain.getpresetparams(presetname:string):string;
582
paramnode : tdomnode;
586
if presets.FindNode(presetname).FindNode('params').HasChildNodes then
588
paramnode:=presets.FindNode(presetname).FindNode('params').FindNode('#text');
589
param:=paramnode.NodeValue;
597
// get the category from the preset
598
function TfrmMain.getpresetcategory(presetname:string):string;
604
if presetname <> '' then
607
if presets.FindNode(presetname).FindNode('category').HasChildNodes then
609
catnode:=presets.FindNode(presetname).FindNode('category').FindNode('#text');
610
category:=catnode.NodeValue;
619
// get the extension of the preset
620
function TfrmMain.getpresetextension(presetname:string):string;
622
result:=presets.FindNode(presetname).FindNode('extension').FindNode('#text').NodeValue;
626
// get the name of the selected preset
627
function TfrmMain.getcurrentpresetname(currentpreset:string):string;
630
node,subnode: tdomnode;
632
for i:= 0 to presets.childnodes.count -1 do
634
node := presets.childnodes.item[i];
635
subnode:= node.FindNode('label');
636
if currentpreset = subnode.findnode('#text').nodevalue then
637
result := node.nodename;
642
// clear and load the preset box with current list
643
procedure TfrmMain.populatepresetbox(selectedcategory:string);
647
node,subnode, catnode,catsubnode : tdomnode;
648
category,presetcategory: string;
650
selectedcategory:=trim(selectedcategory);
652
categorybox.items.add('------');
653
for i:= 0 to presets.ChildNodes.Count -1 do
656
node:= presets.ChildNodes.item[i];
657
subnode:= node.FindNode('category');
658
category:=subnode.findnode('#text').NodeValue;
659
category:=trim(category)
664
for j:= 0 to categorybox.Items.Count-1 do
665
if categorybox.Items[j]=category then
667
if not ispresent then
668
categorybox.Items.Add(category);
673
for I:= 0 to categorybox.Items.Count -1 do
674
if categorybox.items[i]=selectedcategory then
676
categorybox.ItemIndex:=i;
682
if selectedcategory='------' then
685
category:=trim(categorybox.Text);
687
for i:= 0 to presets.ChildNodes.Count -1 do
690
node:= presets.ChildNodes.item[i];
691
subnode:= node.FindNode('label');
692
catnode:= presets.ChildNodes.item[i];
693
catsubnode:= catnode.FindNode('category');
694
presetcategory:=catsubnode.FindNode('#text').NodeValue;
698
if category = '' then
700
presetbox.items.add(subnode.findnode('#text').NodeValue)
704
if (presetcategory = category) then
706
presetbox.items.add(subnode.findnode('#text').NodeValue);
710
presetbox.sorted:=true;
711
presetbox.sorted:=false;
715
procedure TfrmMain.categoryboxChange(Sender: TObject);
718
node,subnode, catnode,catsubnode : tdomnode;
719
selectedcategory, category,presetcategory: string;
722
selectedcategory:=categorybox.Text;
725
if selectedcategory='------' then
728
category:=trim(categorybox.Text);
730
for i:= 0 to presets.ChildNodes.Count -1 do
733
node:= presets.ChildNodes.item[i];
734
subnode:= node.FindNode('label');
736
catnode:= presets.ChildNodes.item[i];
737
catsubnode:= catnode.FindNode('category');
738
presetcategory:=catsubnode.FindNode('#text').NodeValue;
743
if category = '' then
744
presetbox.items.add(subnode.findnode('#text').NodeValue)
746
if (presetcategory = category) then
747
presetbox.items.add(subnode.findnode('#text').NodeValue);
753
presetbox.sorted:=true;
754
presetbox.sorted:=false;
758
procedure TfrmMain.edtCropBottomChange(Sender: TObject);
763
i:=strtoint(edtcropbottom.text);
765
edtcropbottom.text:='0';
771
procedure TfrmMain.edtCropLeftChange(Sender: TObject);
776
i:=strtoint(edtcropleft.text);
778
edtcropleft.text:='0';
784
procedure TfrmMain.edtCropRightChange(Sender: TObject);
789
i:=strtoint(edtcropright.text);
791
edtcropright.text:='0';
797
procedure TfrmMain.edtCropTopChange(Sender: TObject);
802
i:=strtoint(edtcroptop.text);
804
edtcroptop.text:='0';
809
procedure TfrmMain.edtSeekMMChange(Sender: TObject);
813
procedure TfrmMain.Button1Click(Sender: TObject);
816
// preview button clicked
817
procedure TfrmMain.btnPreviewClick(Sender: TObject);
820
btnConvertClick(Self);
824
procedure TfrmMain.PresetBoxChange(Sender: TObject);
827
currentpreset:string;
829
currentpreset := getcurrentpresetname(presetbox.Text);
831
// destdir:= getpresetdestdir(currentpreset); // get dest folder from preset
832
if destdir <> '' then destfolder.text:= destdir;
833
if destfolder.Text='' then destfolder.text := getconfigvalue('general/destfolder');
834
if destfolder.text='' then DestFolder.Text:= getmydocumentspath();
839
procedure TfrmMain.launchbrowser(URL:string);
848
if fileexists('/usr/bin/konqueror') then s:='/usr/bin/konqueror';
849
if fileexists('/usr/bin/mozilla-firefox') then s:='/usr/bin/mozilla-firefox';
850
if fileexists('/usr/bin/firefox') then s:='/usr/bin/firefox';
851
if fileexists('/usr/bin/sensible-browser') then s:='/usr/bin/sensible-browser';
854
Showmessage('More information can be found at ' + URL);
858
launcher := tprocess.Create(nil);
859
launcher.CommandLine:= s + ' ' + URL;
865
ShellExecute(self.Handle,'open',PChar(URL),nil,nil, SW_SHOWNORMAL);
870
procedure TfrmMain.LaunchPdf(pdffile:string);
879
if fileexists('/usr/bin/evince') then s:='/usr/bin/evince';
880
if fileexists('/usr/bin/kpdf') then s:='/usr/bin/kpdf';
881
if fileexists('/usr/bin/xpdf') then s:='/usr/bin/xpdf';
882
if fileexists('/usr/bin/acroread') then s:='/usr/bin/acroread';
885
Showmessage('More information can be found at ' + pdffile);
889
launcher := tprocess.Create(nil);
890
launcher.CommandLine:= s + ' ' + pdffile;
896
ShellExecute(self.Handle,'open',PChar(pdffile),nil,nil, SW_SHOWNORMAL);
900
// set a value in the config file
901
procedure TfrmMain.setconfigvalue(key:string;value:string);
905
cfg := TXMLConfig.create(presetspath+'cfg.xml');
906
cfg.SetValue(key,value);
910
// get a value from the config file
911
function TfrmMain.getconfigvalue(key:string): string;
915
cfg := TXMLConfig.create(presetspath+'cfg.xml');
916
result := cfg.GetValue(key, '');
920
// get the user's desktop path
921
function TfrmMain.GetDeskTopPath() : string ;
927
SHGetSpecialFolderLocation(frmMain.Handle,CSIDL_DESKTOPDIRECTORY , ppidl);
928
SetLength(Result, MAX_PATH);
929
if not SHGetPathFromIDList(ppidl, PChar(Result)) then
930
raise exception.create('SHGetPathFromIDList failed : invalid pidl');
931
SetLength(Result, lStrLen(PChar(Result)));
936
result := GetEnvironmentVariable('HOME') + DirectorySeparator + 'Desktop';
940
// get the user's document's path
941
function TfrmMain.GetMydocumentsPath() : string ;
947
SHGetSpecialFolderLocation(frmMain.Handle,CSIDL_PERSONAL , ppidl);
948
SetLength(Result, MAX_PATH);
949
if not SHGetPathFromIDList(ppidl, PChar(Result)) then
950
raise exception.create('SHGetPathFromIDList failed : invalid pidl');
951
SetLength(Result, lStrLen(PChar(Result)));
956
result := GetEnvironmentVariable('HOME') ;
960
// get the user's application data path
961
function TfrmMain.GetappdataPath() : string ;
967
SHGetSpecialFolderLocation(frmMain.Handle,CSIDL_APPDATA , ppidl);
968
SetLength(Result, MAX_PATH);
969
if not SHGetPathFromIDList(ppidl, PChar(Result)) then
970
raise exception.create('SHGetPathFromIDList failed : invalid pidl');
971
SetLength(Result, lStrLen(PChar(Result)));
976
result := GetEnvironmentVariable('HOME') ;
980
// get windows version
982
function TfrmMain.GetWIn32System(): Integer;
984
osVerInfo: TOSVersionInfo;
985
majorVer, minorVer: Integer;
987
Result := cOsUnknown;
988
{ set operating system type flag }
989
osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
990
if GetVersionEx(osVerInfo) then
992
majorVer := osVerInfo.dwMajorVersion;
993
minorVer := osVerInfo.dwMinorVersion;
994
case osVerInfo.dwPlatformId of
995
VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
997
if majorVer <= 4 then
999
else if (majorVer = 5) and (minorVer = 0) then
1000
Result := cOsWin2000
1001
else if (majorVer = 5) and (minorVer = 1) then
1004
Result := cOsUnknown;
1006
VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
1008
if (majorVer = 4) and (minorVer = 0) then
1010
else if (majorVer = 4) and (minorVer = 10) then
1012
if osVerInfo.szCSDVersion[1] = 'A' then
1013
Result := cOsWin98SE
1017
else if (majorVer = 4) and (minorVer = 90) then
1020
Result := cOsUnknown;
1023
Result := cOsUnknown;
1027
Result := cOsUnknown;
1032
procedure TfrmMain.ChooseFolderBtnClick(Sender: TObject);
1034
selectdirectorydialog1.Title:= rsSelectDirectory;
1035
if SelectDirectoryDialog1.execute then
1036
DestFolder.Text := SelectDirectoryDialog1.FileName;
1040
// drop files into list
1041
procedure TfrmMain.FormDropFiles(Sender: TObject; const FileNames: array of String
1044
numfiles, i:integer;
1046
numfiles := high(Filenames);
1047
for i:= 0 to numfiles do
1048
filelist.Items.add(Filenames[i]);
1051
// add files to the list
1052
procedure TfrmMain.btnAddClick(Sender: TObject);
1054
dlgOpenFile.Title:=rsSelectVideoFiles;
1055
dlgOpenFile.InitialDir := getconfigvalue('general/addfilesfolder');
1056
if dlgOpenFile.Execute then
1058
setconfigvalue('general/addfilesfolder',dlgOpenFile.InitialDir);
1059
filelist.items.AddStrings(dlgOpenFile.Files);
1063
// remove a file from the list
1064
procedure TfrmMain.btnRemoveClick(Sender: TObject);
1069
while i< filelist.Items.Count do
1070
if filelist.Selected[i] then
1071
filelist.Items.Delete(i)
1076
// clear the file list
1077
procedure TfrmMain.btnClearClick(Sender: TObject);
1082
procedure TfrmMain.lblCropRight1Click(Sender: TObject);
1087
procedure TfrmMain.edtSeekHHChange(Sender: TObject);
1092
// filelist on key up
1093
procedure TfrmMain.filelistKeyUp(Sender: TObject; var Key: Word;
1094
Shift: TShiftState);
1102
while i< filelist.Items.Count do
1103
if filelist.Selected[i] then
1104
filelist.Items.Delete(i)
1114
// menu: edit the presets
1115
procedure TfrmMain.mitPresetsClick(Sender: TObject);
1117
frmEditPresets.show;
1120
// menu: edit preferences
1121
procedure TfrmMain.mitPreferencesClick(Sender: TObject);
1123
frmPreferences.show;
1126
//menu: help documentation
1127
procedure TfrmMain.mitDocsClick(Sender: TObject);
1131
language:=leftstr(lang,2);
1134
if fileexists('/usr/share/doc/winff/WinFF.' + language + '.pdf.gz') then s:='/usr/share/doc/winff/WinFF.' + language + '.pdf.gz';
1135
if fileexists('/usr/share/doc/winff/WinFF.' + language + '.pdf') then s:='/usr/share/doc/winff/WinFF.' + language + '.pdf';
1136
if fileexists('/usr/share/winff/WinFF.' + language + '.pdf') then s:='/usr/share/winff/WinFF.' + language + '.pdf';
1137
if fileexists('/usr/share/winff/WinFF.' + language + '.pdf.gz') then s:='/usr/share/winff/WinFF.' + language + '.pdf.gz';
1138
if fileexists('/usr/share/doc/packages/winff/WinFF.' + language + '.pdf.gz') then s:='/usr/share/doc/packages/winff/WinFF.' + language + '.pdf.gz';
1139
if fileexists('/usr/share/doc/packages/winff/WinFF.' + language + '.pdf') then s:='/usr/share/doc/packages/winff/WinFF.' + language + '.pdf';
1142
s := '/usr/share/doc/winff/WinFF.en.pdf.gz';
1143
if fileexists('/usr/share/doc/winff/WinFF.en.pdf') then s:='/usr/share/doc/winff/WinFF.en.pdf';
1144
if fileexists('/usr/share/winff/WinFF.en.pdf') then s:='/usr/share/winff/WinFF.en.pdf';
1145
if fileexists('/usr/share/winff/WinFF.en.pdf.gz') then s:='/usr/share/winff/WinFF.en.pdf.gz';
1146
if fileexists('/usr/share/doc/packages/winff/WinFF.en.pdf.gz') then s:='/usr/share/doc/packages/winff/WinFF.en.pdf.gz';
1147
if fileexists('/usr/share/doc/packages/winff/WinFF.en.pdf') then s:='/usr/share/doc/packages/winff/WinFF.en.pdf';
1151
s := extraspath + 'Docs\WinFF.' + language + '.pdf';
1152
if not (fileexists(s)) then s := extraspath + 'Docs\WinFF.en.pdf';
1158
procedure TfrmMain.mitForumsClick(Sender: TObject);
1161
launchbrowser('http://www.winff.org/forums/');
1165
procedure TfrmMain.mitWinffClick(Sender: TObject);
1168
launchbrowser('http://www.winff.org/');
1172
procedure TfrmMain.MenuItem2Click(Sender: TObject);
1177
// menu: exit the program
1178
procedure TfrmMain.mitExitClick(Sender: TObject);
1183
procedure TfrmMain.mitPlaySoundonFinishClick(Sender: TObject);
1185
if mitplaysoundOnFinish.Checked then
1187
mitplaysoundOnFinish.checked:=false;
1192
mitplaysoundOnFinish.checked:=true;
1197
// menu: import preset
1198
procedure TfrmMain.mitImportPresetClick(Sender: TObject);
1200
dlgOpenPreset.Title:=rsSelectPresetFile;
1201
dlgOpenPreset.InitialDir:=GetMydocumentsPath();
1202
if dlgOpenPreset.Execute then
1203
importpresetfromfile(dlgOpenPreset.FileName);
1208
procedure TfrmMain.mitAboutClick(Sender: TObject);
1213
// menu: show / hide additional mnuOptions
1214
procedure TfrmMain.mitShowOptionsClick(Sender: TObject);
1216
if not mitShowOptions.Checked then
1218
frmMain.Height := frmMain.Height + pnlAdditionalOptions.Height;
1219
pnlAdditionalOptions.Visible := True;
1220
//Constraints.MinHeight := Constraints.MinHeight + pnlAdditionalOptions.Height;
1222
mitShowOptions.Checked:=true;
1226
//Constraints.MinHeight := Constraints.MinHeight - pnlAdditionalOptions.Height;
1227
pnlAdditionalOptions.visible := false;
1228
frmMain.Height := frmMain.Height - pnlAdditionalOptions.Height;
1230
mitShowOptions.Checked:=false;
1234
edtAspectRatio.Clear;
1236
audsamplingrate.Clear;
1239
mitDisplayCmdline.Checked:=false;
1240
commandlineparams.Clear;
1243
// Application.ProcessMessages; // Should repaint the form like invalidate
1244
Invalidate; //Why not use Invalidate itself?
1247
// menu: shutdown on finish
1248
procedure TfrmMain.mitShutdownOnFinishClick(Sender: TObject);
1250
if mitShutdownOnFinish.Checked then
1252
mitShutdownOnFinish.checked:=false;
1256
mitPauseOnFinish.checked:=false;
1257
pausescript:='false';
1258
mitShutdownOnFinish.Checked:=true;
1262
// menu: pause on finish
1263
procedure TfrmMain.mitPauseOnFinishClick(Sender: TObject);
1265
if mitPauseOnFinish.Checked then
1267
mitPauseOnFinish.checked:=false;
1268
pausescript:='false'
1272
mitPauseOnFinish.checked:=true;
1273
pausescript:='true';
1274
mitShutdownOnFinish.Checked:=false;
1278
// menu: display commandline
1279
procedure TfrmMain.mitDisplayCmdlineClick(Sender: TObject);
1281
mitDisplayCmdline.Checked:= not mitDisplayCmdline.Checked;
1284
// btnPlay the selected file
1285
procedure TfrmMain.btnPlayClick(Sender: TObject);
1288
filenametoplay: string;
1289
PlayProcess: TProcess;
1292
playprocess:= TProcess.Create(nil);
1294
if not fileexists(ffplay) then
1296
showmessage(rsCouldNotFindFFplay);
1300
if filelist.Items.Count = 1 then
1301
filelist.Selected[0]:=true;
1304
while i< filelist.Items.Count do
1305
if filelist.Selected[i] then
1307
filenametoplay:=filelist.Items[i];
1312
if filenametoplay <>'' then
1314
PlayProcess.CommandLine:=ffplay + ' "' + filenametoplay+'"' ;
1315
playProcess.Execute;
1321
// Start Conversions
1322
procedure TfrmMain.btnConvertClick(Sender: TObject);
1325
cb,ct,cl,cr:integer;
1326
pn, extension, params, commandline, command, filename,batfile, passlogfile, basename:string;
1327
qterm, ffmpegfilename,ffplayfilename, usethreads, numthreads, deinterlace, nullfile, titlestring, priority:string;
1328
script: tstringlist;
1330
scriptprocess:tprocess;
1331
scriptpriority:tprocesspriority;
1332
ignorepreview:boolean;
1335
scriptprocess:= TProcess.Create(nil);
1337
priority := getconfigvalue('general/priority');
1338
if priority= unit4.rspriorityhigh then scriptpriority:=pphigh
1339
else if priority= unit4.rsprioritynormal then scriptpriority:=ppnormal
1340
else if priority= unit4.rspriorityidle then scriptpriority:=ppidle
1341
else scriptpriority:=ppnormal;
1342
scriptprocess.Priority:= scriptpriority;
1345
script:= TStringList.Create;
1346
{$ifdef win32}if usechcp = 'true' then script.Add('chcp ' + inttostr(ansicodepage));{$endif}
1347
{$ifdef unix}script.Add('#!/bin/sh');{$endif}
1349
{$ifdef win32}ffmpegfilename:='"' + ffmpeg + '"';{$endif}
1350
{$ifdef unix}ffmpegfilename:=ffmpeg;{$endif}
1351
{$ifdef win32}ffplayfilename:='"' + ffplay + '"';{$endif}
1352
{$ifdef unix}ffplayfilename:=ffplay;{$endif}
1353
{$ifdef win32}nullfile:='"NUL.avi"';{$endif}
1354
{$ifdef unix}nullfile:='/dev/null';{$endif}
1357
if multithreading='true' then
1359
numthreads := trim(getconfigvalue('general/numberofthreads'));
1360
if numthreads = '' then numthreads := '2';
1361
usethreads := ' -threads ' + numthreads + ' ';
1363
else usethreads:='';
1365
if cbxDeinterlace.Checked then deinterlace := ' -deinterlace '
1366
else deinterlace:='';
1368
if not fileexists(ffmpeg) then
1370
showmessage(rsCouldnotFindFFplay);
1374
pn:=getcurrentpresetname(presetbox.Text);
1377
showmessage(rsPleaseSelectAPreset);
1380
if filelist.Items.Count=0 then
1382
showmessage(rsPleaseAdd1File);
1385
params:=getpresetparams(pn);
1386
extension:=getpresetextension(pn);
1387
frmScript.memo1.lines.Clear;
1389
// trim everything up
1390
commandlineparams.text := trim(commandlineparams.Text);
1391
vidbitrate.Text := trim(vidbitrate.Text);
1392
vidframerate.text := trim(vidframerate.Text);
1393
VidsizeX.text := trim(VidsizeX.Text);
1394
VidsizeY.text := trim(VidsizeY.Text);
1395
edtAspectRatio.Text := trim(edtAspectRatio.text);
1396
audbitrate.Text := trim(audbitrate.Text);
1397
audsamplingrate.Text := trim(audsamplingrate.Text);
1398
audchannels.Text:=trim(audchannels.Text);
1399
edtCropBottom.Text:=trim(edtCropbottom.text);
1400
edtCropTop.Text:=trim(edtCropTop.text);
1401
edtCropleft.Text:=trim(edtCropleft.text);
1402
edtCropright.Text:=trim(edtCropright.text);
1403
edtVolume.Text:=trim(edtVolume.Text);
1404
edtAudioSync.Text:=trim(edtAudioSync.Text);
1407
// replace preset params if mnuOptions specified
1408
commandline := params;
1409
if vidbitrate.Text <> '' then
1410
commandline:=replaceparam(commandline,'-b','-b ' + vidbitrate.text+'k');
1411
if vidframerate.Text <> '' then
1412
commandline:=replaceparam(commandline,'-r','-r ' + vidframerate.Text);
1414
// Inserting Crop Routine here as per Issue 77 on code.google.com
1415
// Changed by Ian V1.3
1418
if edtCropBottom.Text <> '' then
1420
cb:=strtoint(edtcropbottom.text);
1421
if cb mod 2 = 1 then cb := cb-1;
1422
edtcropbottom.text := inttostr(cb);
1423
if edtcropbottom.text <> '0' then commandline := commandline + ' -cropbottom ' + edtCropBottom.Text + ' ';
1426
if edtCropTop.Text <> '' then
1428
ct:=strtoint(edtcroptop.text);
1429
if ct mod 2 = 1 then ct := ct-1;
1430
edtcroptop.text := inttostr(ct);
1431
if edtcroptop.text <> '0' then commandline += ' -croptop ' + edtCropTop.Text + ' ';
1434
if edtCropLeft.Text <> '' then
1436
cl:=strtoint(edtcropleft.text);
1437
if cl mod 2 = 1 then cl := cl-1;
1438
edtcropleft.text := inttostr(cl);
1439
if edtcropleft.text <> '0' then commandline += ' -cropleft ' + edtCropLeft.Text + ' ';
1442
if edtCropRight.Text <> '' then
1444
cr:=strtoint(edtcropright.text);
1445
if cr mod 2 = 1 then cr := cr-1;
1446
edtcropright.text := inttostr(cr);
1447
if edtcropright.text <> '0' then commandline += ' -cropright ' + edtCropRight.Text + ' ';
1452
if (VidsizeX.Text <>'') AND (VidsizeY.Text <>'') then
1455
//commandline:=replaceparam(commandline,'-s','-s ' + VidsizeX.Text + 'x' + VidsizeY.Text);
1457
commandline:=replaceparam(commandline,'-s','');
1458
commandline += ' -s ' + VidsizeX.Text + 'x' + VidsizeY.Text + ' ';
1462
if edtAspectRatio.Text <> '' then
1463
commandline:=replaceparam(commandline,'-aspect','-aspect ' + edtAspectRatio.Text);
1464
if audbitrate.Text <> '' then
1465
commandline:=replaceparam(commandline,'-ab','-ab ' + audbitrate.Text+'k');
1466
if audsamplingrate.Text <> '' then
1467
commandline:=replaceparam(commandline,'-ar','-ar ' + audsamplingrate.Text);
1468
if audchannels.Text <> '' then
1469
commandline:=replaceparam(commandline,'-ac','-ac ' + audchannels.Text);
1471
// changes for winff 1.3
1473
ignorepreview := false;
1474
if edtVolume.Text <> '' then
1475
commandline:=replaceparam(commandline,'-vol','-vol ' + edtVolume.Text);
1476
if edtAudioSync.Text <> '' then
1477
commandline:=replaceparam(commandline,'-async','-async ' + edtAudioSync.Text);
1482
if edtSeekHH.Value + edtSeekMM.Value + edtSeekSS.Value > 0 then
1484
ignorepreview := true;
1485
if (edtSeekMM.Value < 10) and (length(edtSeekMM.Text)<2) then edtSeekMM.Text := '0' + edtSeekMM.Text;
1486
if (edtSeekSS.Value < 10) and (length(edtSeekSS.Text)<2) then edtSeekSS.Text := '0' + edtSeekSS.Text;
1488
commandline:=replaceparam(commandline,'-ss','-ss ' + edtSeekHH.Text + ':' + edtSeekMM.Text + ':' + edtSeekSS.Text);
1491
if edtTTRHH.Value + edtTTRMM.Value + edtTTRSS.Value > 0 then
1493
ignorepreview := true;
1494
if (edtTTRMM.Value < 10) and (length(edtTTRMM.Text)<2) then edtTTRMM.Text := '0' + edtTTRMM.Text;
1495
if (edtTTRSS.Value < 10) and (length(edtTTRSS.Text)<2) then edtTTRSS.Text := '0' + edtTTRSS.Text;
1497
commandline:=replaceparam(commandline,'-t','-t ' + edtTTRHH.Text + ':' + edtTTRMM.Text + ':' + edtTTRSS.Text);
1501
if commandlineparams.Text <> '' then
1502
commandline += ' ' + commandlineparams.text;
1505
// if -ss and -t are already set, ignore the following parameter.
1506
if (preview = true) and (ignorepreview = false) then
1508
commandline += ' -ss 00:01:00 -t 00:00:30';
1514
batfile := 'ff' + FormatDateTime('yymmddhhnnss',thetime) +
1515
{$ifdef win32}'.bat'{$endif}
1516
{$ifdef unix}'.sh'{$endif} ;
1518
for i:=0 to filelist.Items.Count - 1 do
1520
filename := filelist.items[i];
1521
basename := extractfilename(filename);
1522
// resolve issues with embedded quote marks in filename to be converted. issue 38
1524
filename := StringReplace(filename,'"','\"',[rfReplaceAll]);
1527
for j:= length(basename) downto 1 do
1529
if basename[j] = #46 then
1531
basename := leftstr(basename,j-1);
1533
basename := StringReplace(basename,'"','\"',[rfReplaceAll]);
1540
{$ifdef win32}titlestring:='title ' + rsConverting + ' ' + extractfilename(filename) +
1541
' ('+inttostr(i+1)+'/'+ inttostr(filelist.items.count)+')';{$endif}
1542
{$ifdef unix}titlestring:='echo -n "\033]0; ' + rsConverting +' ' + basename +
1543
' ('+inttostr(i+1)+'/'+ inttostr(filelist.items.count)+')'+'\007"';{$endif}
1544
script.Add(titlestring);
1546
passlogfile := destfolder.Text + DirectorySeparator + basename + '.log';
1548
if cbx2Pass.Checked = false then
1550
command := ffmpegfilename + usethreads + ' -i "' + filename + '" ' + deinterlace + commandline + ' "' +
1551
destfolder.Text + DirectorySeparator + basename +'.' + extension+ '"';
1552
script.Add(command);
1554
else if cbx2Pass.Checked = true then
1556
command := ffmpegfilename + usethreads + ' -i "' + filename + '" ' + deinterlace + commandline + ' -an'
1557
+ ' -passlogfile "' + passlogfile + '"' + ' -pass 1 ' + ' -y ' + nullfile ;
1558
script.Add(command);
1559
command := ffmpegfilename + usethreads + ' -y -i "' + filename + '" ' + deinterlace + commandline + ' -passlogfile "'
1560
+ passlogfile + '"' + ' -pass 2 ' + ' "' + destfolder.Text + DirectorySeparator + basename +'.'
1562
script.add(command);
1566
script.add(ffplayfilename + ' "' + destfolder.Text + DirectorySeparator + basename +'.'+ extension+ '"');
1570
// finish off command
1573
if (pausescript='true') and (preview=false) then
1576
script.Add('pause');
1579
script.Add('read -p "' + rsPressEnter + '" dumbyvar');
1582
//shutdown when finnshed
1583
if mitShutdownOnFinish.Checked and (pausescript='false') then
1584
{$ifdef win32}script.Add('shutdown.exe -s');{$endif}
1585
{$ifdef unix}script.Add('shutdown now');{$endif}
1587
// remove preview file if exists
1590
{$ifdef win32}script.add('del ' + '"' + destfolder.Text + DirectorySeparator + basename +'.'+ extension+ '"');{$endif}
1591
{$ifdef unix}script.add('rm ' + '"' + destfolder.Text + DirectorySeparator + basename +'.'+ extension+ '"');{$endif}
1594
// remove batch file on completion
1595
{$ifdef win32}script.Add('del ' + '"' + presetspath + batfile + '"');{$endif}
1596
{$ifdef unix}script.Add('rm ' + '"' + presetspath + batfile+ '"');{$endif}
1599
if not mitDisplayCmdline.Checked then
1601
script.SaveToFile(presetspath+batfile);
1603
fpchmod(presetspath + batfile,&777);
1607
qterm := '"' + terminal + '"';
1610
{$ifdef unix}qterm := terminal;{$endif}
1612
{$ifdef win32}scriptprocess.commandline:= qterm + ' ' + termoptions + ' "' + presetspath + batfile + '"';{$endif}
1613
{$ifdef unix}scriptprocess.commandline:= qterm + ' ' + termoptions + ' ' + presetspath + batfile + ' &'; {$endif}
1615
scriptprocess.execute;
1619
// if continue pressed, attempt to execute user modified script;
1620
frmScript.Memo1.Lines:=script;
1621
frmScript.scriptfilename:= presetspath + batfile;
1622
resmod := frmScript.ShowModal;
1623
if resmod = 1 then // Continue Clicked;
1628
fpchmod(presetspath + batfile,&777);
1632
qterm := '"' + terminal + '"';
1635
{$ifdef unix}qterm := terminal;{$endif}
1637
{$ifdef win32}scriptprocess.commandline:= qterm + ' ' + termoptions + ' "' + presetspath + batfile + '"';{$endif}
1638
{$ifdef unix}scriptprocess.commandline:= qterm + ' ' + termoptions + ' ' + presetspath + batfile + ' &'; {$endif}
1640
scriptprocess.execute;
1646
// try // to set dest directory in preset
1647
// setpresetdestdir(pn,destfolder.text);
1652
// replace a paramter from a commandline
1653
function TfrmMain.replaceparam(commandline:string; param:string; replacement:string):string;
1655
i,startpos,endpos: integer;
1658
startpos:=pos(param +' ', commandline);
1659
endpos:=length(commandline)+1;
1660
if startpos <> 0 then
1662
for I:=startpos+1 to length(commandline)-1 do
1663
if commandline[i]='-' then
1668
delete(commandline,startpos,endpos-startpos);
1669
commandline:=leftstr(commandline,startpos)+replacement+' '+rightstr(commandline,length(commandline)-startpos);
1672
commandline+= ' ' + replacement;
1673
result:=commandline;
1676
procedure TfrmMain.VidbitrateChange(Sender: TObject);
1681
// import a preset from a file
1682
procedure TfrmMain.importpresetfromfile(presetfilename: string);
1684
importfile: txmldocument;
1685
importedpreset: tdomelement;
1687
replaceall: boolean = false;
1688
removepreset: boolean = false;
1689
nodeexists:boolean = false;
1690
newnode,labelnode,paramsnode,extensionnode,categorynode,
1691
textl,textp,texte,textc, node: tdomnode;
1692
nodename,nodelabel,nodeext,testchars:string;
1694
if not fileexists(presetfilename) then
1696
showmessage(rsCouldNotFindFile);
1701
importfile := TXMLdocument.Create;
1706
ReadXMLFile(importfile, presetFileName);
1707
importedpreset:=importfile.DocumentElement;
1709
showmessage(rsInvalidPreset);
1713
if importedpreset.ChildNodes.Count = 0 then exit;
1715
for j:= 0 to importedpreset.ChildNodes.Count -1 do
1718
node:= importedpreset.ChildNodes.Item[j];
1720
nodename:= node.NodeName;
1722
removepreset:=false;
1724
for i:= 0 to presets.ChildNodes.Count -1 do
1725
if presets.ChildNodes.Item[i].NodeName = nodename then nodeexists := true;
1729
if replaceall=false then reply := MessageDlg ('Replace Preset', Format(rsPresetAlreadyExist, ['"', nodename, '"']),
1730
mtConfirmation, [mbYes, mbNo, mbAll, mbCancel],0);
1731
if reply=mrCancel then exit;
1732
if reply=mrNo then continue;
1733
if reply=mrAll then replaceall := true;
1734
if (reply=mrYes) or (reply = mrAll) or (replaceall = true) then removepreset:=true;
1735
if removepreset then presets.RemoveChild(presets.FindNode(nodename));
1739
nodelabel := node.FindNode('label').FindNode('#text').NodeValue;
1742
showmessage(rsPresethasnolabel);
1748
testchars := node.FindNode('params').FindNode('#text').NodeValue;
1751
for i:= 0 to length(testchars)-1 do
1753
if (testchars[i] = #124) or (testchars[i] = #60) or (testchars[i] = #62) or
1754
(testchars[i] = #59) or (testchars[i] = #38) then
1756
showmessage(rsThePresetHasIllegalChars);
1761
for i:= 0 to presets.ChildNodes.Count -1 do
1762
if presets.ChildNodes.Item[i].findnode('label').FindNode('#text').NodeValue = nodelabel then
1764
showmessage(Format(rsPresetWithLabelExists, ['"', nodelabel, '"']));
1770
nodeext := node.FindNode('extension').FindNode('#text').NodeValue;
1773
showmessage(rsPresetHasNoExt);
1778
newnode:=presetsfile.CreateElement(nodename);
1779
presets.AppendChild(newnode);
1780
labelnode:=presetsfile.CreateElement('label');
1781
newnode.AppendChild(labelnode);
1782
paramsnode:=presetsfile.CreateElement('params');
1783
newnode.AppendChild(paramsnode);
1784
extensionnode:=presetsfile.CreateElement('extension');
1785
newnode.AppendChild(extensionnode);
1786
categorynode:=presetsfile.CreateElement('category');
1787
newnode.AppendChild(categorynode);
1789
textl:=presetsfile.CreateTextNode(nodelabel);
1790
labelnode.AppendChild(textl);
1794
textp:=presetsfile.CreateTextNode(node.FindNode('params').FindNode('#text').NodeValue);
1796
textp:=presetsfile.CreateTextNode('');
1798
paramsnode.AppendChild(textp);
1800
texte:=presetsfile.CreateTextNode(nodeext);
1801
extensionnode.AppendChild(texte);
1804
textc:=presetsfile.CreateTextNode(node.FindNode('category').FindNode('#text').NodeValue);
1806
textc:=presetsfile.CreateTextNode('');
1808
categorynode.AppendChild(textc);
1810
end; //for j = 1 to childnodes-1
1812
writexmlfile(presetsfile, presetspath + 'presets.xml'); // save the imported preset
1814
populatepresetbox('');
1819
{$ifdef win32}PODirectory := extraspath + '\languages\'{$endif};
1820
{$ifdef unix}PODirectory := '/usr/share/winff/languages/'{$endif};
1821
GetLanguageIDs(Lang, FallbackLang); // in unit gettext
1822
POFile := PODirectory + 'winff.' + Lang + '.po';
1823
if not FileExists(POFile) then
1824
POFile := PODirectory + 'winff.' + FallbackLang + '.po';
1826
if FileExists(POFile) then
1829
LRSTranslator := TPoTranslator.Create(POFile);