Changeset 25 for trunk/Forms


Ignore:
Timestamp:
Nov 9, 2011, 1:58:00 PM (13 years ago)
Author:
george
Message:
  • Modified: Login form now use connection profile form for selecting connection parameters.
  • Added: About application dialog.
Location:
trunk/Forms
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/ULoginForm.lfm

    r22 r25  
    11object LoginForm: TLoginForm
    2   Left = 482
    3   Height = 171
    4   Top = 258
    5   Width = 399
     2  Left = 312
     3  Height = 163
     4  Top = 186
     5  Width = 433
    66  BorderIcons = [biSystemMenu]
    77  BorderStyle = bsDialog
    88  Caption = 'Login'
    9   ClientHeight = 171
    10   ClientWidth = 399
     9  ClientHeight = 163
     10  ClientWidth = 433
     11  OnClose = FormClose
     12  OnShow = FormShow
    1113  LCLVersion = '0.9.31'
    1214  object Label1: TLabel
    1315    Left = 16
    1416    Height = 14
    15     Top = 48
     17    Top = 64
    1618    Width = 53
    1719    Caption = 'Username:'
     
    2123    Left = 16
    2224    Height = 14
    23     Top = 80
     25    Top = 96
    2426    Width = 51
    2527    Caption = 'Password:'
     
    3234    Width = 75
    3335    Caption = 'Close'
     36    ModalResult = 11
     37    OnClick = ButtonCancelClick
    3438    TabOrder = 0
    3539  end
     
    4044    Width = 75
    4145    Caption = 'Login'
     46    ModalResult = 1
     47    OnClick = ButtonLoginClick
    4248    TabOrder = 1
    4349  end
    44   object Edit1: TEdit
     50  object EditUserName: TEdit
    4551    Left = 88
    4652    Height = 21
    47     Top = 40
     53    Top = 64
    4854    Width = 104
    4955    TabOrder = 2
    5056  end
    51   object MaskEdit1: TMaskEdit
     57  object MaskEditPassword: TMaskEdit
    5258    Left = 88
    5359    Height = 21
    54     Top = 71
     60    Top = 96
    5561    Width = 104
    5662    CharCase = ecNormal
     
    6167    SpaceChar = '_'
    6268  end
     69  object Label3: TLabel
     70    Left = 16
     71    Height = 14
     72    Top = 12
     73    Width = 59
     74    Caption = 'Connection:'
     75    ParentColor = False
     76  end
     77  object ComboBoxConnection: TComboBox
     78    Left = 88
     79    Height = 21
     80    Top = 12
     81    Width = 105
     82    ItemHeight = 13
     83    Style = csDropDownList
     84    TabOrder = 4
     85  end
     86  object ButtonChange: TButton
     87    Left = 198
     88    Height = 25
     89    Top = 9
     90    Width = 67
     91    Caption = 'Change'
     92    OnClick = ButtonChangeClick
     93    TabOrder = 5
     94  end
    6395  object Image1: TImage
    64     Left = 216
    65     Height = 152
    66     Top = 16
    67     Width = 168
     96    Left = 272
     97    Height = 140
     98    Top = 12
     99    Width = 152
    68100  end
    69101end
  • trunk/Forms/ULoginForm.lrt

    r10 r25  
    44TLOGINFORM.BUTTONCANCEL.CAPTION=Close
    55TLOGINFORM.BUTTONLOGIN.CAPTION=Login
    6 TLOGINFORM.MASKEDIT1.TEXT=*
     6TLOGINFORM.MASKEDITPASSWORD.TEXT=*
     7TLOGINFORM.LABEL3.CAPTION=Connection:
     8TLOGINFORM.BUTTONCHANGE.CAPTION=Change
  • trunk/Forms/ULoginForm.pas

    r3 r25  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   MaskEdit, ExtCtrls;
     9  MaskEdit, ExtCtrls, URegistry, Registry;
    1010
    1111type
     
    1414
    1515  TLoginForm = class(TForm)
     16    ButtonChange: TButton;
    1617    ButtonCancel: TButton;
    1718    ButtonLogin: TButton;
    18     Edit1: TEdit;
     19    ComboBoxConnection: TComboBox;
     20    EditUserName: TEdit;
    1921    Image1: TImage;
    2022    Label1: TLabel;
    2123    Label2: TLabel;
    22     MaskEdit1: TMaskEdit;
     24    Label3: TLabel;
     25    MaskEditPassword: TMaskEdit;
     26    procedure ButtonCancelClick(Sender: TObject);
     27    procedure ButtonChangeClick(Sender: TObject);
     28    procedure ButtonLoginClick(Sender: TObject);
     29    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     30    procedure FormShow(Sender: TObject);
    2331  private
    24     { private declarations }
    2532  public
    26     { public declarations }
    27   end;
     33  end;
    2834
    2935var
     
    3440{$R *.lfm}
    3541
     42uses
     43  UCore, ULoginProfileForm, UMainForm;
     44
     45{ TLoginForm }
     46
     47procedure TLoginForm.ButtonLoginClick(Sender: TObject);
     48begin
     49  Core.LastUserName := EditUserName.Text;
     50  Core.LastProfile := ComboBoxConnection.ItemIndex;
     51  Core.LastPassword := MaskEditPassword.Text;
     52end;
     53
     54procedure TLoginForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     55begin
     56  MainForm.PersistentForm.Save(Self);
     57end;
     58
     59procedure TLoginForm.FormShow(Sender: TObject);
     60begin
     61  MainForm.PersistentForm.Load(Self);
     62  ComboBoxConnection.ItemIndex := Core.LastProfile;
     63  EditUserName.Text := Core.LastUserName;
     64  MaskEditPassword.Text := '';
     65  Core.Profiles.FillStrings(ComboBoxConnection.Items);
     66end;
     67
     68procedure TLoginForm.ButtonCancelClick(Sender: TObject);
     69begin
     70  Close;
     71end;
     72
     73procedure TLoginForm.ButtonChangeClick(Sender: TObject);
     74begin
     75  if LoginProfileForm.ShowModal = mrOk then begin
     76    Core.Profiles.FillStrings(ComboBoxConnection.Items);
     77  end;
     78end;
     79
    3680end.
    3781
  • trunk/Forms/UMainForm.lfm

    r24 r25  
    66  ActiveControl = Panel1
    77  Caption = 'ChronIS'
    8   ClientHeight = 422
     8  ClientHeight = 427
    99  ClientWidth = 640
    1010  Menu = MainMenu1
     
    1616  object Panel1: TPanel
    1717    Left = 0
    18     Height = 422
     18    Height = 427
    1919    Top = 0
    2020    Width = 184
    2121    Align = alLeft
    2222    BevelOuter = bvNone
    23     ClientHeight = 422
     23    ClientHeight = 427
    2424    ClientWidth = 184
    2525    TabOrder = 0
    2626    object Label1: TLabel
    2727      Left = 7
    28       Height = 18
     28      Height = 14
    2929      Top = 4
    30       Width = 51
     30      Width = 39
    3131      Caption = 'Groups:'
    3232      ParentColor = False
     
    3434    object TreeView1: TTreeView
    3535      Left = 4
    36       Height = 398
     36      Height = 403
    3737      Top = 19
    3838      Width = 180
    3939      Anchors = [akTop, akLeft, akRight, akBottom]
     40      DefaultItemHeight = 16
    4041      Images = ImageListActions
    4142      ReadOnly = True
     
    4748  object Panel2: TPanel
    4849    Left = 189
    49     Height = 422
     50    Height = 427
    5051    Top = 0
    5152    Width = 451
    5253    Align = alClient
    5354    BevelOuter = bvNone
    54     ClientHeight = 422
     55    ClientHeight = 427
    5556    ClientWidth = 451
    5657    TabOrder = 1
    5758    object Label2: TLabel
    5859      Left = 2
    59       Height = 18
     60      Height = 14
    6061      Top = 4
    61       Width = 54
     62      Width = 43
    6263      Caption = 'Reports:'
    6364      ParentColor = False
     
    6566    object ListView1: TListView
    6667      Left = 2
    67       Height = 366
     68      Height = 371
    6869      Top = 19
    6970      Width = 447
     
    8586      Left = 3
    8687      Height = 25
    87       Top = 393
     88      Top = 398
    8889      Width = 75
    8990      Action = AItemAdd
     
    9495      Left = 83
    9596      Height = 25
    96       Top = 393
     97      Top = 398
    9798      Width = 75
    9899      Action = AItemDelete
     
    103104  object Splitter1: TSplitter
    104105    Left = 184
    105     Height = 422
     106    Height = 427
    106107    Top = 0
    107108    Width = 5
     
    184185      Caption = 'Import structure...'
    185186      OnExecute = AImportStructureExecute
     187    end
     188    object AAbout: TAction
     189      Caption = 'About'
     190      OnExecute = AAboutExecute
    186191    end
    187192  end
     
    316321      object MenuItem17: TMenuItem
    317322        Action = AConnect
     323        OnClick = MenuItem17Click
    318324      end
    319325      object MenuItem14: TMenuItem
     
    341347    object MenuItem12: TMenuItem
    342348      Caption = 'Help'
     349      object MenuItem21: TMenuItem
     350        Action = AAbout
     351      end
    343352    end
    344353  end
  • trunk/Forms/UMainForm.lrt

    r24 r25  
    2020TMAINFORM.AINITSYSTEMVALUES.CAPTION=Init system values
    2121TMAINFORM.AIMPORTSTRUCTURE.CAPTION=Import structure...
     22TMAINFORM.AABOUT.CAPTION=About
    2223TMAINFORM.MENUITEM13.CAPTION=Server
    2324TMAINFORM.MENUITEM11.CAPTION=View
  • trunk/Forms/UMainForm.pas

    r24 r25  
    1717  published
    1818    AConnect: TAction;
     19    AAbout: TAction;
    1920    AImportStructure: TAction;
    2021    AInitSystemValues: TAction;
     
    5354    MenuItem2: TMenuItem;
    5455    MenuItem20: TMenuItem;
     56    MenuItem21: TMenuItem;
    5557    MenuItem3: TMenuItem;
    5658    MenuItem4: TMenuItem;
     
    6769    Splitter1: TSplitter;
    6870    TreeView1: TTreeView;
     71    procedure AAboutExecute(Sender: TObject);
    6972    procedure AConnectExecute(Sender: TObject);
    7073    procedure AExitExecute(Sender: TObject);
     
    9194    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
    9295      Selected: Boolean);
     96    procedure MenuItem17Click(Sender: TObject);
    9397    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    9498  private
     
    96100    OriginalWindowState: TWindowState;
    97101    ScreenBounds: TRect;
    98     RegistryKey: string;
    99     RegistryRootKey: HKEY;
    100102    procedure LoadFromRegistry;
    101103    procedure SaveToRegistry;
     
    128130uses
    129131  UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo,
    130   UCore, UImportStructureForm;
     132  UCore, UImportStructureForm, UAboutForm, ULoginProfileForm;
    131133
    132134{$R *.lfm}
     
    138140  with TRegistryEx.Create do
    139141  try
    140     RootKey := RegistryRootKey;
    141     OpenKey(RegistryKey, True);
     142    RootKey := Core.RegistryRootKey;
     143    OpenKey(Core.RegistryKey, True);
    142144    Panel1.Width := ReadIntegerWithDefault('GroupTreeWidth', 200);
    143     Core.System.Database.Database := ReadStringWithDefault('DatabaseSchema', 'chronis');
    144     Core.System.Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost');
    145     Core.System.Database.UserName := ReadStringWithDefault('DatabaseUserName', 'chronis');
    146     Core.System.Database.Password := ReadStringWithDefault('DatabasePassword', '');
    147145    with Core.CoolTranslator1 do
    148146      Language := Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''));
     
    156154  with TRegistryEx.Create do
    157155  try
    158     RootKey := RegistryRootKey;
    159     OpenKey(RegistryKey, True);
     156    RootKey := Core.RegistryRootKey;
     157    OpenKey(Core.RegistryKey, True);
    160158    WriteInteger('GroupTreeWidth', Panel1.Width);
    161     WriteString('DatabaseSchema', Core.System.Database.Database);
    162     WriteString('DatabaseHostName', Core.System.Database.Hostname);
    163     WriteString('DatabaseUserName', Core.System.Database.UserName);
    164     WriteString('DatabasePassword', Core.System.Database.Password);
    165159    with Core.CoolTranslator1 do
    166160      WriteString('LanguageCode', Language.Code);
     
    520514  SelectedObject := TChronisObject.Create;
    521515  SelectedObject.Base := Core.System;
    522   RegistryRootKey := HKEY_CURRENT_USER;
    523   RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' +
    524     ApplicationInfo.Name;
    525516  PersistentForm := TPersistentForm.Create;
    526   PersistentForm.RegistryKey := RegistryKey;
     517  PersistentForm.RegistryKey := Core.RegistryKey;
    527518end;
    528519
     
    641632procedure TMainForm.AConnectExecute(Sender: TObject);
    642633begin
    643   LoginForm.ShowModal;
     634  Core.Profiles.LoadFromRegistry(Core.RegistryRootKey, Core.RegistryKey);
     635  if LoginForm.ShowModal = mrOK then begin
     636    with TConnectProfile(Core.Profiles[Core.LastProfile]) do begin
     637      Core.System.Database.HostName := HostName;
     638      Core.System.Database.Database := Database;
     639      Core.System.Database.UserName := Core.LastUserName;
     640      Core.System.Database.Password := Core.LastPassword;
     641      Core.System.Database.Connect;
     642    end;
     643    InitStructure;
     644    Core.System.LoadTypes;
     645    LoadTree;
     646  end;
     647end;
     648
     649procedure TMainForm.AAboutExecute(Sender: TObject);
     650begin
     651  AboutForm.ShowModal;
    644652end;
    645653
     
    648656  PersistentForm.Load(Self);
    649657  LoadFromRegistry;
    650   Core.System.Database.Connect;
    651   InitStructure;
    652   Core.System.LoadTypes;
    653   LoadTree;
     658  AConnect.Execute;
    654659end;
    655660
     
    696701  AItemView.Enabled := Assigned(ListView1.Selected);
    697702  AItemEdit.Enabled := Assigned(ListView1.Selected);
     703end;
     704
     705procedure TMainForm.MenuItem17Click(Sender: TObject);
     706begin
     707  LoginForm.ShowModal;
    698708end;
    699709
Note: See TracChangeset for help on using the changeset viewer.