Bladeren bron

GUI: Initial wallet screen skeleton

Herman Schoenfeld 7 jaren geleden
bovenliggende
commit
2b12673fb5

+ 16 - 3
PascalCoinWallet.lpi

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

BIN
Resources/WalletImages/search-16x16.png


+ 2 - 2
Units/Forms/UCTRLBanner.lfm

@@ -1,7 +1,7 @@
 object CTRLBanner: TCTRLBanner
-  Left = 736
+  Left = 439
   Height = 80
-  Top = 26
+  Top = 23
   Width = 992
   BorderIcons = []
   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
-  Top = 5
+  Top = 0
   Width = 636
   BorderIcons = []
   BorderStyle = bsNone

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

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

+ 2 - 2
Units/Forms/UFRMMainForm.lfm

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

+ 26 - 15
Units/Forms/UFRMMainForm.pas

@@ -21,7 +21,7 @@ uses
   ULog,
   UBlockChain, UNode, UGridUtils, UAccounts, Menus,
   UNetProtocol, UCrypto, Buttons, ActnList, UPoolMining,
-  UCTRLBanner, UFRMSyncronizationForm, UCommon, UCommonUI;
+  UCTRLBanner, UCTRLWallet, UCTRLSyncronization, UCommon, UCommonUI;
 
 const
   CM_PC_FinishedLoadingDatabase = WM_USER + 1;
@@ -95,7 +95,8 @@ type
   private
     __FLastFooterToolBarDrawRect : TRect;  // Required for FPC bug work-around
     FMode : TFRMMainFormMode;
-    FSyncControl : TFRMSyncronizationForm;
+    FSyncControl : TCTRLSyncronization;
+    FWalletControl : TCTRLWallet;
     procedure CM_FinishedLoadingDatabase(var Msg: TMessage); message CM_PC_FinishedLoadingDatabase;
     procedure CM_WalletChanged(var Msg: TMessage); message CM_PC_WalletKeysChanged;
     procedure CM_ConnectivityChanged(var Msg: TMessage); message CM_PC_ConnectivityChanged;
@@ -109,7 +110,7 @@ type
     Function ForceMining : Boolean; virtual;
     procedure SetMode(AMode: TFRMMainFormMode);
   public
-    property SyncControl : TFRMSyncronizationForm read FSyncControl;
+    property SyncControl : TCTRLSyncronization read FSyncControl;
     property Mode : TFRMMainFormMode read FMode write SetMode;
     procedure OnFinishedLoadingDatabase;
   end;
@@ -134,9 +135,10 @@ begin
   __FLastFooterToolBarDrawRect := TRect.Empty;
   CloseAction := caNone; // Will handle terminate in separate method
   FMode := wmSync;
-  FSyncControl := TFRMSyncronizationForm.Create(self);
+  FSyncControl := TCTRLSyncronization.Create(self);
   paLogoPanel.AddControlDockCenter(TCTRLBanner.Create(Self));
   paSyncPanel.AddControlDockCenter(FSyncControl);
+  // note: wallet control is lazily constructed
 end;
 
 procedure TFRMMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
@@ -219,18 +221,27 @@ end;
 procedure TFRMMainForm.SetMode(AMode: TFRMMainFormMode);
 var nestedForm : TForm;
 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;
-    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;
 

+ 2 - 2
Units/Forms/UFRMWalletKeys.lfm

@@ -1,7 +1,7 @@
 object FRMWalletKeys: TFRMWalletKeys
-  Left = 198
+  Left = 200
   Height = 477
-  Top = 373
+  Top = 191
   Width = 661
   Caption = 'Wallet Keys'
   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,
   UCommonUI, UBlockChain, UAccounts, UNode, UWallet, UConst, UFolderHelper, UGridUtils, URPC, UPoolMining,
   ULog, UThread, UNetProtocol, UCrypto,
-  UFRMMainForm, UFRMSyncronizationForm, UFRMAccountExplorer, UFRMOperationExplorer, UFRMPendingOperations, UFRMOperation,
+  UFRMMainForm, UCTRLSyncronization, UFRMAccountExplorer, UFRMOperationExplorer, UFRMPendingOperations, UFRMOperation,
   UFRMLogs, UFRMMessages, UFRMNodes, UFRMBlockExplorer, UFRMWalletKeys;
 
 type

+ 1 - 0
Units/Utils/UVisualGrid.pas

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

+ 1 - 1
Units/Utils/UVisualGrid.rc

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