Browse Source

GUI: Initial wallet screen skeleton

Herman Schoenfeld 7 years ago
parent
commit
2b12673fb5

+ 16 - 3
PascalCoinWallet.lpi

@@ -38,7 +38,7 @@
         <PackageName Value="LCL"/>
         <PackageName Value="LCL"/>
       </Item1>
       </Item1>
     </RequiredPackages>
     </RequiredPackages>
-    <Units Count="75">
+    <Units Count="77">
       <Unit0>
       <Unit0>
         <Filename Value="PascalCoinWallet.dpr"/>
         <Filename Value="PascalCoinWallet.dpr"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
@@ -344,9 +344,11 @@
         <ResourceBaseClass Value="Form"/>
         <ResourceBaseClass Value="Form"/>
       </Unit61>
       </Unit61>
       <Unit62>
       <Unit62>
-        <Filename Value="Units\Forms\UFRMSyncronizationForm.pas"/>
+        <Filename Value="Units\Forms\UCTRLSyncronization.pas"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
+        <ComponentName Value="CTRLSyncronization"/>
         <HasResources Value="True"/>
         <HasResources Value="True"/>
+        <ResourceBaseClass Value="Form"/>
       </Unit62>
       </Unit62>
       <Unit63>
       <Unit63>
         <Filename Value="Units\Utils\UAutoScope.pas"/>
         <Filename Value="Units\Utils\UAutoScope.pas"/>
@@ -416,6 +418,17 @@
         <ComponentName Value="WIZAddKey_SelectEncryption"/>
         <ComponentName Value="WIZAddKey_SelectEncryption"/>
         <ResourceBaseClass Value="Form"/>
         <ResourceBaseClass Value="Form"/>
       </Unit74>
       </Unit74>
+      <Unit75>
+        <Filename Value="Units\Forms\UCTRLWallet.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="CTRLWallet"/>
+        <HasResources Value="True"/>
+        <ResourceBaseClass Value="Form"/>
+      </Unit75>
+      <Unit76>
+        <Filename Value="Units\Forms\UGrids.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit76>
     </Units>
     </Units>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>
@@ -451,7 +464,7 @@
         <ShowHintsForUnusedUnitsInMainSrc Value="True"/>
         <ShowHintsForUnusedUnitsInMainSrc Value="True"/>
         <ShowHintsForSenderNotUsed Value="True"/>
         <ShowHintsForSenderNotUsed Value="True"/>
       </Verbosity>
       </Verbosity>
-      <CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL -vD"/>
+      <CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL -vd"/>
     </Other>
     </Other>
   </CompilerOptions>
   </CompilerOptions>
   <Debugging>
   <Debugging>

BIN
Resources/WalletImages/search-16x16.png


+ 2 - 2
Units/Forms/UCTRLBanner.lfm

@@ -1,7 +1,7 @@
 object CTRLBanner: TCTRLBanner
 object CTRLBanner: TCTRLBanner
-  Left = 736
+  Left = 439
   Height = 80
   Height = 80
-  Top = 26
+  Top = 23
   Width = 992
   Width = 992
   BorderIcons = []
   BorderIcons = []
   BorderStyle = bsNone
   BorderStyle = bsNone

+ 3 - 3
Units/Forms/UFRMSyncronizationForm.lfm → Units/Forms/UCTRLSyncronization.lfm

@@ -1,7 +1,7 @@
-object FRMSyncronizationForm: TFRMSyncronizationForm
-  Left = 322
+object CTRLSyncronization: TCTRLSyncronization
+  Left = 0
   Height = 240
   Height = 240
-  Top = 5
+  Top = 0
   Width = 636
   Width = 636
   BorderIcons = []
   BorderIcons = []
   BorderStyle = bsNone
   BorderStyle = bsNone

+ 15 - 15
Units/Forms/UFRMSyncronizationForm.pas → Units/Forms/UCTRLSyncronization.pas

@@ -1,4 +1,4 @@
-unit UFRMSyncronizationForm;
+unit UCTRLSyncronization;
 
 
 {$mode delphi}
 {$mode delphi}
 
 
