source: trunk/dsa_messenger/logon_dialogs.adb

Last change on this file was 8, checked in by vadim.godunko, 12 years ago

Add list of users.

File size: 3.6 KB
Line 
1with Qt4.Dialog_Button_Boxes.Constructors;
2with Qt4.Grid_Layouts.Constructors;
3-- It is much better to use QFormLayout, but it is unavailable in QtAda 3.1.0.
4with Qt4.Labels.Constructors;
5with Qt4.Line_Edits.Constructors;
6with Qt4.Objects;
7with Qt4.Push_Buttons;
8with Qt4.Settings.Constructors;
9with Qt4.Strings;
10with Qt4.Variants;
11
12with Logon_Dialogs.Moc;
13
14package body Logon_Dialogs is
15
16 function "-" (Item : String) return Qt4.Strings.Q_String
17 renames Qt4.Strings.From_Utf_8;
18
19 -------------------
20 -- Accept_Dialog --
21 -------------------
22
23 overriding procedure Accept_Dialog (Self : not null access Logon_Dialog) is
24 Login : constant Qt4.Strings.Q_String := Self.Login.Text;
25 Password : constant Qt4.Strings.Q_String := Self.Password.Text;
26
27 begin
28 Qt4.Dialogs.Directors.Q_Dialog_Director (Self.all).Accept_Dialog;
29
30 Self.Settings.Set_Value (-"login", Qt4.Variants.Create (Login));
31 Self.Settings.Set_Value (-"password", Qt4.Variants.Create (Password));
32
33 Self.Emit_Accepted (Login, Password);
34 end Accept_Dialog;
35
36 ------------------
37 -- Constructors --
38 ------------------
39
40 package body Constructors is
41
42 ------------
43 -- Create --
44 ------------
45
46 function Create
47 (Parent : access Qt4.Widgets.Q_Widget'Class)
48 return not null Logon_Dialog_Access
49 is
50 Layout : Qt4.Grid_Layouts.Q_Grid_Layout_Access;
51 Label : Qt4.Labels.Q_Label_Access;
52 Box : Qt4.Dialog_Button_Boxes.Q_Dialog_Button_Box_Access;
53 Button : Qt4.Push_Buttons.Q_Push_Button_Access;
54
55 begin
56 return Self : not null Logon_Dialog_Access := new Logon_Dialog do
57 Qt4.Dialogs.Directors.Constructors.Initialize (Self, Parent);
58
59 Self.Set_Window_Title (-"Logon");
60 Self.Set_Modal (True);
61
62 Self.Settings := Qt4.Settings.Constructors.Create (Self);
63 Self.Settings.Begin_Group (-"client");
64
65 Layout := Qt4.Grid_Layouts.Constructors.Create;
66 Self.Set_Layout (Layout);
67
68 Label := Qt4.Labels.Constructors.Create (-"Login");
69 Layout.Add_Widget (Label, 0, 0);
70
71 Self.Login := Qt4.Line_Edits.Constructors.Create;
72 Self.Login.Set_Text
73 (Self.Settings.Value (-"login").To_String);
74 Layout.Add_Widget (Self.Login, 0, 1);
75
76 Label := Qt4.Labels.Constructors.Create (-"Password");
77 Layout.Add_Widget (Label, 1, 0);
78
79 Self.Password := Qt4.Line_Edits.Constructors.Create;
80 Self.Password.Set_Echo_Mode (Qt4.Line_Edits.Password);
81 Self.Password.Set_Text
82 (Self.Settings.Value (-"password").To_String);
83 Layout.Add_Widget (Self.Password, 1, 1);
84
85 Box :=
86 Qt4.Dialog_Button_Boxes.Constructors.Create (Qt4.Horizontal);
87 Layout.Add_Widget (Box, 2, 0, 2, 2);
88 Qt4.Objects.Connect
89 (Box, Qt4.Signal ("accepted()"), Self, Qt4.Slot ("accept()"));
90 Qt4.Objects.Connect
91 (Box, Qt4.Signal ("rejected()"), Self, Qt4.Slot ("reject()"));
92
93 Button :=
94 Qt4.Push_Buttons.Q_Push_Button_Access
95 (Box.Add_Button (Qt4.Dialog_Button_Boxes.Ok));
96
97 Button :=
98 Qt4.Push_Buttons.Q_Push_Button_Access
99 (Box.Add_Button (Qt4.Dialog_Button_Boxes.Cancel));
100 end return;
101 end Create;
102
103 end Constructors;
104
105 -------------------
106 -- Emit_Accepted --
107 -------------------
108
109 procedure Emit_Accepted
110 (Self : not null access Logon_Dialog'Class;
111 Login : Qt4.Strings.Q_String;
112 Password : Qt4.Strings.Q_String) is separate;
113
114end Logon_Dialogs;
Note: See TracBrowser for help on using the repository browser.