-
Notifications
You must be signed in to change notification settings - Fork 2
/
unit7.pas
150 lines (128 loc) · 5.1 KB
/
unit7.pas
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
unit Unit7;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
ExtCtrls, StdCtrls, IniPropStorage,LCLTranslator,unConstants,LocalizedForms;
type
TuiJazyky = (czech,english);
{ TFormNastaveni }
TFormNastaveni = class(TLocalizedForm) // Options form
logyAplikaceNastaveni: TCheckGroup;
IniPropStorage1: TIniPropStorage;
Okbutton: TButton;
CancelButton: TButton;
PageControl1: TPageControl;
FilmScrapers: TRadioGroup;
LanguageScrapers: TRadioGroup;
jazykAplikace: TRadioGroup;
mysKoleckoOznaceni: TRadioGroup;
SerialScrapers: TRadioGroup;
Scrapers: TTabSheet;
narodniNastaveni: TTabSheet;
ostatni: TTabSheet;
procedure FormCreate(Sender: TObject);
procedure IniPropStorage1RestoreProperties(Sender: TObject);
procedure IniPropStorage1SavingProperties(Sender: TObject);
procedure jazykAplikaceSelectionChanged(Sender: TObject);
procedure OkbuttonClick(Sender: TObject);
procedure nastavStatusBar;
procedure spustReinicializaci(Data: PtrInt); // pomocná pro QueueAsyncCall
private
{ private declarations }
public
{ public declarations }
protected
procedure UpdateTranslation(ALang: String); override;
end;
var
FormNastaveni: TFormNastaveni;
uiJazyk:array[TuiJazyky] of String[2] = ('cs','en');
implementation
uses unit1, // resource string
unit8; // formScraper
{$R *.frm}
{ TFormNastaveni }
procedure TFormNastaveni.OkbuttonClick(Sender: TObject);
begin
FormNastaveni.Close;
{ nastavení aktuálního scraperu při změně konfigurace v ini souboru}
aktualniScraperFilm:=ScraperyFilm[TScraperFilm(FormNastaveni.FilmScrapers.ItemIndex)];
aktualniScraperSerial:=ScraperySerial[TScraperSerial(FormNastaveni.SerialScrapers.ItemIndex)];
aktualniScraperEpisody:=scraperyEpizody[TScraperSerial(FormNastaveni.SerialScrapers.ItemIndex)];
aktualniJazyk:=jazyky[Tjazyky(FormNastaveni.LanguageScrapers.ItemIndex)];
// reinicializace genresMovieDB during scraper language change
// - je deklarován v Unit8,line 16-22
// QueAsyncCall for keeping responsive ui :-)
Application.QueueAsyncCall(@spustReinicializaci,1);
nastavStatusBar;
end;
procedure TFormNastaveni.jazykAplikaceSelectionChanged(Sender: TObject);
var
pom:String;
begin
pom:=uiJazyk[TUiJazyky(jazykAplikace.ItemIndex)];
SetDefaultLang(pom);
Form1.UpdateTranslation(pom);
end;
procedure TFormNastaveni.FormCreate(Sender: TObject);
begin
mysKoleckoOznaceni.Items.Strings[0]:= rsHighlightIni;
mysKoleckoOznaceni.Items.Strings[1]:= rsDoNotHighlig;
// disabling imdb.com sraper due to omdbapi.com became paid
FilmScrapers.Controls[1].Enabled:=False;
if FormNastaveni.logyAplikaceNastaveni.Checked[0] then
begin
form1.frmeventLog.FileName:='eventLogMain.log';
Form1.frmeventLog.Active:=True;
end
else
begin
Form1.frmeventLog.FileName:='';
Form1.frmeventLog.Active:=False;
end;
end;
procedure TFormNastaveni.IniPropStorage1RestoreProperties(Sender: TObject);
begin
logyAplikaceNastaveni.Checked[0]:=StrToBool(
IniPropStorage1.StoredValue['mainApplicationLog']);
logyAplikaceNastaveni.Checked[1]:=StrToBool(
IniPropStorage1.StoredValue['scrappingLog']);
end;
procedure TFormNastaveni.IniPropStorage1SavingProperties(Sender: TObject);
begin
IniPropStorage1.StoredValue['mainApplicationLog']:=BoolToStr(
logyAplikaceNastaveni.Checked[0]);
IniPropStorage1.StoredValue['scrappingLog']:=BoolToStr(
logyAplikaceNastaveni.Checked[1]);
end;
procedure TFormNastaveni.nastavStatusBar;
var
PomS: String;
PomF: String;
begin
PomS:= FormNastaveni.SerialScrapers.Items[FormNastaveni.SerialScrapers.ItemIndex];
PomF:= FormNastaveni.FilmScrapers.Items[FormNastaveni.FilmScrapers.ItemIndex];
if (PomS='themoviedb.org') or (pomS='thetvdb.com') then PomS:=PomS+'('+aktualniJazyk+')';
if PomF='themoviedb.org' then PomF:=PomF+'('+aktualniJazyk+')';
Form1.StatusBar1.Panels[1].Text:=Format(rsSeriesFilms, [PomS, PomF]);
end;
procedure TFormNastaveni.spustReinicializaci(Data: PtrInt);
begin
//initGenres(genresMovieDB,
// 'https://api.themoviedb.org/3/genre/movie/list?api_key='+theMovidedbAPI+
// '&language='+aktualniJazyk,'$json("genres")() ! [.("id"), .("name")]');
InitGenresLanguageFilm[TScraperFilm(FormNastaveni.FilmScrapers.ItemIndex)](aktualniJazyk);
InitGenresLanguageSerial[TScraperSerial(FormNastaveni.SerialScrapers.ItemIndex)](aktualniJazyk);
end;
procedure TFormNastaveni.UpdateTranslation(ALang: String);
begin
inherited UpdateTranslation(ALang);
mysKoleckoOznaceni.Items.Strings[0]:= rsHighlightIni;
mysKoleckoOznaceni.Items.Strings[1]:= rsDoNotHighlig;
//nastavStatusBar; // způsobovalo podivnou chybu, po přidání lines 146,147,
// asi chyba fpc nebo lazarusu v TIniPropStorage;
logyAplikaceNastaveni.Items.Strings[0]:= rsMainApplicat;
logyAplikaceNastaveni.Items.Strings[1]:= rsScrappingLog;
end;
end.