@@ -21,9 +21,9 @@ uses
 
 
 type
 type
 
 
-  { TFRMSyncronizationForm }
+  { TCTRLSyncronization }
 
 
-  TFRMSyncronizationForm = class(TApplicationForm)
+  TCTRLSyncronization = class(TApplicationForm)
     btnOpenWallet: TButton;
     btnOpenWallet: TButton;
     Label16: TLabel;
     Label16: TLabel;
     Label4: TLabel;
     Label4: TLabel;
@@ -53,14 +53,14 @@ type
     procedure lblReceivedMessagesClick(Sender:TObject);
     procedure lblReceivedMessagesClick(Sender:TObject);
   private
   private
     { private declarations }
     { private declarations }
-    FMinersBlocksFound: Integer;
+    FMinedBlocksCount: Integer;
   public
   public
     { public declarations }
     { public declarations }
     procedure UpdateNodeStatus;
     procedure UpdateNodeStatus;
     procedure UpdateBlockChainState;
     procedure UpdateBlockChainState;
-    procedure SetMinersBlocksFound(const Value: Integer);
+    procedure SetMinedBlocksCount(const Value: Integer);
     procedure OnFinishedLoadingDatabase;
     procedure OnFinishedLoadingDatabase;
-    Property MinersBlocksFound : Integer read FMinersBlocksFound write SetMinersBlocksFound;
+    Property MinedBlocksCount : Integer read FMinedBlocksCount write SetMinedBlocksCount;
   end;
   end;
 
 
 implementation
 implementation
@@ -71,7 +71,7 @@ uses UNetProtocol,UTime,UConst, UUserInterface;
 
 
 {%region Methods}
 {%region Methods}
 
 
-procedure TFRMSyncronizationForm.UpdateNodeStatus;
+procedure TCTRLSyncronization.UpdateNodeStatus;
 Var status : AnsiString;
 Var status : AnsiString;
 begin
 begin
   if not TUserInterface.Started then exit;
   if not TUserInterface.Started then exit;
@@ -105,7 +105,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TFRMSyncronizationForm.UpdateBlockChainState;
+procedure TCTRLSyncronization.UpdateBlockChainState;
 Var
 Var
   f, favg : real;
   f, favg : real;
 begin
 begin
@@ -150,23 +150,23 @@ begin
       lblMinersClientsValue.Caption := 'No JSON-RPC clients';
       lblMinersClientsValue.Caption := 'No JSON-RPC clients';
       lblMinersClientsValue.Font.Color := clDkGray;
       lblMinersClientsValue.Font.Color := clDkGray;
     end;
     end;
-    MinersBlocksFound := TUserInterface.PoolMiningServer.ClientsWins;
+    MinedBlocksCount := TUserInterface.PoolMiningServer.ClientsWins;
   end else begin
   end else begin
-    MinersBlocksFound := 0;
+    MinedBlocksCount := 0;
     lblMinersClientsValue.Caption := 'JSON-RPC server not active';
     lblMinersClientsValue.Caption := 'JSON-RPC server not active';
     lblMinersClientsValue.Font.Color := clRed;
     lblMinersClientsValue.Font.Color := clRed;
   end;
   end;
 end;
 end;
 
 
-procedure TFRMSyncronizationForm.SetMinersBlocksFound(const Value: Integer);
+procedure TCTRLSyncronization.SetMinedBlocksCount(const Value: Integer);
 begin
 begin
-  FMinersBlocksFound := Value;
+  FMinedBlocksCount := Value;
   lblBlocksFound.Caption := Inttostr(Value);
   lblBlocksFound.Caption := Inttostr(Value);
   if Value>0 then lblBlocksFound.Font.Color := clGreen
   if Value>0 then lblBlocksFound.Font.Color := clGreen
   else lblBlocksFound.Font.Color := clDkGray;
   else lblBlocksFound.Font.Color := clDkGray;
 end;
 end;
 
 
-procedure TFRMSyncronizationForm.OnFinishedLoadingDatabase;
+procedure TCTRLSyncronization.OnFinishedLoadingDatabase;
 begin
 begin
   btnOpenWallet.Enabled:=true;
   btnOpenWallet.Enabled:=true;
   TUserInterface.ShowWallet;
   TUserInterface.ShowWallet;
