forked from HemulGM/ChatGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatGPT.ChatSettings.pas
188 lines (167 loc) · 5.1 KB
/
ChatGPT.ChatSettings.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
unit ChatGPT.ChatSettings;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
ChatGPT.Overlay, FMX.Objects, FMX.Edit, FMX.Controls.Presentation, FMX.Layouts,
ChatGPT.Classes, FMX.ComboEdit;
type
TFrameChatSettings = class(TFrameOveraly)
LayoutClient: TLayout;
RectangleFrame: TRectangle;
LayoutActs: TLayout;
ButtonCancel: TButton;
ButtonOk: TButton;
VertScrollBox: TVertScrollBox;
ComboEditModel: TComboEdit;
EditMaxTokens: TEdit;
ClearEditButton3: TClearEditButton;
Path2: TPath;
EditQueryMaxToken: TEdit;
ClearEditButton4: TClearEditButton;
Path3: TPath;
Label1: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label3: TLabel;
Label4: TLabel;
Label8: TLabel;
Label9: TLabel;
Layout3: TLayout;
TrackBarTemp: TTrackBar;
LabelTemp: TLabel;
Layout1: TLayout;
TrackBarPP: TTrackBar;
LabelPP: TLabel;
Label12: TLabel;
Label11: TLabel;
Label15: TLabel;
Layout5: TLayout;
TrackBarFP: TTrackBar;
LabelFP: TLabel;
Label13: TLabel;
Label28: TLabel;
Layout6: TLayout;
TrackBarTopP: TTrackBar;
LabelTopP: TLabel;
Label30: TLabel;
LabelAppearance: TLabel;
Layout7: TLayout;
SwitchUseFunctions: TSwitch;
Label34: TLabel;
Label35: TLabel;
Layout9: TLayout;
SwitchAutoExecFuncs: TSwitch;
Label37: TLabel;
Layout2: TLayout;
procedure TrackBarTempTracking(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure ButtonOkClick(Sender: TObject);
procedure FrameResize(Sender: TObject);
procedure RectangleBGClick(Sender: TObject);
procedure TrackBarPPTracking(Sender: TObject);
procedure TrackBarFPTracking(Sender: TObject);
procedure TrackBarTopPTracking(Sender: TObject);
private
FProcCallback: TProc<TFrameChatSettings, Boolean>;
FLayoutClientWidth: Single;
FLayoutClientHeight: Single;
protected
procedure SetMode(const Value: TWindowMode); override;
public
constructor Create(AOwner: TComponent); override;
class procedure Execute(AParent: TControl; ProcSet: TProc<TFrameChatSettings>; ProcExecuted: TProc<TFrameChatSettings, Boolean>);
end;
var
FrameChatSettings: TFrameChatSettings;
implementation
uses
System.Math, FMX.Ani, HGM.FMX.Ani;
{$R *.fmx}
{ TFrameChatSettings }
procedure TFrameChatSettings.ButtonCancelClick(Sender: TObject);
begin
if Assigned(FProcCallback) then
FProcCallback(Self, False);
Release;
end;
procedure TFrameChatSettings.ButtonOkClick(Sender: TObject);
begin
if Assigned(FProcCallback) then
FProcCallback(Self, True);
Release;
end;
constructor TFrameChatSettings.Create(AOwner: TComponent);
begin
inherited;
FLayoutClientWidth := LayoutClient.Width;
FLayoutClientHeight := LayoutClient.Height;
VertScrollBox.AniCalculations.Animation := True;
VertScrollBox.AniCalculations.Interval := 1;
VertScrollBox.AniCalculations.Averaging := True;
VertScrollBox.ViewportPosition := TPoint.Zero;
Name := '';
end;
class procedure TFrameChatSettings.Execute(AParent: TControl; ProcSet: TProc<TFrameChatSettings>; ProcExecuted: TProc<TFrameChatSettings, Boolean>);
begin
var Frame := TFrameChatSettings.Create(AParent);
Frame.Parent := AParent;
Frame.FProcCallback := ProcExecuted;
Frame.Align := TAlignLayout.Contents;
Frame.BringToFront;
if Assigned(ProcSet) then
ProcSet(Frame);
Frame.TrackBarTempTracking(nil);
Frame.TrackBarPPTracking(nil);
Frame.TrackBarFPTracking(nil);
Frame.TrackBarTopPTracking(nil);
Frame.ButtonCancel.SetFocus;
end;
procedure TFrameChatSettings.FrameResize(Sender: TObject);
begin
LayoutClient.Width := Min(FLayoutClientWidth, Width);
LayoutClient.Height := Min(FLayoutClientHeight, Height);
end;
procedure TFrameChatSettings.RectangleBGClick(Sender: TObject);
begin
TAnimator.AnimateFloatWithFinish(LayoutClient, 'RotationAngle', 2,
procedure
begin
TAnimator.AnimateFloat(LayoutClient, 'RotationAngle', 0, 0.2, TAnimationType.out, TInterpolationType.Back);
end,
0.2, TAnimationType.out, TInterpolationType.Elastic);
end;
procedure TFrameChatSettings.SetMode(const Value: TWindowMode);
begin
inherited;
if Mode = TWindowMode.Compact then
begin
LayoutClient.Align := TAlignLayout.Client;
RectangleFrame.Corners := [];
end
else
begin
LayoutClient.Align := TAlignLayout.Center;
RectangleFrame.Corners := AllCorners;
end;
FrameResize(nil);
end;
procedure TFrameChatSettings.TrackBarFPTracking(Sender: TObject);
begin
LabelFP.Text := FormatFloat('0.0', TrackBarFP.Value / 10);
end;
procedure TFrameChatSettings.TrackBarPPTracking(Sender: TObject);
begin
LabelPP.Text := FormatFloat('0.0', TrackBarPP.Value / 10);
end;
procedure TFrameChatSettings.TrackBarTempTracking(Sender: TObject);
begin
LabelTemp.Text := FormatFloat('0.0', TrackBarTemp.Value / 10);
end;
procedure TFrameChatSettings.TrackBarTopPTracking(Sender: TObject);
begin
LabelTopP.Text := FormatFloat('0.0', TrackBarTopP.Value / 10);
end;
end.