Browse Source

GUI: move wizard activation to TUserInterface

Herman Schoenfeld 7 years ago
parent
commit
d40cdeb538
3 changed files with 56 additions and 32 deletions
  1. 3 3
      src/gui/UCTRLNoAccount.lfm
  2. 5 28
      src/gui/UCTRLWallet.pas
  3. 48 1
      src/gui/UUserInterface.pas

+ 3 - 3
src/gui/UCTRLNoAccount.lfm

@@ -18,15 +18,15 @@ object CTRLNoAccounts: TCTRLNoAccounts
     Anchors = [akLeft, akRight]
     Anchors = [akLeft, akRight]
     AutoSize = False
     AutoSize = False
     Caption = 'No Accounts'
     Caption = 'No Accounts'
-    Font.Height = -27
+    Font.Height = -20
     Font.Style = [fsBold]
     Font.Style = [fsBold]
     ParentColor = False
     ParentColor = False
     ParentFont = False
     ParentFont = False
   end
   end
   object btnGetAcc: TBitBtn
   object btnGetAcc: TBitBtn
-    Left = 176
+    Left = 96
     Height = 57
     Height = 57
-    Top = 192
+    Top = 128
     Width = 163
     Width = 163
     Anchors = []
     Anchors = []
     Caption = 'Get An Account'
     Caption = 'Get An Account'

+ 5 - 28
src/gui/UCTRLWallet.pas

@@ -17,9 +17,7 @@ interface
 uses
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
   ExtCtrls, PairSplitter, Buttons, UVisualGrid, UCommon.UI, Generics.Collections, ULog,
   ExtCtrls, PairSplitter, Buttons, UVisualGrid, UCommon.UI, Generics.Collections, ULog,
-  UAccounts, UDataSources, UNode, UCoreObjects, UCoreUtils, UCTRLNoAccount,
-  UWIZSendPASC, UWIZChangeKey, UWIZEnlistAccountForSale;
-
+  UAccounts, UDataSources, UNode, UCoreObjects, UCoreUtils, UCTRLNoAccount;
 type
 type
 
 
   { TCTRLWallet }
   { TCTRLWallet }
@@ -613,44 +611,23 @@ begin
 end;
 end;
 
 
 procedure TCTRLWallet.miSendPASCClick(Sender: TObject);
 procedure TCTRLWallet.miSendPASCClick(Sender: TObject);
-var
-  Scoped: TDisposables;
-  wiz: TWIZSendPASCWizard;
-  model: TWIZOperationsModel;
 begin
 begin
-  wiz := Scoped.AddObject(TWIZSendPASCWizard.Create(nil)) as TWIZSendPASCWizard;
-  model := TWIZOperationsModel.Create(wiz, omtSendPasc);
-  model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowSendDialog(SelectedAccounts);
 end;
 end;
 
 
 procedure TCTRLWallet.miChangeKeyClick(Sender: TObject);
 procedure TCTRLWallet.miChangeKeyClick(Sender: TObject);
-var
-  Scoped: TDisposables;
-  wiz: TWIZChangeKeyWizard;
-  model: TWIZOperationsModel;
 begin
 begin
-  wiz := Scoped.AddObject(TWIZChangeKeyWizard.Create(nil)) as TWIZChangeKeyWizard;
-  model := TWIZOperationsModel.Create(wiz, omtChangeKey);
-  model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowChangeKeyDialog(SelectedAccounts);
 end;
 end;
 
 
 procedure TCTRLWallet.miEnlistAccountsForSaleClick(Sender: TObject);
 procedure TCTRLWallet.miEnlistAccountsForSaleClick(Sender: TObject);
-var
-  Scoped: TDisposables;
-  wiz: TWIZEnlistAccountForSaleWizard;
-  model: TWIZOperationsModel;
 begin
 begin
-  wiz := Scoped.AddObject(TWIZEnlistAccountForSaleWizard.Create(nil)) as TWIZEnlistAccountForSaleWizard;
-  model := TWIZOperationsModel.Create(wiz, omtEnlistAccountForSale);
-  model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowSellAccountsDialog(SelectedAccounts);
 end;
 end;
 
 
 procedure TCTRLWallet.miDelistAccountsFromSaleClick(Sender: TObject);
 procedure TCTRLWallet.miDelistAccountsFromSaleClick(Sender: TObject);
 begin
 begin
-  raise ENotImplemented.Create('not yet implemented.');
+  TUserInterface.ShowDelistAccountsDialog(SelectedAccounts);
 end;
 end;
 
 
 procedure TCTRLWallet.OnPrepareOperationsPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);
 procedure TCTRLWallet.OnPrepareOperationsPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);