@@ -176,12 +176,12 @@ end;
 
 
 {%region Handlers: widgets }
 {%region Handlers: widgets }
 
 
-procedure TFRMSyncronizationForm.lblReceivedMessagesClick(Sender:TObject);
+procedure TCTRLSyncronization.lblReceivedMessagesClick(Sender:TObject);
 begin
 begin
   TUserInterface.ShowMessagesForm;
   TUserInterface.ShowMessagesForm;
 end;
 end;
 
 
-procedure TFRMSyncronizationForm.btnOpenWalletClick(Sender:TObject);
+procedure TCTRLSyncronization.btnOpenWalletClick(Sender:TObject);
 begin
 begin
   TUserInterface.ShowWallet;
   TUserInterface.ShowWallet;
 end;
 end;

+ 79 - 0
Units/Forms/UCTRLWallet.lfm

@@ -0,0 +1,79 @@
+object CTRLWallet: TCTRLWallet
+  Left = -7
+  Height = 536
+  Top = 2
+  Width = 796
+  BorderStyle = bsNone
+  Caption = 'CTRLWallet'
+  ClientHeight = 536
+  ClientWidth = 796
+  OnCreate = FormCreate
+  LCLVersion = '1.6.4.0'
+  object GroupBox1: TGroupBox
+    Left = 32
+    Height = 129
+    Top = 24
+    Width = 400
+    Caption = 'Overview'
+    TabOrder = 0
+  end
+  object gpMyAccounts: TGroupBox
+    Left = 32
+    Height = 340
+    Top = 168
+    Width = 400
+    Anchors = [akTop, akLeft, akBottom]
+    Caption = 'My Accounts'
+    ClientHeight = 320
+    ClientWidth = 396
+    TabOrder = 1
+    object cbMyAccViews: TComboBox
+      Left = 8
+      Height = 23
+      Top = 8
+      Width = 376
+      Anchors = [akTop, akLeft, akRight]
+      ItemHeight = 15
+      ItemIndex = 0
+      Items.Strings = (
+        'Show All'
+        'Show non-zero balances'
+        'Get my first account!'
+      )
+      OnChange = cbMyAccViewsChange
+      TabOrder = 0
+      Text = 'Show All'
+    end
+    object paMyAccContent: TPanel
+      Left = 8
+      Height = 261
+      Top = 40
+      Width = 376
+      Anchors = [akTop, akLeft, akRight, akBottom]
+      BevelOuter = bvNone
+      Caption = 'MY ACCOUNT PANEL'
+      Color = clGreen
+      ParentColor = False
+      TabOrder = 1
+    end
+  end
+  object gpRecentOps: TGroupBox
+    Left = 448
+    Height = 484
+    Top = 24
+    Width = 321
+    Anchors = [akTop, akLeft, akRight, akBottom]
+    Caption = 'Recent Operations'
+    ClientHeight = 464
+    ClientWidth = 317
+    TabOrder = 2
+    object cbRecentOpsSelectedAccOnly: TCheckBox
+      Left = 21
+      Height = 19
+      Top = 16
+      Width = 255
+      Caption = 'Show operations from selected account only'
+      TabOrder = 0
+    end
+  end
+end

+ 74 - 0
Units/Forms/UCTRLWallet.pas

