-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainOptions.pas
760 lines (673 loc) · 26.3 KB
/
MainOptions.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
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
{ Ïðè èñïîëüçîâàíèè äàííûõ èñõîäíèêîâ èëè èõ ôðàãìåíòîâ, ññûëêà íà èñòî÷íèê
îáÿçàòåëüíà.
http://irchat.ru
Íàñòðîéêè îñíîâíîé ÷àñòè ïðîãðàììû.
}
unit MainOptions;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids, ValEdit, Contnrs, Configs, Misc;
type
TMainConfig = class(TConf)
private
procedure FillLanguagesList();
public
LangsList: TObjectList;
fntArray: array [1..3] of TFont;
PluginsNode: TConfNode;
constructor Create();
destructor Destroy(); override;
end;
TLangInfo = class
public
FileName: string;
LangName: string;
Author: string;
InfoText: string;
end;
TfrmMainOptions = class(TForm)
PageControl1: TPageControl;
tsTemplates: TTabSheet;
gbTemplates: TGroupBox;
lbTemplates1: TLabel;
lbTemplates2: TLabel;
lbTemplates3: TLabel;
lbTemplates4: TLabel;
lbTemplates5: TLabel;
lbTemplates6: TLabel;
lbTemplates7: TLabel;
lbTemplates8: TLabel;
lbTemplates9: TLabel;
memoTemplates: TMemo;
tsSounds: TTabSheet;
gbSounds: TGroupBox;
lbSoundTest: TLabel;
vleSounds: TValueListEditor;
btnSoundTest: TButton;
cbPlaySounds: TCheckBox;
tsSmiles: TTabSheet;
gbSmiles: TGroupBox;
lbSmilesCount: TLabel;
cbSmilesCloseAfterSelect: TCheckBox;
editSmilesCount: TEdit;
UpDownSmilesCount: TUpDown;
tsPlugins: TTabSheet;
gbPlugins: TGroupBox;
lbPluginInfo: TLabel;
lvPluginsList: TListView;
tsNotesGrabber: TTabSheet;
gbNotesGrabber: TGroupBox;
lbNotesGrabberReadme: TLabel;
memoGrabKeywords: TMemo;
tsNotes: TTabSheet;
gbNotes: TGroupBox;
lbNotesReadme: TLabel;
memoNotes: TMemo;
cbShowNotesOnJoin: TCheckBox;
tsMain: TTabSheet;
gbMain: TGroupBox;
cbCopySelected: TCheckBox;
cbNotifyPrivates: TCheckBox;
cbNotifyAllMessages: TCheckBox;
cbUserlistCheckboxes: TCheckBox;
cbPopupPrivate: TCheckBox;
cbUseAvatars: TCheckBox;
cbLogMessages: TCheckBox;
cbSendMsgOnCtrlEnter: TCheckBox;
tsIgnore: TTabSheet;
gbIgnore: TGroupBox;
lbIgnore1: TLabel;
lbIgnore2: TLabel;
lbIgnore3: TLabel;
memoIgnore: TMemo;
tsFonts: TTabSheet;
gbFonts: TGroupBox;
lbFontSelect: TListBox;
tsFastMsg: TTabSheet;
gbFastMsg: TGroupBox;
lbFM1: TLabel;
memoFastMsg: TMemo;
tsProxy: TTabSheet;
gbProxy: TGroupBox;
gbProxyList: TGroupBox;
lbProxyHost: TLabel;
lbProxyPort: TLabel;
btnAddProxy: TButton;
btnDelProxy: TButton;
edProxyHost: TEdit;
edProxyPort: TEdit;
tsAutojoin: TTabSheet;
gbAutojoin: TGroupBox;
lbAJList: TLabel;
memoAutojoinList: TMemo;
tsMessages: TTabSheet;
gbMessages: TGroupBox;
tsLanguage: TTabSheet;
gbLanguage: TGroupBox;
listboxLangs: TListBox;
btnLoadLang: TButton;
lbLangInfo: TLabel;
lbHotkey: TLabel;
edHotkey: TEdit;
lbProxyUser: TLabel;
lbProxyPass: TLabel;
edProxyUser: TEdit;
edProxyPass: TEdit;
lbProxyType: TLabel;
cboxProxyType: TComboBox;
memoProxyList: TMemo;
procedure lbFontSelectClick(Sender: TObject);
procedure lvPluginsListSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
procedure listboxLangsClick(Sender: TObject);
procedure btnLoadLangClick(Sender: TObject);
procedure edHotkeyKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnAddProxyClick(Sender: TObject);
procedure btnDelProxyClick(Sender: TObject);
private
{ Private declarations }
SelectedLangInfo: TLangInfo;
procedure FillSoundOptions();
public
{ Public declarations }
procedure vleSoundsEditButtonClick(Sender: TObject);
procedure btnSoundTestClick(Sender: TObject);
procedure FillConfigNodes(RootNode: TConfNode);
procedure RefreshSettings(ConfNode: TConfNode);
procedure ApplySettings(ConfNode: TConfNode);
procedure OnApplySettingsHandler(Sender: TObject);
procedure ChangeLanguage();
end;
var
frmMainOptions: TfrmMainOptions;
implementation
uses Core, Sounds, IniFiles;
{$R *.dfm}
// TMainConfig
constructor TMainConfig.Create;
var
i: integer;
ConfItems: TConfItems;
begin
inherited Create();
RootNode:=TConfNode.Create(nil);
RootNode.Name:='RealChat';
RootNode.FullName:='RealChat main config';
self.AllConfItems:=TConfItems.Create('Main');
for i:=1 to 3 do
begin
fntArray[i]:=TFont.Create();
end;
RootNode.ConfItems:=TConfItems.Create(RootNode.Name);
ConfItems:=RootNode.ConfItems;
// Çàïîëíåíèå çíà÷åíèé ïî óìîë÷àíèþ
ConfItems.Add('MyFullName', 'My full name', '', 'S');
ConfItems.Add('MyNick', 'My nick', GetWinUserName(), 'S');
ConfItems.Add('MySecondNick', 'My second nick', GetWinCompName(), 'S');
//ConfItems.Add('ClientVersion', 'Client version', 'IRC client for iRC ver. 0.1', 'S');
ConfItems.Add('AvatarURL', 'Avatar URL', '', 'S');
ConfItems.Add('AwayMessage', 'Avay message', 'Ìåíÿ çäåñü íåò!', 'S');
ConfItems.Add('Version', 'Version', 'RealChat', 'S');
ConfItems.Add('QuitMessage', 'Quit message', 'RealChat - http://irchat.ru', 'S');
ConfItems.Add('Hotkey', 'Hotkey', 'Ctrl+Alt+67', 'S');
ConfItems.Add('SettingsFile', 'Settings file', 'Settings.ini', 'S');
ConfItems.Add('LanguageFile', 'Language file', '', 'S');
ConfItems.Add('SaveFilesDir', 'Patch for received files', 'Incoming', 'S');
ConfItems.Add('SmilesPath', 'Patch for smiles', 'Smiles', 'S');
ConfItems.Add('AvatarsPath', 'Patch for received avatars', 'Avatars', 'S');
ConfItems.Add('LogsPath', 'Patch for log files', 'Logs', 'S');
ConfItems.Add('PluginsPath', 'Patch for plugins', 'Plugins', 'S');
ConfItems.Add('MainForm_Top', 'MainForm Top', '100', 'I');
ConfItems.Add('MainForm_Left', 'MainForm Left', '100', 'I');
ConfItems.Add('MainForm_Height', 'MainForm Height', '400', 'I');
ConfItems.Add('MainForm_Width', 'MainForm Width', '600', 'I');
ConfItems.Add('UseAvatars', 'Use avatars', '0', 'B');
ConfItems.Add('AvatarQueryDelay', 'Delay between requests for avatar', '30', 'I');
ConfItems.Add('SmilesCount', 'Max Smiles count', '10', 'I');
ConfItems.Add('SmilesCloseAfterSelect', 'SmilesCloseAfterSelect', '1', 'B');
ConfItems.Add('CopySelected', 'Copy selected text', '1', 'B');
ConfItems.Add('NotifyPrivates', 'Notify private messages', '1', 'B');
ConfItems.Add('NotifyAllMsg', 'Notify all messages', '0', 'B');
ConfItems.Add('UserlistCheckboxes', 'UserlistCheckboxes', '0', 'B');
ConfItems.Add('IgnorePrivates', 'IgnorePrivates', '0', 'B');
ConfItems.Add('PopupPrivate', 'PopupPrivate', '0', 'B');
ConfItems.Add('ServerPageVisible', 'ServerPageVisible', '1', 'B');
ConfItems.Add('NotesPageVisible', 'NotesPageVisible', '0', 'B');
ConfItems.Add('FilesPageVisible', 'FilesPageVisible', '0', 'B');
ConfItems.Add('PlaySounds', 'PlaySounds', '0', 'B');
ConfItems.Add('LogMessages', 'Log messages', '0', 'B');
ConfItems.Add('SendMsgOnCtrlEnter', 'SendMsgOnCtrlEnter', '0', 'B');
ConfItems.Add('DisableTextColors', 'Disable text colors', '0', 'B');
ConfItems.Add('DisableSmiles', 'Disable smiles', '0', 'B');
//ConfItems.Add('NotesList', 'Notes', '', 'T');
//ConfItems.Add('TemplatesList', 'Templates', '', 'T');
ConfItems.Add('NotesKeywordsList', 'Grab notes keywords', '', 'T');
ConfItems.Add('FastMsgList', 'Notes', '', 'T');
ConfItems.Add('ProxyList', 'Proxy servers list', '', 'T');
ConfItems.Add('ChatClientsList', 'Chat clients list', '', 'T');
//ConfItems.Add('', '', '', '');
//ConfItems.Add('', '', '', '');
//ConfItems.Add('', '', '', '');
//ConfItems.Add('', '', '', '');
ConfItems.Add('fntChatText_Name', 'Chat text font Name', fntArray[1].Name, 'S');
ConfItems.Add('fntChatText_Size', 'Chat text font Size', IntToStr(fntArray[1].Size), 'I');
ConfItems.Add('fntUserList_Name', 'User list font Name', fntArray[2].Name, 'S');
ConfItems.Add('fntUserList_Size', 'User list font Size', IntToStr(fntArray[2].Size), 'I');
ConfItems.Add('fntTxtToSend_Name', 'Send text font Name', fntArray[3].Name, 'S');
ConfItems.Add('fntTxtToSend_Size', 'Send text font Size', IntToStr(fntArray[3].Size), 'I');
frmMainOptions:= TfrmMainOptions.Create(nil);
//frmMainOptions.FillConfItems(RootNode);
frmMainOptions.FillConfigNodes(RootNode);
// Fill languages list
LangsList := TObjectList.Create();
FillLanguagesList();
// Set plugins node
for i:=0 to RootNode.ChildCount-1 do
begin
if RootNode.ChildNodes[i].Name = frmMainOptions.tsPlugins.Caption then
begin
PluginsNode:=RootNode.ChildNodes[i];
Break;
end;
end;
//self['ConfFileName']:='';
end;
destructor TMainConfig.Destroy();
begin
frmMainOptions.Release();
LangsList.Free();
inherited Destroy();
end;
procedure TMainConfig.FillLanguagesList();
var
li: TLangInfo;
sr: TSearchRec;
LangIni: TMemIniFile;
sFileName, s, s2: string;
Done: boolean;
begin
s2:=self.Values['LanguageFile'];
if FindFirst(glHomePath+'\language_*.ini', faAnyFile, sr)=0 then
begin
Done:=false;
while not Done do
begin
sFileName:=glHomePath+sr.Name;
LangIni:=TMemIniFile.Create(sFileName);
s:=LangIni.ReadString('Info', 'Name', '');
if s<>'' then
begin
li:=TLangInfo.Create();
li.FileName:=sFileName;
li.LangName:=s;
li.Author:=LangIni.ReadString('Info', 'Author', '');
li.InfoText:=LangIni.ReadString('Info', 'Info', '');
self.LangsList.Add(li);
frmMainOptions.listboxLangs.AddItem(li.LangName, li);
if sr.Name=s2 then frmMainOptions.listboxLangs.Selected[frmMainOptions.listboxLangs.Count-1]:=true;
end;
FreeAndNil(LangIni);
Done := (FindNext(sr) <> 0);
end;
end;
FindClose(sr);
if s2<>'' then
begin
sFileName:=glHomePath+s2;
Core.LangIni:=TMemIniFile.Create(sFileName);
end;
end;
// === TfrmMainOptions ===
procedure TfrmMainOptions.FillSoundOptions();
var
slSoundNames: TStringList;
sd: char;
sKey: string;
i, n: integer;
ItemProp: TItemProp;
begin
// Ñïèñîê íàçâàíèé çâóêîâûõ ñîáûòèé
slSoundNames:=TStringList.Create();
sd:=slSoundNames.NameValueSeparator;
with slSoundNames do
begin
{slSoundNames.Add('sfxChanMsg'+sd+sSoundEventChannelMessage);
slSoundNames.Add('sfxPvtMsg' +sd+sSoundEventPrivateMessage);
slSoundNames.Add('sfxMeMsg' +sd+sSoundEventMeMessage);
slSoundNames.Add('sfxNoteMsg'+sd+sSoundEventNoticeMessage);
slSoundNames.Add('sfxDccChat'+sd+sSoundEventDccChat);
slSoundNames.Add('sfxDccFile'+sd+sSoundEventDccFile);
slSoundNames.Add('sfxConnect'+sd+sSoundEventServerConnect);
slSoundNames.Add('sfxDisconnect'+sd+sSoundEventServerDisconnect);
slSoundNames.Add('sfxJoin' +sd+sSoundEventJoinChannel);
slSoundNames.Add('sfxLeave' +sd+sSoundEventLeaveChannel);
slSoundNames.Add('sfxError' +sd+sSoundEventErrorMessage);
slSoundNames.Add('sfxOther' +sd+sSoundEventOther); }
//slSoundNames.Add(''+sd+'');
end;
// Î÷èñòêà è çàïîëíåíèå âèçóàëüíîãî ñïèñêà çâóêîâ
// !! åñëè Strings èçíà÷àëüíî ïóñò - áóäåò îøèáêà!
for i:=vleSounds.RowCount-1 downto 1 do
begin
vleSounds.DeleteRow(i);
end;
for i:=0 to slSoundNames.Count-1 do
begin
sKey:=slSoundNames.Names[i];
//n:=vleSounds.InsertRow(sKey, conf.slSoundFiles.Values[sKey], true);
ItemProp:=vleSounds.ItemProps[sKey];
ItemProp.KeyDesc:=slSoundNames.ValueFromIndex[i];
ItemProp.EditStyle:=esEllipsis;
//ItemProp.MaxLength:=3;
//ItemProp.EditMask:='!990';
end;
FreeAndNil(slSoundNames);
end;
// Ïðè êëèêå êíîïêè âûáîðà â ñïèñêå çâóêîâ
procedure TfrmMainOptions.vleSoundsEditButtonClick(Sender: TObject);
var
fsd: TOpenDialog;
curKey: string;
begin
if not (sender = vleSounds) then Exit;
curKey:=vleSounds.Keys[vleSounds.Row];
fsd:=TOpenDialog.Create(self);
fsd.Filter:='WAV files|*.wav|All files|*.*';
fsd.FileName:=vleSounds.Values[curKey];
if fsd.Execute then vleSounds.Values[curKey]:=fsd.FileName;
FreeAndNil(fsd);
end;
procedure TfrmMainOptions.btnSoundTestClick(Sender: TObject);
begin
PlaySoundFile(vleSounds.Values[vleSounds.Keys[vleSounds.Row]]);
end;
procedure TfrmMainOptions.lvPluginsListSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
begin
if (Item = nil) then Exit;
lbPluginInfo.Caption:=Item.SubItems[0];
end;
// Âûáîð øðèôòîâ
procedure TfrmMainOptions.lbFontSelectClick(Sender: TObject);
var
i: integer;
MP: TPoint;
FontSelector: TFontDialog;
begin
with (Sender as TListBox) do
begin
MP.X:= Mouse.CursorPos.X - ClientOrigin.X;
MP.Y:= Mouse.CursorPos.Y - ClientOrigin.Y;
i:=ItemAtPos(MP, true);
end;
if (i < 0) or (i > 2) then Exit;
FontSelector:=TFontDialog.Create(Self);
if MainConf.fntArray[i+1] = nil then MainConf.fntArray[i+1]:=TFont.Create;
FontSelector.Font.Assign(MainConf.fntArray[i+1]);
if FontSelector.Execute then
begin
MainConf.fntArray[i+1].Assign(FontSelector.Font);
Core.SetNewFonts();
//MainConf.SetNewFonts;
end;
FontSelector.Destroy;
end;
procedure TfrmMainOptions.FillConfigNodes(RootNode: TConfNode);
var
NewNode: TConfNode;
NewNode2: TConfNode;
begin
RootNode.OnApplySettings:=OnApplySettingsHandler;
// Main
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Main';
NewNode.FullName:=gbMain.Caption;
NewNode.Panel:=gbMain;
// Fonts
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Fonts';
NewNode.FullName:=gbFonts.Caption;
NewNode.Panel:=gbFonts;
// Sounds
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Sounds';
NewNode.FullName:=gbSounds.Caption;
NewNode.Panel:=gbSounds;
// Plugins
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Plugins';
NewNode.FullName:=gbPlugins.Caption;
NewNode.Panel:=gbPlugins;
// Languages
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Language';
NewNode.FullName:=gbLanguage.Caption;
NewNode.Panel:=gbLanguage;
// Proxy list
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Proxy';
NewNode.FullName:=gbProxy.Caption;
NewNode.Panel:=gbProxy;
// Other
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Other';
NewNode.FullName:='All main options';
NewNode.ConfItems:=RootNode.ConfItems;
NewNode.Panel:=nil;
// Messages group
NewNode:=TConfNode.Create(RootNode);
NewNode.Name:='Messages';
NewNode.FullName:=gbMessages.Caption;
NewNode.Panel:=gbMessages;
NewNode2:=NewNode;
{// Autojoin
NewNode:=TConfNode.Create(NewNode2);
NewNode.Name:=tsAutojoin.Caption;
NewNode.FullName:=gbAutojoin.Caption;
NewNode.Panel:=gbAutojoin; }
{// Templates
NewNode:=TConfNode.Create(NewNode2);
NewNode.Name:=tsTemplates.Caption;
NewNode.FullName:=gbTemplates.Caption;
NewNode.Panel:=gbTemplates;}
// FastMsg
NewNode:=TConfNode.Create(NewNode2);
NewNode.Name:='FastMsg';
NewNode.FullName:=gbFastMsg.Caption;
NewNode.Panel:=gbFastMsg;
{// Notes
NewNode:=TConfNode.Create(NewNode2);
NewNode.Name:=tsNotes.Caption;
NewNode.FullName:=gbNotes.Caption;
NewNode.Panel:=gbNotes;}
// NotesGrabber
NewNode:=TConfNode.Create(NewNode2);
NewNode.Name:='NotesGrabber';
NewNode.FullName:=gbNotesGrabber.Caption;
NewNode.Panel:=gbNotesGrabber;
self.RefreshSettings(RootNode);
end;
// Ïîñêîëüêó ó MainConf íàñòðîéêè õðàíÿòñÿ òîëüêî â RootNode, ðàáîòàåò òîëüêî ñ íèì
procedure TfrmMainOptions.RefreshSettings(ConfNode: TConfNode);
var
ConfItems: TConfItems;
begin
//if ConfNode<>MainConf.RootNode then Exit;
ConfItems:=ConfNode.ConfItems;
if not Assigned(ConfItems) then Exit;
// óñòàíîâêà çíà÷åíèé
cbCopySelected.Checked := (ConfItems['CopySelected']='1');
cbNotifyPrivates.Checked := (ConfItems['NotifyPrivates']='1');
cbNotifyAllMessages.Checked := (ConfItems['NotifyAllMsg']='1');
cbUserlistCheckboxes.Checked := (ConfItems['UserlistCheckboxes']='1');
cbShowNotesOnJoin.Checked := (ConfItems['ShowNotesOnJoin']='1');
cbPopupPrivate.Checked := (ConfItems['PopupPrivate']='1');
cbUseAvatars.Checked := (ConfItems['UseAvatars']='1');
cbLogMessages.Checked := (ConfItems['LogMessages']='1');
cbPlaySounds.Checked := (ConfItems['PlaySounds']='1');
cbSendMsgOnCtrlEnter.Checked := (ConfItems['SendMsgOnCtrlEnter']='1');
edHotkey.Text := ConfItems['Hotkey'];
editSmilesCount.Text := ConfItems['SmilesCount'];
cbSmilesCloseAfterSelect.Checked := (ConfItems['CloseAfterSelect']='1');
memoTemplates.Lines.Text := ConfItems['TemplatesList'];
memoGrabKeywords.Lines.Text := ConfItems['NotesGrabberList'];
memoNotes.Lines.Text := ConfItems['NotesList'];
memoIgnore.Lines.Text := ConfItems['IgnoreList'];
memoFastMsg.Lines.Text := ConfItems['FastMsgList'];
memoAutojoinList.Lines.Text := ConfItems['AutojoinList'];
memoProxyList.Lines.Text := ConfItems['ProxyList'];
// Çàãðóçêà øðèôòîâ
if not Assigned(MainConf) then Exit;
MainConf.fntArray[1].Name:=MainConf['fntChatText_Name'];
MainConf.fntArray[1].Size:=StrToIntDef(MainConf['fntChatText_Size'], MainConf.fntArray[1].Size);
MainConf.fntArray[2].Name:=MainConf['fntUserList_Name'];
MainConf.fntArray[2].Size:=StrToIntDef(MainConf['fntUserList_Size'], MainConf.fntArray[2].Size);
MainConf.fntArray[3].Name:=MainConf['fntTxtToSend_Name'];
MainConf.fntArray[3].Size:=StrToIntDef(MainConf['fntTxtToSend_Size'], MainConf.fntArray[3].Size);
end;
// Ïîñêîëüêó ó MainConf íàñòðîéêè õðàíÿòñÿ òîëüêî â RootNode, ðàáîòàåò òîëüêî ñ íèì
procedure TfrmMainOptions.ApplySettings(ConfNode: TConfNode);
var
ConfItems: TConfItems;
function GetBoolStr(b: boolean): string;
begin
result:='0';
if b then result:='1';
end;
begin
//if ConfNode<>MainConf.RootNode then Exit;
ConfItems:=ConfNode.ConfItems;
if not Assigned(ConfItems) then Exit;
// óñòàíîâêà çíà÷åíèé
ConfItems['CopySelected'] := GetBoolStr(cbCopySelected.Checked);
ConfItems['NotifyPrivates'] := GetBoolStr(cbNotifyPrivates.Checked);
ConfItems['NotifyAllMsg'] := GetBoolStr(cbNotifyAllMessages.Checked);
ConfItems['UserlistCheckboxes'] := GetBoolStr(cbUserlistCheckboxes.Checked);
ConfItems['ShowNotesOnJoin'] := GetBoolStr(cbShowNotesOnJoin.Checked);
ConfItems['PopupPrivate'] := GetBoolStr(cbPopupPrivate.Checked);
ConfItems['UseAvatars'] := GetBoolStr(cbUseAvatars.Checked);
ConfItems['LogMessages'] := GetBoolStr(cbLogMessages.Checked);
ConfItems['PlaySounds'] := GetBoolStr(cbPlaySounds.Checked);
ConfItems['SendMsgOnCtrlEnter'] := GetBoolStr(cbSendMsgOnCtrlEnter.Checked);
ConfItems['Hotkey'] := edHotkey.Text;
ConfItems['SmilesCount'] := editSmilesCount.Text;
ConfItems['CloseAfterSelect'] := GetBoolStr(cbSmilesCloseAfterSelect.Checked);
ConfItems['TemplatesList'] := memoTemplates.Lines.Text;
ConfItems['NotesGrabberList'] := memoGrabKeywords.Lines.Text;
ConfItems['NotesList'] := memoNotes.Lines.Text;
ConfItems['IgnoreList'] := memoIgnore.Lines.Text;
ConfItems['FastMsgList'] := memoFastMsg.Lines.Text;
ConfItems['AutojoinList'] := memoAutojoinList.Lines.Text;
// Çàïèñü øðèôòîâ
if not Assigned(MainConf) then Exit;
MainConf['fntChatText_Name']:=MainConf.fntArray[1].Name;
MainConf['fntChatText_Size']:=IntToStr(MainConf.fntArray[1].Size);
MainConf['fntUserList_Name']:=MainConf.fntArray[2].Name;
MainConf['fntUserList_Size']:=IntToStr(MainConf.fntArray[2].Size);
MainConf['fntTxtToSend_Name']:=MainConf.fntArray[3].Name;
MainConf['fntTxtToSend_Size']:=IntToStr(MainConf.fntArray[3].Size);
end;
procedure TfrmMainOptions.OnApplySettingsHandler(Sender: TObject);
begin
ApplySettings(TConfNode(Sender));
end;
procedure TfrmMainOptions.ChangeLanguage();
function GetStr(Name: string; s: string): string;
begin
result:=Core.LangIni.ReadString('MainOptions', Name, s);
end;
procedure SetNodeCaption(sNodeName, sCaption: string);
var
cn: TConfNode;
begin
cn:=MainConf.RootNode.GetChildByName(sNodeName);
if cn <> nil then cn.FullName:=sCaption;
end;
begin
if not Assigned(Core.LangIni) then Exit;
try
// Templates
{gbTemplates.Caption:=GetStr('gbTemplates.Caption', gbTemplates.Caption);
lbTemplates1.Caption:=GetStr('lbTemplates1.Caption', lbTemplates1.Caption);
lbTemplates6.Caption:=GetStr('lbTemplates6.Caption', lbTemplates6.Caption);
lbTemplates7.Caption:=GetStr('lbTemplates7.Caption', lbTemplates7.Caption);
lbTemplates8.Caption:=GetStr('lbTemplates8.Caption', lbTemplates8.Caption);
lbTemplates9.Caption:=GetStr('lbTemplates9.Caption', lbTemplates9.Caption);}
// Sounds
gbSounds.Caption:=GetStr('gbSounds.Caption', gbSounds.Caption);
cbPlaySounds.Caption:=GetStr('cbPlaySounds.Caption', cbPlaySounds.Caption);
lbSoundTest.Caption:=GetStr('lbSoundTest.Caption', lbSoundTest.Caption);
SetNodeCaption('Sounds', gbSounds.Caption);
// Smiles
gbSmiles.Caption:=GetStr('gbSmiles.Caption', gbSmiles.Caption);
cbSmilesCloseAfterSelect.Caption:=GetStr('cbSmilesCloseAfterSelect.Caption', cbSmilesCloseAfterSelect.Caption);
lbSmilesCount.Caption:=GetStr('lbSmilesCount.Caption', lbSmilesCount.Caption);
// Plugins
gbPlugins.Caption:=GetStr('gbPlugins.Caption', gbPlugins.Caption);
SetNodeCaption('Plugins', gbPlugins.Caption);
// NotesGrabber
gbNotesGrabber.Caption:=GetStr('gbNotesGrabber.Caption', gbNotesGrabber.Caption);
lbNotesGrabberReadme.Caption:=GetStr('lbNotesGrabberReadme.Caption', lbNotesGrabberReadme.Caption);
SetNodeCaption('NotesGrabber', gbNotesGrabber.Caption);
// Notes
{gbNotes.Caption:=GetStr('gbNotes.Caption', gbNotes.Caption);
cbShowNotesOnJoin.Caption:=GetStr('cbShowNotesOnJoin.Caption', cbShowNotesOnJoin.Caption);
lbNotesReadme.Caption:=GetStr('lbNotesReadme.Caption', lbNotesReadme.Caption);}
// Main
gbMain.Caption:=GetStr('gbMain.Caption', gbMain.Caption);
cbCopySelected.Caption:=GetStr('cbCopySelected.Caption', cbCopySelected.Caption);
cbLogMessages.Caption:=GetStr('cbLogMessages.Caption', cbLogMessages.Caption);
cbNotifyAllMessages.Caption:=GetStr('cbNotifyAllMessages.Caption', cbNotifyAllMessages.Caption);
cbNotifyPrivates.Caption:=GetStr('cbNotifyPrivates.Caption', cbNotifyPrivates.Caption);
cbPopupPrivate.Caption:=GetStr('cbPopupPrivate.Caption', cbPopupPrivate.Caption);
cbSendMsgOnCtrlEnter.Caption:=GetStr('cbSendMsgOnCtrlEnter.Caption', cbSendMsgOnCtrlEnter.Caption);
cbUseAvatars.Caption:=GetStr('cbUseAvatars.Caption', cbUseAvatars.Caption);
cbUserlistCheckboxes.Caption:=GetStr('cbUserlistCheckboxes.Caption', cbUserlistCheckboxes.Caption);
lbHotkey.Caption:=GetStr('lbHotkey.Caption', lbHotkey.Caption);
SetNodeCaption('Main', gbMain.Caption);
// Ignore
{gbIgnore.Caption:=GetStr('gbIgnore.Caption', gbIgnore.Caption);
lbIgnore1.Caption:=GetStr('lbIgnore1.Caption', lbIgnore1.Caption);
lbIgnore2.Caption:=GetStr('lbIgnore2.Caption', lbIgnore2.Caption);
lbIgnore3.Caption:=GetStr('lbIgnore3.Caption', lbIgnore3.Caption);}
// Fonts
gbFonts.Caption:=GetStr('gbFonts.Caption', gbFonts.Caption);
SetNodeCaption('Fonts', gbFonts.Caption);
lbFontSelect.Items[0]:=GetStr('Font_ChatWindow', lbFontSelect.Items[0]);
lbFontSelect.Items[1]:=GetStr('Font_UserList', lbFontSelect.Items[1]);
lbFontSelect.Items[2]:=GetStr('Font_PostWindow', lbFontSelect.Items[2]);
// Messages
gbMessages.Caption:=GetStr('gbMessages.Caption', gbMessages.Caption);
SetNodeCaption('Messages', gbMessages.Caption);
// Fast messages
gbFastMsg.Caption:=GetStr('gbFastMsg.Caption', gbFastMsg.Caption);
lbFM1.Caption:=GetStr('lbFM1.Caption', lbFM1.Caption);
SetNodeCaption('FastMsg', gbFastMsg.Caption);
// proxy
gbProxy.Caption:=GetStr('gbProxy.Caption', gbProxy.Caption);
gbProxyList.Caption:=GetStr('gbProxyList.Caption', gbProxyList.Caption);
btnAddProxy.Caption:=GetStr('btnAddProxy.Caption', btnAddProxy.Caption);
btnDelProxy.Caption:=GetStr('btnDelProxy.Caption', btnDelProxy.Caption);
lbProxyHost.Caption:=GetStr('lbProxyHost.Caption', lbProxyHost.Caption);
lbProxyPort.Caption:=GetStr('lbProxyPort.Caption', lbProxyPort.Caption);
lbProxyUser.Caption:=GetStr('lbProxyUser.Caption', lbProxyUser.Caption);
lbProxyPass.Caption:=GetStr('lbProxyPass.Caption', lbProxyPass.Caption);
lbProxyType.Caption:=GetStr('lbProxyType.Caption', lbProxyType.Caption);
SetNodeCaption('Proxy', gbProxy.Caption);
// Autojoin
{gbAutojoin.Caption:=GetStr('gbAutojoin.Caption', gbAutojoin.Caption);
lbAJList.Caption:=GetStr('lbAJList.Caption', lbAJList.Caption);}
// Language
SetNodeCaption('Language', gbLanguage.Caption);
finally
end;
end;
procedure TfrmMainOptions.listboxLangsClick(Sender: TObject);
var
li: TLangInfo;
begin
with TListBox(Sender) do
begin
if ItemIndex<0 then Exit;
li:=(Items.Objects[ItemIndex] as TLangInfo);
end;
lbLangInfo.Caption:=li.LangName+#13+#10+li.Author+#13+#10+li.InfoText;
SelectedLangInfo:=li;
end;
procedure TfrmMainOptions.btnLoadLangClick(Sender: TObject);
begin
if not Assigned(SelectedLangInfo) then Exit;
if Assigned(Core.LangIni) then FreeAndNil(Core.LangIni);
MainConf['LanguageFile']:=ExtractFilename(SelectedLangInfo.FileName);
//Core.LangIni:=TMemIniFile.Create(SelectedLangInfo.FileName);
Core.ChangeLanguage();
end;
procedure TfrmMainOptions.edHotkeyKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s: string;
begin
s:='';
if ssShift in Shift then s:=s+'Shift+';
if ssAlt in Shift then s:=s+'Alt+';
if ssCtrl in Shift then s:=s+'Ctrl+';
s:=s+IntToStr(Key);
edHotkey.Text:=s;
end;
procedure TfrmMainOptions.btnAddProxyClick(Sender: TObject);
var
s: string;
begin
s:=Misc.ComposeProxyURL(edProxyHost.Text, edProxyPort.Text, cboxProxyType.Text,
edProxyUser.Text, edProxyPass.Text);
if memoProxyList.Lines.IndexOf(s)<0 then memoProxyList.Lines.Add(s);
MainConf['ProxyList']:=memoProxyList.Lines.Text;
end;
procedure TfrmMainOptions.btnDelProxyClick(Sender: TObject);
begin
if memoProxyList.CaretPos.Y>=0 then
memoProxyList.Lines.Delete(memoProxyList.CaretPos.Y);
MainConf['ProxyList']:=memoProxyList.Lines.Text;
end;
end.