+ 48 - 1
src/gui/UUserInterface.pas

@@ -116,6 +116,10 @@ type
       class procedure CheckNodeIsReady;
       class procedure CheckNodeIsReady;
 
 
       // Show Dialogs
       // Show Dialogs
+      class procedure ShowSendDialog(const AAccounts : array of Cardinal);
+      class procedure ShowChangeKeyDialog(const AAccounts : array of Cardinal);
+      class procedure ShowSellAccountsDialog(const AAccounts : array of Cardinal);
+      class procedure ShowDelistAccountsDialog(const AAccounts : array of Cardinal);
       class procedure ShowAboutBox(parentForm : TForm);
       class procedure ShowAboutBox(parentForm : TForm);
       class procedure ShowOptionsDialog(parentForm: TForm);
       class procedure ShowOptionsDialog(parentForm: TForm);
       class procedure ShowAccountInfoDialog(parentForm: TForm; const account : Cardinal); overload;
       class procedure ShowAccountInfoDialog(parentForm: TForm; const account : Cardinal); overload;
@@ -147,6 +151,7 @@ type
       class procedure ShowLogsForm;
       class procedure ShowLogsForm;
       class procedure ShowWallet;
       class procedure ShowWallet;
       class procedure ShowSyncDialog;
       class procedure ShowSyncDialog;
+
   end;
   end;
 
 
   { TLoadSafeBoxThread }
   { TLoadSafeBoxThread }
@@ -164,7 +169,8 @@ implementation
 
 
 uses
 uses
   UFRMAbout, UFRMNodesIp, UFRMPascalCoinWalletConfig, UFRMPayloadDecoder, UFRMMemoText,
   UFRMAbout, UFRMNodesIp, UFRMPascalCoinWalletConfig, UFRMPayloadDecoder, UFRMMemoText,
-  UOpenSSL, UFileStorage, UTime, UCommon, USettings, UCoreUtils;
+  UOpenSSL, UFileStorage, UTime, UCommon, USettings, UCoreUtils, UMemory,
+  UWIZOperation, UWIZSendPASC, UWIZChangeKey, UWIZEnlistAccountForSale;
 
 
 {%region UI Lifecyle}
 {%region UI Lifecyle}
 
 
@@ -412,6 +418,47 @@ end;
 
 
 {%region Show Dialogs}
 {%region Show Dialogs}
 
 
+class procedure TUserInterface.ShowSendDialog(const AAccounts : array of Cardinal);
+var
+  Scoped: TDisposables;
+  wiz: TWIZSendPASCWizard;
+  model: TWIZOperationsModel;
+begin
+  wiz := Scoped.AddObject(TWIZSendPASCWizard.Create(nil)) as TWIZSendPASCWizard;
+  model := TWIZOperationsModel.Create(wiz, omtSendPasc);
+  model.Account.SelectedAccounts := TNode.Node.GetAccounts(AAccounts, True);
+  wiz.Start(model);
+end;
+
+class procedure TUserInterface.ShowChangeKeyDialog(const AAccounts : array of Cardinal);
+var
+  Scoped: TDisposables;
+  wiz: TWIZChangeKeyWizard;
+  model: TWIZOperationsModel;
+begin
+  wiz := Scoped.AddObject(TWIZChangeKeyWizard.Create(nil)) as TWIZChangeKeyWizard;
+  model := TWIZOperationsModel.Create(wiz, omtChangeKey);
+  model.Account.SelectedAccounts := TNode.Node.GetAccounts(AAccounts, True);
+  wiz.Start(model);
+end;
+
+class procedure TUserInterface.ShowSellAccountsDialog(const AAccounts : array of Cardinal);
+var
+  Scoped: TDisposables;
+  wiz: TWIZEnlistAccountForSaleWizard;
+  model: TWIZOperationsModel;
+begin
+  wiz := Scoped.AddObject(TWIZEnlistAccountForSaleWizard.Create(nil)) as TWIZEnlistAccountForSaleWizard;
+  model := TWIZOperationsModel.Create(wiz, omtEnlistAccountForSale);
+  model.Account.SelectedAccounts := TNode.Node.GetAccounts(AAccounts, True);
+  wiz.Start(model);
+end;
+
+class procedure TUserInterface.ShowDelistAccountsDialog(const AAccounts : array of Cardinal);
+begin
+  raise ENotImplemented.Create('Not Implemented');
+end;
+
 class procedure TUserInterface.ShowAboutBox(parentForm : TForm);
 class procedure TUserInterface.ShowAboutBox(parentForm : TForm);
 begin
 begin
   with TFRMAbout.Create(parentForm) do
   with TFRMAbout.Create(parentForm) do