@@ -0,0 +1,74 @@
+unit UCTRLWallet;
+
+{$mode delphi}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
+  ExtCtrls, UVisualGrid, UCommonUI;
+
+type
+
+  { TCTRLWallet }
+
+  TCTRLWalletAccountView = (wavAllAccounts, wavMyAccounts, wavFirstAccount);
+  TCTRLWallet = class(TApplicationForm)
+    cbMyAccViews: TComboBox;
+    cbRecentOpsSelectedAccOnly: TCheckBox;
+    GroupBox1: TGroupBox;
+    gpMyAccounts: TGroupBox;
+    gpRecentOps: TGroupBox;
+    paMyAccContent: TPanel;
+    procedure cbMyAccViewsChange(Sender: TObject);
+    procedure FormCreate(Sender: TObject);
+  private
+    FAccountsView : TCTRLWalletAccountView;
+    FAccountsGrid : TVisualGrid;
+    procedure SetAccountsView(view: TCTRLWalletAccountView);
+  protected
+    procedure ActivateFirstTime; override;
+  public
+    property AccountsView : TCTRLWalletAccountView read FAccountsView write SetAccountsView;
+  end;
+
+implementation
+
+{$R *.lfm}
+
+uses UGrids;
+
+{ TCTRLWallet }
+
+procedure TCTRLWallet.FormCreate(Sender: TObject);
+begin
+  FAccountsGrid := TVisualGrid.Create(Self);
+  FAccountsGrid.DataSource := TMyAccountDataSource.Create(FAccountsGrid);
+  AccountsView := wavMyAccounts;
+end;
+
+procedure TCTRLWallet.ActivateFirstTime;
+begin
+end;
+
+procedure TCTRLWallet.SetAccountsView(view: TCTRLWalletAccountView);
+begin
+  paMyAccContent.RemoveAllControls(false);
+  case view of
+     wavAllAccounts: raise Exception.Create('Not implemented');
+     wavMyAccounts: paMyAccContent.AddControlDockCenter(FAccountsGrid);
+     wavFirstAccount: raise Exception.Create('Not implemented');
+  end;
+end;
+
+procedure TCTRLWallet.cbMyAccViewsChange(Sender: TObject);
+begin
+  case cbMyAccViews.ItemIndex of
+     0: AccountsView := wavAllAccounts;
+     1: AccountsView := wavMyAccounts;
+     2: AccountsView := wavFirstAccount;
+  end;
+end;
+
+end.
+

+ 2 - 2
Units/Forms/UFRMAccountExplorer.lfm

@@ -1,7 +1,7 @@
 object FRMAccountExplorer: TFRMAccountExplorer
 object FRMAccountExplorer: TFRMAccountExplorer
-  Left = 205
+  Left = 207
   Height = 471
   Height = 471
-  Top = 107
+  Top = 94
   Width = 868
   Width = 868
   Caption = 'Accounts Explorer'
   Caption = 'Accounts Explorer'
   ClientHeight = 451
   ClientHeight = 451

+ 2 - 2
Units/Forms/UFRMMainForm.lfm

@@ -1,7 +1,7 @@
 object FRMMainForm: TFRMMainForm
 object FRMMainForm: TFRMMainForm
-  Left = 52
+  Left = 168
   Height = 600
   Height = 600
-  Top = 55
+  Top = 12
   Width = 865
   Width = 865
   Caption = 'Pascal Coin Wallet, JSON-RPC Miner & Explorer'
   Caption = 'Pascal Coin Wallet, JSON-RPC Miner & Explorer'
   ClientHeight = 580
   ClientHeight = 580

+ 26 - 15
Units/Forms/UFRMMainForm.pas

@@ -21,7 +21,7 @@ uses
   ULog,
   ULog,
   UBlockChain, UNode, UGridUtils, UAccounts, Menus,
   UBlockChain, UNode, UGridUtils, UAccounts, Menus,
   UNetProtocol, UCrypto, Buttons, ActnList, UPoolMining,
   UNetProtocol, UCrypto, Buttons, ActnList, UPoolMining,
-  UCTRLBanner, UFRMSyncronizationForm, UCommon, UCommonUI;
+  UCTRLBanner, UCTRLWallet, UCTRLSyncronization, UCommon, UCommonUI;
 
 
 const
 const
   CM_PC_FinishedLoadingDatabase = WM_USER + 1;
   CM_PC_FinishedLoadingDatabase = WM_USER + 1;
@@ -95,7 +95,8 @@ type
   private
   private
     __FLastFooterToolBarDrawRect : TRect;  // Required for FPC bug work-around
     __FLastFooterToolBarDrawRect : TRect;  // Required for FPC bug work-around
     FMode : TFRMMainFormMode;
     FMode : TFRMMainFormMode;
