You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.4 KiB
Plaintext
141 lines
3.4 KiB
Plaintext
{
|
|
This file is part of R&Q.
|
|
Under same license
|
|
}
|
|
unit addContactDlg;
|
|
{$I RnQConfig.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
SysUtils, Classes, Controls, Forms, ExtCtrls, StdCtrls, Menus, RnQButtons, ICQContacts, ICQSession;
|
|
|
|
{$I NoRTTI.inc}
|
|
|
|
type
|
|
TaddContactFrm = class(TForm)
|
|
Label1: TLabel;
|
|
UINBox: TLabeledEdit;
|
|
addBtn: TRnQButton;
|
|
LocalChk: TCheckBox;
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure addBtnClick(Sender: TObject);
|
|
procedure addcontactAction(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure UINBoxChange(Sender: TObject);
|
|
procedure UINBoxKeyPress(Sender: TObject; var Key: Char);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormDestroy(Sender: TObject);
|
|
private
|
|
menu: TPopupMenu;
|
|
c: TICQContact;
|
|
thisProto: TICQSession;
|
|
public
|
|
constructor Create(AOwner: TComponent; proto: TICQSession); reIntroduce;
|
|
procedure DestroyHandle; Override;
|
|
end;
|
|
|
|
// var
|
|
// addContactFrm: TaddContactFrm;
|
|
|
|
implementation
|
|
|
|
uses
|
|
RnQLangs, RQUtil, RDGlobal, RQThemes, menusUnit, RnQSysUtils, RnQPics, ICQCommon, utilLib, globalLib, roasterLib;
|
|
|
|
{$R *.DFM}
|
|
|
|
procedure TaddContactFrm.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
DestroyHandle;
|
|
Action := caFree;
|
|
end;
|
|
|
|
procedure TaddContactFrm.FormCreate(Sender: TObject);
|
|
begin
|
|
menu := TPopupMenu.Create(Self);
|
|
Self.menu := menu;
|
|
end;
|
|
|
|
procedure TaddContactFrm.FormDestroy(Sender: TObject);
|
|
begin
|
|
menu.Free;
|
|
end;
|
|
|
|
procedure TaddContactFrm.addBtnClick(Sender: TObject);
|
|
var
|
|
UID: TUID;
|
|
begin
|
|
UID := Trim(UINBox.text);
|
|
if not thisProto.ValidICQ(UID) then
|
|
MsgDlg('Invalid UIN', True, mtError)
|
|
else
|
|
begin
|
|
c := thisProto.GetContact(UID);
|
|
if not Assigned(c) then
|
|
begin
|
|
MsgDlg('Couldn''t create contact!', True, mtError);
|
|
Exit;
|
|
end;
|
|
if c.IsInRoster then
|
|
begin
|
|
roasterLib.focus(c);
|
|
MsgDlg(getTranslation('%s already exists', [uid]), False, mtWarning)
|
|
end
|
|
else
|
|
begin
|
|
addGroupsToMenu(Self, menu.items, addcontactAction, LocalChk.Checked or thisProto.canAddCntOutOfGroup);
|
|
// applyCommonSettings(menu);
|
|
with clientToScreen(addBtn.BoundsRect.bottomRight) do
|
|
menu.popup(x, y);
|
|
end;
|
|
end
|
|
end;
|
|
|
|
procedure TaddContactFrm.addcontactAction(Sender: TObject);
|
|
begin
|
|
// if LocalChk.Checked then
|
|
AddToRoster(c, (Sender as Tmenuitem).tag, LocalChk.Checked);
|
|
Close;
|
|
SaveListsDelayed := True;
|
|
end;
|
|
|
|
constructor TaddContactFrm.Create(AOwner: TComponent; proto: TICQSession);
|
|
begin
|
|
inherited Create(AOwner);
|
|
thisProto := proto;
|
|
LocalChk.Enabled := thisProto.isSSCL and thisProto.isOnline;
|
|
LocalChk.Checked := not LocalChk.Enabled; // not (LocalChk.Checked);
|
|
end;
|
|
|
|
procedure TaddContactFrm.DestroyHandle;
|
|
begin
|
|
inherited
|
|
end;
|
|
|
|
procedure TaddContactFrm.FormShow(Sender: TObject);
|
|
begin
|
|
// theme.getPic(PIC_ADD_CONTACT, addBtn.glyph);
|
|
theme.pic2ico(RQteFormIcon, PIC_ADD_CONTACT, icon);
|
|
uinBox.text := '';
|
|
uinBox.setFocus;
|
|
applyTaskButton(Self);
|
|
end;
|
|
|
|
procedure TaddContactFrm.UINBoxChange(Sender: TObject);
|
|
begin
|
|
// onlydigits(sender)
|
|
end;
|
|
|
|
procedure TaddContactFrm.UINBoxKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
case Key of
|
|
#27:
|
|
close;
|
|
#13:
|
|
addBtnClick(Self);
|
|
end;
|
|
end;
|
|
|
|
end.
|