forked from torum/Image-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageViewer.lpr
131 lines (106 loc) · 4.19 KB
/
ImageViewer.lpr
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
program ImageViewer;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, UMain, Ufullscreen, UAbout,
LCLTranslator, lazutf8{$ifdef windows}, Windows{$endif};
{$R *.res}
var
ShowHelp:boolean;
procedure TranslateLCL;
var
Lang,FallbackLang: String;
begin
// TODO: in windows, you have to call GetUserDefaultUILanguage() API to get UI languages.
// http://sygh.hatenadiary.jp/entry/2014/05/24/181319
{
GetSystemDefaultLangID()
GetUserDefaultLangID()
GetSystemDefaultUILanguage()
GetUserDefaultUILanguage() // We need to call this. But GetLanguageIDs calls GetUserDefaultLCID.
GetSystemDefaultLCID()
GetUserDefaultLCID()
}
Lang:='';
FallbackLang:='';
LazGetLanguageIDs(Lang,FallbackLang);
//LazGetLanguageIDs(Lang,FallbackLang);
//OutputDebugString(PChar(TrimRight( 'Lang is '+ Lang + ', FallbackLang is '+ FallbackLang )));
//Debug Output: 'Lang is jp_JP FallbackLang is jp'
// What??? It supporsed to be "ja_JP"!!
//Lang := FallbackLang+'_'+Country;
//LazGetShortLanguageID(Lang);
//OutputDebugString(PChar(TrimRight( 'Lang is '+ Lang )));
//Debug Output: 'Lang is jp'
// What? not ja?
if (Lang = 'en') or (Lang = 'en_US') or (Lang = 'us')
or (FallbackLang = 'us') or (FallbackLang = 'US') or (FallbackLang = 'en') then
Lang := 'en';
if (Lang = 'ja') or (Lang = 'ja_jp') or (Lang = 'jp_JP') or (Lang = 'jp')
or (FallbackLang = 'jp') or (FallbackLang = 'JP') or (FallbackLang = 'ja') then
Lang := 'ja_JP';
if (Lang = 'ru') or (Lang = 'ru_RU') or (Lang = 'RU')
or (FallbackLang = 'ru') or (FallbackLang = 'RU') then
Lang := 'ru_RU';
SetDefaultLang(Lang,'','',false);
end;
procedure CheckAppParam;
begin
if (ParamCount > 0) then
begin
if ((ParamStr(1) = '-h') or (ParamStr(1) = '--help') or (ParamStr(1) = '/?')) then
begin
ShowHelp := true;
end;
end;
end;
begin
CheckAppParam;
if (ShowHelp) then
begin
// This creates a NEW console window.
// In order to write to original cosole is to compile as a console application
// using ($APPTYPE CONSOLE) or -WG compile/linking option.
// However, if you do, you get a console window WITH a normal form window ...
{$ifdef windows}
AllocConsole; // in Windows unit
{$endif}
IsConsole := True; // in System unit
SysInitStdIO; // in System unit
WriteLn('ImageViewer - a simple image viewer.');
WriteLn('');
WriteLn('Usage:');
WriteLn('ImageViewer [OPTION]=[VALUE] or ImageViewer [OPTION] [VALUE]');
WriteLn('');
WriteLn('Options and Values:');
WriteLn(' --fullscreen, -f (on/off) Start fullscreen at startup (default off)');
WriteLn(' --interval, -i (#) Slideshow interval in seconds (default 4 seconds)');
WriteLn(' --random, -r (on/off) Slideshow random (default on)');
WriteLn(' --repeat, -e (on/off) Slideshow repeat (default on)');
WriteLn(' --effect, -t (on/off) Slideshow transitional effect (default on)');
WriteLn(' --stretchIn, -n (on/off) Picture stretch In -fit to window/screen when the size is bigger. (default on)');
WriteLn(' --stretchOut, -o (on/off) Picture stretch Out -fit to window/screen when the size is smaller. (default off)');
WriteLn(' --includSubFolders, -u (on/off) Loads pictures in the sub folders as well when manually select a picture (default on)');
WriteLn(' --moniter, -m (#) Specify a moniter to show fullscreen slideshow (0 is the default main moniter');
WriteLn(' --stayOnTop, -y (on/off) Specify if window should stay on top (default off)');
WriteLn(' --help, -h Shows this.');
WriteLn('');
WriteLn('Useage example:');
WriteLn(' $ ImageViewer -f on -i 2 -o on -e off C:\Users\<USER>\Pictures\Wallpapers\');
Application.Initialize;
Application.ShowMainForm := False;
Application.Run;
end else
begin
TranslateLCL;
Application.Scaled:=True;
RequireDerivedFormResource:=True;
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end;
end.