| 1 | unit UFormLogin;
|
|---|
| 2 |
|
|---|
| 3 | {$mode objfpc}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 9 | MaskEdit, ExtCtrls, URegistry, Registry;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TLoginForm }
|
|---|
| 14 |
|
|---|
| 15 | TLoginForm = class(TForm)
|
|---|
| 16 | ButtonChange: TButton;
|
|---|
| 17 | ButtonCancel: TButton;
|
|---|
| 18 | ButtonLogin: TButton;
|
|---|
| 19 | CheckBoxRememberPassword: TCheckBox;
|
|---|
| 20 | ComboBoxConnection: TComboBox;
|
|---|
| 21 | EditUserName: TEdit;
|
|---|
| 22 | EditPassword: TEdit;
|
|---|
| 23 | Image1: TImage;
|
|---|
| 24 | Label1: TLabel;
|
|---|
| 25 | Label2: TLabel;
|
|---|
| 26 | Label3: TLabel;
|
|---|
| 27 | procedure ButtonCancelClick(Sender: TObject);
|
|---|
| 28 | procedure ButtonChangeClick(Sender: TObject);
|
|---|
| 29 | procedure ButtonLoginClick(Sender: TObject);
|
|---|
| 30 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 31 | procedure FormShow(Sender: TObject);
|
|---|
| 32 | private
|
|---|
| 33 | public
|
|---|
| 34 | procedure UpdateInterface;
|
|---|
| 35 | end;
|
|---|
| 36 |
|
|---|
| 37 | var
|
|---|
| 38 | LoginForm: TLoginForm;
|
|---|
| 39 |
|
|---|
| 40 | implementation
|
|---|
| 41 |
|
|---|
| 42 | {$R *.lfm}
|
|---|
| 43 |
|
|---|
| 44 | uses
|
|---|
| 45 | UCore, UFormLoginProfile, UFormMain;
|
|---|
| 46 |
|
|---|
| 47 | { TLoginForm }
|
|---|
| 48 |
|
|---|
| 49 | procedure TLoginForm.ButtonLoginClick(Sender: TObject);
|
|---|
| 50 | begin
|
|---|
| 51 | Core.LastUserName := EditUserName.Text;
|
|---|
| 52 | Core.LastProfile := ComboBoxConnection.ItemIndex;
|
|---|
| 53 | Core.LastPassword := EditPassword.Text;
|
|---|
| 54 | Core.RememberPassword := CheckBoxRememberPassword.Checked;
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | procedure TLoginForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 58 | begin
|
|---|
| 59 | //MainForm.PersistentForm.Save(Self);
|
|---|
| 60 | end;
|
|---|
| 61 |
|
|---|
| 62 | procedure TLoginForm.FormShow(Sender: TObject);
|
|---|
| 63 | begin
|
|---|
| 64 | //MainForm.PersistentForm.Load(Self);
|
|---|
| 65 | EditUserName.Text := Core.LastUserName;
|
|---|
| 66 | EditPassword.Text := Core.LastPassword;
|
|---|
| 67 | EditPassword.SetFocus;
|
|---|
| 68 | CheckBoxRememberPassword.Checked := Core.RememberPassword;
|
|---|
| 69 | Core.Profiles.FillStrings(ComboBoxConnection.Items);
|
|---|
| 70 | ComboBoxConnection.ItemIndex := Core.LastProfile;
|
|---|
| 71 | if (ComboBoxConnection.Items.Count > 0) and
|
|---|
| 72 | (ComboBoxConnection.ItemIndex = -1) then ComboBoxConnection.ItemIndex := 0;
|
|---|
| 73 | UpdateInterface;
|
|---|
| 74 | end;
|
|---|
| 75 |
|
|---|
| 76 | procedure TLoginForm.UpdateInterface;
|
|---|
| 77 | begin
|
|---|
| 78 | ButtonLogin.Enabled := ComboBoxConnection.ItemIndex >= 0;
|
|---|
| 79 | end;
|
|---|
| 80 |
|
|---|
| 81 | procedure TLoginForm.ButtonCancelClick(Sender: TObject);
|
|---|
| 82 | begin
|
|---|
| 83 | Close;
|
|---|
| 84 | end;
|
|---|
| 85 |
|
|---|
| 86 | procedure TLoginForm.ButtonChangeClick(Sender: TObject);
|
|---|
| 87 | begin
|
|---|
| 88 | try
|
|---|
| 89 | LoginProfileForm := TLoginProfileForm.Create(MainForm);
|
|---|
| 90 | Core.CoolTranslator1.TranslateComponentRecursive(LoginProfileForm);
|
|---|
| 91 | if LoginProfileForm.ShowModal = mrOk then begin
|
|---|
| 92 | Core.Profiles.FillStrings(ComboBoxConnection.Items);
|
|---|
| 93 | Core.LastProfile := ComboBoxConnection.ItemIndex;
|
|---|
| 94 | ComboBoxConnection.ItemIndex := Core.LastProfile;
|
|---|
| 95 | if (ComboBoxConnection.Items.Count > 0) and
|
|---|
| 96 | (ComboBoxConnection.ItemIndex = -1) then ComboBoxConnection.ItemIndex := 0;
|
|---|
| 97 | end;
|
|---|
| 98 | finally
|
|---|
| 99 | LoginProfileForm.Free;
|
|---|
| 100 | end;
|
|---|
| 101 | UpdateInterface;
|
|---|
| 102 | end;
|
|---|
| 103 |
|
|---|
| 104 | end.
|
|---|
| 105 |
|
|---|