-    FSyncControl : TFRMSyncronizationForm;
+    FSyncControl : TCTRLSyncronization;
+    FWalletControl : TCTRLWallet;
     procedure CM_FinishedLoadingDatabase(var Msg: TMessage); message CM_PC_FinishedLoadingDatabase;
     procedure CM_FinishedLoadingDatabase(var Msg: TMessage); message CM_PC_FinishedLoadingDatabase;
     procedure CM_WalletChanged(var Msg: TMessage); message CM_PC_WalletKeysChanged;
     procedure CM_WalletChanged(var Msg: TMessage); message CM_PC_WalletKeysChanged;
     procedure CM_ConnectivityChanged(var Msg: TMessage); message CM_PC_ConnectivityChanged;
     procedure CM_ConnectivityChanged(var Msg: TMessage); message CM_PC_ConnectivityChanged;
@@ -109,7 +110,7 @@ type
     Function ForceMining : Boolean; virtual;
     Function ForceMining : Boolean; virtual;
     procedure SetMode(AMode: TFRMMainFormMode);
     procedure SetMode(AMode: TFRMMainFormMode);
   public
   public
-    property SyncControl : TFRMSyncronizationForm read FSyncControl;
+    property SyncControl : TCTRLSyncronization read FSyncControl;
     property Mode : TFRMMainFormMode read FMode write SetMode;
     property Mode : TFRMMainFormMode read FMode write SetMode;
     procedure OnFinishedLoadingDatabase;
     procedure OnFinishedLoadingDatabase;
   end;
   end;
@@ -134,9 +135,10 @@ begin
   __FLastFooterToolBarDrawRect := TRect.Empty;
   __FLastFooterToolBarDrawRect := TRect.Empty;
   CloseAction := caNone; // Will handle terminate in separate method
   CloseAction := caNone; // Will handle terminate in separate method
   FMode := wmSync;
   FMode := wmSync;
-  FSyncControl := TFRMSyncronizationForm.Create(self);
+  FSyncControl := TCTRLSyncronization.Create(self);
   paLogoPanel.AddControlDockCenter(TCTRLBanner.Create(Self));
   paLogoPanel.AddControlDockCenter(TCTRLBanner.Create(Self));
   paSyncPanel.AddControlDockCenter(FSyncControl);
   paSyncPanel.AddControlDockCenter(FSyncControl);
+  // note: wallet control is lazily constructed
 end;
 end;
 
 
 procedure TFRMMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
 procedure TFRMMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
@@ -219,18 +221,27 @@ end;
 procedure TFRMMainForm.SetMode(AMode: TFRMMainFormMode);
 procedure TFRMMainForm.SetMode(AMode: TFRMMainFormMode);
 var nestedForm : TForm;
 var nestedForm : TForm;
 begin
 begin
-  case AMode of
-    wmWallet: begin
-      paWalletPanel.Visible := true;
-      paSyncPanel.Visible := false;
-      FMode := AMode;
+  try
+    FUILock.Acquire;
+    case AMode of
+      wmWallet: begin
+        if NOT Assigned(FWalletControl) then begin
+          FWalletControl := TCTRLWallet.Create(self);
+          paWalletPanel.AddControlDockCenter(FWalletControl);
+        end;
+        paWalletPanel.Visible := true;
+        paSyncPanel.Visible := false;
+        FMode := AMode;
+      end;
+      wmSync: begin
+        paSyncPanel.Visible := true;
+        paWalletPanel.Visible := false;;
+        FMode := AMode;
+      end;
+      else raise Exception.Create('[Internal Error] - TFRMMainForm.SetMode: unsupported mode passed');
     end;
     end;
-    wmSync: begin
-      paSyncPanel.Visible := true;
-      paWalletPanel.Visible := false;;
-      FMode := AMode;
-    end;
-    else raise Exception.Create('[Internal Error] - TFRMMainForm.SetMode: unsupported mode passed');
+  finally
+    FUILock.Release;
   end;
   end;
 end;
 end;
 
 

+ 2 - 2
Units/Forms/UFRMWalletKeys.lfm

