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.
RnQ/RnQ/addContactDlg.pas

153 lines
3.6 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, RnQProtocol, RnQButtons;
{$I NoRTTI.inc}
type
TaddContactFrm = class(TForm)
Label1: TLabel;
uinBox: TLabeledEdit;
addBtn: TRnQButton;
LocalChk: TCheckBox;
procedure FormPaint(Sender: TObject);
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: TRnQContact;
thisProto: TRnQProtocol;
public
constructor Create(AOwner: TComponent; proto: TRnQProtocol); reIntroduce;
procedure DestroyHandle; Override;
end;
// var
// addContactFrm: TaddContactFrm;
implementation
uses
RnQLangs, RQUtil, RDGlobal, RQThemes, menusUnit, RnQSysUtils, RnQPics, utilLib, globalLib, roasterLib;
{$R *.DFM}
procedure TaddContactFrm.FormPaint(Sender: TObject);
begin
wallpaperize(canvas)
end;
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
// i:integer;
uid: TUID;
begin
uid := trim(uinBox.text);
// if not thisProto.validUid(uid) then
if not thisProto.ValidUid1(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=icq.myinfo then
// msgDlg(getTranslation('Invalid UIN'),mtWarning)
// else
// if roasterLib.exists(c) then
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);
// 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: TRnQProtocol);
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.