Skip to content

Commit eb0e0d7

Browse files
committed
v1.2.12
1 parent 910b16c commit eb0e0d7

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

ImageViewer.lpr

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
{$R *.res}
1414

15+
var
16+
ShowHelp:boolean;
17+
1518
procedure TranslateLCL;
1619
var
1720
Lang,FallbackLang: String;
@@ -59,18 +62,27 @@ procedure TranslateLCL;
5962

6063
end;
6164

62-
65+
procedure CheckAppParam;
6366
begin
64-
65-
if (Application.ParamCount > 0) then
67+
if (ParamCount > 0) then
6668
begin
67-
if ((Application.Params[0] = '-h') or (Application.Params[0] = '--help') or (Application.Params[0] = '/?')) then
69+
if ((ParamStr(1) = '-h') or (ParamStr(1) = '--help') or (ParamStr(1) = '/?')) then
6870
begin
71+
ShowHelp := true;
72+
end;
73+
end;
74+
end;
75+
6976

77+
begin
78+
CheckAppParam;
79+
80+
if (ShowHelp) then
81+
begin
7082
// This creates a NEW console window.
7183
// In order to write to original cosole is to compile as a console application
7284
// using ($APPTYPE CONSOLE) or -WG compile/linking option.
73-
// However, if you do, you get a console window with a normal form window when execute...
85+
// However, if you do, you get a console window WITH a normal form window ...
7486
{$ifdef windows}
7587
AllocConsole; // in Windows unit
7688
{$endif}
@@ -102,17 +114,17 @@ procedure TranslateLCL;
102114
Application.ShowMainForm := False;
103115
Application.Run;
104116

105-
end;
106-
107117
end else
108118
begin
119+
109120
TranslateLCL;
110121
Application.Scaled:=True;
111122
RequireDerivedFormResource:=True;
112123
Application.Initialize;
113124
Application.ShowMainForm := False;
114125
Application.CreateForm(TfrmMain, frmMain);
115126
Application.Run;
127+
116128
end;
117129

118130
end.

umain.pas

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
macOS 10.11.6 (64bit) El Capitan: Lazarus 1.9.0 carbon trunk, FPC 3.0.4
1717
1818
TODO:
19+
preLoading image for slideshow.
1920
load playlist.
2021
more Command line options.
2122
file drop handling(win).
22-
preLoading image for slideshow.
2323
OS's power-save event aware.
2424
Modal dialog with options and playlist edit tab (drag & drop files).
2525
@@ -41,7 +41,7 @@ interface
4141
uses
4242
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
4343
LclType, LclProc, LclIntf, Menus, StdCtrls, ExtDlgs,
44-
strutils, Types, XMLConf{$ifdef windows}, Windows{$endif};
44+
strutils, Types, XMLConf{$ifdef windows}, windirs, Windows{$endif};
4545

4646
type
4747

@@ -145,6 +145,7 @@ TfrmMain = class(TForm)
145145
FiCurrentFileIndex:integer;
146146
FstrAppVer:string;
147147
FstrInitialSelectedImageFile:string;
148+
FstrInitialDir:string;
148149
procedure ShowFullScreen(blnOn: boolean);
149150
procedure SetFullScreen_Universal(blnOn: boolean);
150151
procedure SetFullScreen_Win32(blnOn: boolean);
@@ -245,7 +246,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
245246
folderfiles:TStringlist;
246247
fileSearchMask,fileFolder:string;
247248
begin
248-
FstrAppVer:='1.2.10';
249+
FstrAppVer:='1.2.12';
249250

250251
// Init Main form properties.
251252
self.Caption:=ReplaceStr(ExtractFileName(ParamStr(0)),ExtractFileExt(ParamStr(0)),'');
@@ -269,7 +270,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
269270
FOptIntervalIntSeconds:=4;
270271
FOptRandom:=true;
271272
FOptRepeat:=true;
272-
FOptFileExts:='.jpg;.jpeg;.png;.gif'; //'.jpg;.jpeg;.jpe;.png;.gif';
273+
FOptFileExts:='.jpg;.jpeg;.jpe;.png;.gif'; //'.jpg;.jpeg;.jpe;.png;.gif';
273274
FOptPlaylistExts:='.m3u;.xspf';
274275
FOptIncludeSubFolders:=true;
275276
// Be carefull when settings this. If the size is too large, the list will be empty.
@@ -294,6 +295,13 @@ procedure TfrmMain.FormCreate(Sender: TObject);
294295

295296
FstrInitialSelectedImageFile :='';
296297

298+
{$ifdef windows}
299+
FstrInitialDir := GetWindowsSpecialDir(CSIDL_MYPICTURES);
300+
{$else}
301+
// TODO:
302+
FstrInitialDir := '';
303+
{$endif}
304+
297305
// i18n
298306
MenuItemNext.Caption := resstrPlaybackNext;
299307
MenuItemBack.Caption := resstrPlaybackPrevious;
@@ -314,7 +322,6 @@ procedure TfrmMain.FormCreate(Sender: TObject);
314322
MenuItemBackgroundBlack.Caption:=resstrBackgroundBlack;
315323
MenuItemBackgroundWhite.Caption:=resstrBackgroundWhite;
316324

