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]
     AutoSize = False
     Caption = 'No Accounts'
-    Font.Height = -27
+    Font.Height = -20
     Font.Style = [fsBold]
     ParentColor = False
     ParentFont = False
   end
   object btnGetAcc: TBitBtn
-    Left = 176
+    Left = 96
     Height = 57
-    Top = 192
+    Top = 128
     Width = 163
     Anchors = []
     Caption = 'Get An Account'

+ 5 - 28
src/gui/UCTRLWallet.pas

@@ -17,9 +17,7 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
   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
 
   { TCTRLWallet }
@@ -613,44 +611,23 @@ begin
 end;
 
 procedure TCTRLWallet.miSendPASCClick(Sender: TObject);
-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(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowSendDialog(SelectedAccounts);
 end;
 
 procedure TCTRLWallet.miChangeKeyClick(Sender: TObject);
-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(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowChangeKeyDialog(SelectedAccounts);
 end;
 
 procedure TCTRLWallet.miEnlistAccountsForSaleClick(Sender: TObject);
-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(SelectedAccounts, True);
-  wiz.Start(model);
+  TUserInterface.ShowSellAccountsDialog(SelectedAccounts);
 end;
 
 procedure TCTRLWallet.miDelistAccountsFromSaleClick(Sender: TObject);
 begin
-  raise ENotImplemented.Create('not yet implemented.');
+  TUserInterface.ShowDelistAccountsDialog(SelectedAccounts);
 end;
 
 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;
 
       // 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 ShowOptionsDialog(parentForm: TForm);
       class procedure ShowAccountInfoDialog(parentForm: TForm; const account : Cardinal); overload;
@@ -147,6 +151,7 @@ type
       class procedure ShowLogsForm;
       class procedure ShowWallet;
       class procedure ShowSyncDialog;
+
   end;
 
   { TLoadSafeBoxThread }
@@ -164,7 +169,8 @@ implementation
 
 uses
   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}
 
@@ -412,6 +418,47 @@ end;
 
 {%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);
 begin
   with TFRMAbout.Create(parentForm) do