Skip to content

Commit

Permalink
Added username label
Browse files Browse the repository at this point in the history
  • Loading branch information
peleccom committed Oct 8, 2013
1 parent 022ca57 commit bc01c49
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 92 deletions.
131 changes: 57 additions & 74 deletions LogInUnit.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ object LogInForm: TLogInForm
Caption = 'TabSheet1'
TabVisible = False
OnShow = TabSheet1Show
ExplicitLeft = 8
ExplicitTop = 10
DesignSize = (
236
184)
object EnterPageLabel: TLabel
Left = 0
Top = 0
Expand All @@ -40,91 +45,70 @@ object LogInForm: TLogInForm
Alignment = taCenter
Caption = 'Total Commander Dropbox plugin'
WordWrap = True
ExplicitLeft = 3
ExplicitTop = -6
end
object Label1: TLabel
Left = 0
Top = 13
Top = 37
Width = 236
Height = 13
Align = alTop
Alignment = taRightJustify
ExplicitLeft = 233
ExplicitTop = 13
ExplicitWidth = 3
end
object ButtonsPageControl: TPageControl
Left = 0
Top = 26
Width = 236
Height = 158
ActivePage = TabSheet4
Align = alClient
Style = tsFlatButtons
object UserNameLabel: TLabel
AlignWithMargins = True
Left = 3
Top = 16
Width = 223
Height = 18
Margins.Right = 10
Align = alTop
Alignment = taRightJustify
Caption = 'hello'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clGreen
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ParentColor = False
ParentFont = False
ExplicitLeft = 198
ExplicitWidth = 28
end
object Enter: TButton
Left = 25
Top = 70
Width = 185
Height = 28
Anchors = []
Caption = #1042#1093#1086#1076
TabOrder = 0
object TabSheet4: TTabSheet
Caption = 'TabSheet4'
TabVisible = False
DesignSize = (
228
148)
object UserNameLabel: TLabel
AlignWithMargins = True
Left = 3
Top = 3
Width = 215
Height = 38
Margins.Right = 10
Align = alTop
Alignment = taRightJustify
Caption = 'hello'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clGreen
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ParentColor = False
ParentFont = False
end
object Enter: TButton
Left = 26
Top = 47
Width = 185
Height = 28
Anchors = []
Caption = #1042#1093#1086#1076
TabOrder = 0
OnClick = EnterClick
end
object SignOut: TButton
Left = 26
Top = 93
Width = 185
Height = 28
Anchors = []
Caption = #1057#1084#1077#1085#1080#1090#1100' '#1087#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1103
TabOrder = 1
OnClick = SignOutClick
end
end
object TabSheet5: TTabSheet
Caption = 'TabSheet5'
ImageIndex = 1
TabVisible = False
DesignSize = (
228
148)
object SignIn: TButton
Left = 21
Top = 62
Width = 185
Height = 29
Anchors = []
Caption = #1040#1074#1090#1086#1088#1080#1079#1086#1074#1072#1090#1100#1089#1103
TabOrder = 0
OnClick = SignInClick
end
end
OnClick = EnterClick
end
object SignOut: TButton
Left = 25
Top = 139
Width = 185
Height = 28
Anchors = []
Caption = #1057#1084#1077#1085#1080#1090#1100' '#1087#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1103
TabOrder = 1
OnClick = SignOutClick
end
object SignIn: TButton
Left = 25
Top = 104
Width = 185
Height = 29
Anchors = []
Caption = #1040#1074#1090#1086#1088#1080#1079#1086#1074#1072#1090#1100#1089#1103
TabOrder = 2
OnClick = SignInClick
end
end
object TabSheet2: TTabSheet
Expand Down Expand Up @@ -165,7 +149,6 @@ object LogInForm: TLogInForm
Anchors = []
Caption = #1054#1090#1082#1083#1086#1085#1080#1090#1100
TabOrder = 1
OnClick = CancelButtonClick
end
end
object TabSheet3: TTabSheet
Expand Down
29 changes: 12 additions & 17 deletions LogInUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,17 @@ TLogInForm = class(TForm)
AcceptPageLabel: TLabel;
EnterPageLabel: TLabel;
Label1: TLabel;
ButtonsPageControl: TPageControl;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
UserNameLabel: TLabel;
Enter: TButton;
SignOut: TButton;
SignIn: TButton;
UserNameLabel: TLabel;
constructor Create(AOwner: TComponent; session: TDropboxSession;
client: TDropboxClient; accessKeyFilename: string);
procedure SignOutClick(Sender: TObject);
procedure SignInClick(Sender: TObject);
procedure EnterClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure AcceptButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure TabSheet1Show(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
Expand Down Expand Up @@ -79,7 +75,7 @@ procedure TLogInForm.SignInClick(Sender: TObject);
token := session.obtainRequestToken();
url := session.buildAuthorizeUrl(token, '');
ShellExecute(0, PChar('open'), PChar(url), Nil, Nil, SW_SHOW);
Sleep(3000);
Sleep(4000);
PageControl1.ActivePageIndex := 1;
except
on E: Exception do
Expand All @@ -104,20 +100,27 @@ procedure TLogInForm.TabSheet1Show(Sender: TObject);
if session.isLinked() then
begin
// logged in
ButtonsPageControl.ActivePageIndex := 0;
UserNameLabel.Visible := True;
SignOut.Visible := True;
Enter.Visible := True;
SignIn.Visible := False;

try
UserNameLabel.Caption := getUserName();
except
on E: Exception do
begin
UserNameLabel.Caption := '';
logger.Debug('Cant get display name ' + E.ClassName+ E.Message);
logger.Debug('Cant get display name ' + E.ClassName + E.Message);
end;
end;
end
else
begin
ButtonsPageControl.ActivePageIndex := 1;
UserNameLabel.Visible := False;
SignOut.Visible := False;
Enter.Visible := False;
SignIn.Visible := True;
UserNameLabel.Caption := '';
end;
end;
Expand All @@ -126,7 +129,6 @@ procedure TLogInForm.AcceptButtonClick(Sender: TObject);
begin
try
session.obtainAccessToken();
PageControl1.ActivePageIndex := 0;
if session.isLinked() then
begin
logger.Info('Accept token: Linked to dropbox');
Expand Down Expand Up @@ -156,11 +158,6 @@ procedure TLogInForm.BitBtn1Click(Sender: TObject);
logger.Debug('Key file not saved');
end;

procedure TLogInForm.CancelButtonClick(Sender: TObject);
begin
PageControl1.ActivePageIndex := 0;
end;

constructor TLogInForm.Create(AOwner: TComponent; session: TDropboxSession;
client: TDropboxClient; accessKeyFilename: string);
begin
Expand Down Expand Up @@ -216,8 +213,6 @@ procedure TLogInForm.FormCreate(Sender: TObject);
begin
PageControl1.Pages[page].TabVisible := False;
end;
for page := 0 to ButtonsPageControl.PageCount - 1 do
ButtonsPageControl.Pages[page].TabVisible := False;
PageControl1.ActivePageIndex := 0;
end;

Expand Down
3 changes: 2 additions & 1 deletion TCBox.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ function ShowDllFormModal: boolean;
var
modal: TModalResult;
begin
LogInForm := TLogInForm.Create(nil, DropboxSession, DropboxClient, AccessKeyFullFileName);
LogInForm := TLogInForm.Create(nil, DropboxSession, DropboxClient,
AccessKeyFullFileName);
modal := LogInForm.ShowModal;
if modal = mrOk then
Result := True
Expand Down

0 comments on commit bc01c49

Please sign in to comment.