317-
318325
// Load settings
319326
if ForceDirectories(GetAppConfigDir(false)) then
320327
begin
@@ -348,6 +355,8 @@ procedure TfrmMain.FormCreate(Sender: TObject);
348355
FOptPlaylistExts := string(XMLConfig.GetValue('/Opts/PlaylistExts',widestring(FOptPlaylistExts)));
349356
FOptIntervalIntSeconds := XMLConfig.GetValue('/Opts/IntervalSeconds',FOptIntervalIntSeconds);
350357

358+
FstrInitialDir := string(XMLConfig.GetValue('/InitDir/Path',widestring(FstrInitialDir)));
359+
351360
// Command line parameters
352361
if Application.HasOption('h', 'help') then
353362
begin
@@ -551,7 +560,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
551560
begin
552561
f:= FileSize(ParamStr(I));
553562
// Check file size.
554-
if f >= (FOptMinimulFileSizeKiloByte * 1024) then
563+
if f >= (FOptMinimulFileSizeKiloByte) then
555564
begin
556565
FstFileList.Add(ParamStr(I));
557566
//
@@ -603,7 +612,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
603612
begin
604613
f:= FileSize(folderfiles[j]);
605614
// Check file size.
606-
if f >= (FOptMinimulFileSizeKiloByte * 1024) then
615+
if f >= (FOptMinimulFileSizeKiloByte) then
607616
begin
608617
FstFileList.Add(folderfiles[j]);
609618
end;
@@ -623,7 +632,12 @@ procedure TfrmMain.FormCreate(Sender: TObject);
623632
if ((FstFileList.Count < 1) and (FstrInitialSelectedImageFile = '')) then
624633
begin
625634
// No files are provided in the parameter string, so open "file open" dialog.
635+
636+
// Sets default dir
637+
OpenPictureDialog1.InitialDir:=FstrInitialDir;
638+
// Sets title
626639
OpenPictureDialog1.Title:=ReplaceStr(ExtractFileName(ParamStr(0)),ExtractFileExt(ParamStr(0)),'')+' - ' + resstrOpenPictures;
640+
// Open dialog
627641
if OpenPictureDialog1.Execute then
628642
begin
629643
for i:=0 to OpenPictureDialog1.Files.Count -1 do
@@ -635,12 +649,14 @@ procedure TfrmMain.FormCreate(Sender: TObject);
635649
begin
636650
f:= FileSize(OpenPictureDialog1.Files[i]);
637651
// Check file size.
638-
if f >= (FOptMinimulFileSizeKiloByte * 1024) then
652+
if f >= (FOptMinimulFileSizeKiloByte) then
639653
begin
640654
//FstFileList.Add(OpenPictureDialog1.Files[i]);
641655
if (i=0) then
642656
begin
643657
FstrInitialSelectedImageFile:=OpenPictureDialog1.Files[i];
658+
// sets init dir for next time.
659+
FstrInitialDir := ExtractFilePath(OpenPictureDialog1.Files[i]);
644660
end;
645661
FstFileList.Add(OpenPictureDialog1.Files[i]);
646662
end;
@@ -665,6 +681,10 @@ procedure TfrmMain.FormCreate(Sender: TObject);
665681
begin
666682
fileFolder:=ReplaceStr(FstFileList[0],ExtractFileName(FstFileList[0]),'');
667683
//fileFolder:=ReplaceStr(FstrInitialSelectedImageFile,ExtractFileName(FstrInitialSelectedImageFile),'');
684+
685+
// sets init dir for next time.
686+
FstrInitialDir := ExtractFilePath(FstFileList[0]);
687+
668688
// Create search mask
669689
fileSearchMask:='';
670690
for i:=0 to FstFileExtList.Count-1 do
@@ -688,7 +708,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
688708
begin
689709
f:= FileSize(folderfiles[j]);
690710
// Check file size.
691-
if f >= (FOptMinimulFileSizeKiloByte * 1024) then
711+
if f >= (FOptMinimulFileSizeKiloByte) then
692712
begin
693713
FstFileList.Add(folderfiles[j]);
694714
end;
@@ -902,6 +922,9 @@ procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
902922
XMLConfig.SetValue('/Opts/FileExts',widestring(FOptFileExts));
903923
XMLConfig.SetValue('/Opts/PlaylistExts',widestring(FOptPlaylistExts));
904924
XMLConfig.SetValue('/Opts/IntervalSeconds',FOptIntervalIntSeconds);
925+
926+
XMLConfig.SetValue('/InitDir/Path',widestring(FstrInitialDir));
927+
905928
end;
906929
end;
907930

@@ -1288,7 +1311,7 @@ procedure TfrmMain.MenuItemSlideshowInFrameClick(Sender: TObject);
12881311
FOrigBounds:= BoundsRect;
12891312
self.BorderStyle:=bsNone;
12901313
BoundsRect := FOrigBounds;
1291-
titlebarheight:=GetSystemMetrics(SM_CYCAPTION);
1314+
titlebarheight:=GetSystemMetrics(SM_CYCAPTION) + 9;
12921315
self.height := self.height + titlebarheight;
12931316
{$else}
12941317
// https://forum.lazarus.freepascal.org/index.php?topic=38675.0

0 commit comments

Comments
 (0)