@@ -1,7 +1,7 @@
 object FRMWalletKeys: TFRMWalletKeys
 object FRMWalletKeys: TFRMWalletKeys
-  Left = 198
+  Left = 200
   Height = 477
   Height = 477
-  Top = 373
+  Top = 191
   Width = 661
   Width = 661
   Caption = 'Wallet Keys'
   Caption = 'Wallet Keys'
   ClientHeight = 477
   ClientHeight = 477

+ 49 - 0
Units/Forms/UGrids.pas

@@ -0,0 +1,49 @@
+unit UGrids;
+
+{$mode delphi}
+
+interface
+
+uses
+  Classes, SysUtils, UAccounts, UVisualGrid, UCommonUI, UCommon;
+
+type
+
+  TMyAccountDataSource = class(TComponent, IDataSource)
+    public
+      function FetchPage(constref AParams: TPageFetchParams; var ADataTable: TDataTable): TPageFetchResult;
+      function GetSearchCapabilities: TSearchCapabilities;
+  end;
+
+
+implementation
+
+uses UWallet,  UUserInterface;
+
+function TMyAccountDataSource.FetchPage(constref AParams: TPageFetchParams; var ADataTable: TDataTable): TPageFetchResult;
+var
+  key : Integer;
+  i : Integer;
+  accountsByKeys : TOrderedAccountKeysList;
+begin
+  ADataTable.Columns := TTableColumns.Create('Account', 'Key', 'Name', 'Balance');
+
+  accountsByKeys := TOrderedAccountKeysList.Create(TUserInterface.Node.Bank.SafeBox,false);
+
+  for key := 0 to TWallet.Keys.Count - 1 do begin
+//    accountsByKeys.AddAccountKey(TAccountKey(TWallet.Keys.Key[i]));
+  end;
+
+end;
+
+function TMyAccountDataSource.GetSearchCapabilities: TSearchCapabilities;
+begin
+   Result :=  TSearchCapabilities.Create(
+     TSearchCapability.From('Account', SORTABLE_NUMERIC_FILTER),
+     TSearchCapability.From('Balance', SORTABLE_NUMERIC_FILTER)
+   );
+end;
+
+
+end.
+

+ 1 - 1
Units/Forms/UUserInterface.pas

@@ -19,7 +19,7 @@ uses
   SysUtils, Classes, Forms, Controls, Windows, ExtCtrls, Dialogs,
   SysUtils, Classes, Forms, Controls, Windows, ExtCtrls, Dialogs,
   UCommonUI, UBlockChain, UAccounts, UNode, UWallet, UConst, UFolderHelper, UGridUtils, URPC, UPoolMining,
   UCommonUI, UBlockChain, UAccounts, UNode, UWallet, UConst, UFolderHelper, UGridUtils, URPC, UPoolMining,
   ULog, UThread, UNetProtocol, UCrypto,
   ULog, UThread, UNetProtocol, UCrypto,
-  UFRMMainForm, UFRMSyncronizationForm, UFRMAccountExplorer, UFRMOperationExplorer, UFRMPendingOperations, UFRMOperation,
+  UFRMMainForm, UCTRLSyncronization, UFRMAccountExplorer, UFRMOperationExplorer, UFRMPendingOperations, UFRMOperation,
   UFRMLogs, UFRMMessages, UFRMNodes, UFRMBlockExplorer, UFRMWalletKeys;
   UFRMLogs, UFRMMessages, UFRMNodes, UFRMBlockExplorer, UFRMWalletKeys;
 
 
 type
 type

+ 1 - 0
Units/Utils/UVisualGrid.pas

@@ -1848,5 +1848,6 @@ end;
 initialization
 initialization
   {$I *.inc}
   {$I *.inc}
 {$ENDIF}
 {$ENDIF}
+
 end.
 end.
 
 

+ 1 - 1
Units/Utils/UVisualGrid.rc

@@ -1 +1 @@
-VISUALGRID_SEARCH RCDATA "..\\resources\\search-16.png"
+VISUALGRID_SEARCH RCDATA "..\\..\\Resources\\WalletImages\\search-16x16.png"