uinfoview.pas

来自「FMA is a free1 powerful phone editing to」· PAS 代码 · 共 915 行 · 第 1/2 页

PAS
915
字号
unit uInfoView;

{
*******************************************************************************
* Descriptions: Phone Info view implementation
* $Source: /cvsroot/fma/fma/uInfoView.pas,v $
* $Locker:  $
*
* Todo:
*
* Change Log:
* $Log: uInfoView.pas,v $
*
*******************************************************************************
}

interface

uses
  Windows, TntWindows, Messages, SysUtils, TntSysUtils, Classes, TntClasses, Graphics, TntGraphics, Controls, TntControls, Forms, TntForms, Dialogs, TntDialogs,
  StdCtrls, TntStdCtrls, ExtCtrls, TntExtCtrls, TeEngine, Series, TeeProcs, Chart, ComCtrls, TntComCtrls, UniTntCtrls,
  ImgList, jpeg, Buttons, TntButtons, LMDControl, LMDBaseControl,
  LMDBaseGraphicControl, LMDGraphicControl, LMDBaseMeter,
  LMDCustomProgressFill, LMDProgressFill, LMDFill, Menus, TntMenus, VirtualTrees,
  cUnicodeCodecs;

type
  TfrmInfoView = class(TTntFrame)
    Panel1: TTntPanel;
    Panel2: TTntPanel;
    TodayCaptionPanel: TTntPanel;
    wOperator: TTntLabel;
    wSignal: TTntLabel;
    SignalImage: TTntImage;
    wDate: TTntLabel;
    lblTitle: TTntLabel;
    Image1: TTntImage;
    LMDFill2: TLMDFill;
    PopupMenu2: TTntPopupMenu;
    CallContact1: TTntMenuItem;
    MessageContact1: TTntMenuItem;
    Splitter1: TTntSplitter;
    InboxPanel: TTntPanel;
    Label17: TTntLabel;
    Label10: TTntLabel;
    Bevel2: TTntBevel;
    Image3: TTntImage;
    Label11: TTntLabel;
    wInboxNew: TTntLabel;
    CallsPanel: TTntPanel;
    Label15: TTntLabel;
    Label21: TTntLabel;
    Bevel4: TTntBevel;
    Image5: TTntImage;
    Label22: TTntLabel;
    wRecentCallsNum: TTntLabel;
    lvCalls: TTntListView;
    BatteryPanel: TTntPanel;
    Label26: TTntLabel;
    Label27: TTntLabel;
    Bevel6: TTntBevel;
    Image7: TTntImage;
    Label5: TTntLabel;
    Label3: TTntLabel;
    Label2: TTntLabel;
    Label4: TTntLabel;
    Label7: TTntLabel;
    Label1: TTntLabel;
    Label28: TTntLabel;
    Label29: TTntLabel;
    Label8: TTntLabel;
    Label35: TTntLabel;
    wCharge: TTntLabel;
    lblTimeLeft: TTntLabel;
    wBattery: TTntLabel;
    lbPower: TTntLabel;
    lbvbat: TTntLabel;
    lbdcio: TTntLabel;
    lbcyclescharge: TTntLabel;
    lbicharge: TTntLabel;
    lbiphone: TTntLabel;
    lbtempbatt: TTntLabel;
    Splitter2: TTntSplitter;
    Splitter3: TTntSplitter;
    OuboxPanel: TTntPanel;
    Label18: TTntLabel;
    Label19: TTntLabel;
    Bevel3: TTntBevel;
    Image4: TTntImage;
    Label20: TTntLabel;
    wOutboxNew: TTntLabel;
    MissedCallsPanel: TTntPanel;
    lvMissed: TTntListView;
    Label24: TTntLabel;
    Label25: TTntLabel;
    Label23: TTntLabel;
    Image6: TTntImage;
    wMissedCallsNum: TTntLabel;
    Bevel5: TTntBevel;
    PhoneAddressPanel: TTntPanel;
    BigImage: TTntImage;
    Splitter4: TTntSplitter;
    Splitter5: TTntSplitter;
    Label32: TTntLabel;
    Label33: TTntLabel;
    Image9: TTntImage;
    Bevel1: TTntBevel;
    wMENum: TTntLabel;
    AddToPhonebook1: TTntMenuItem;
    N1: TTntMenuItem;
    N2: TTntMenuItem;
    Refresh1: TTntMenuItem;
    N3: TTntMenuItem;
    Properties1: TTntMenuItem;
    Image10: TTntImage;
    Image11: TTntImage;
    Image12: TTntImage;
    Image13: TTntImage;
    Image14: TTntImage;
    Image15: TTntImage;
    ImageList1: TImageList;
    ChatContact1: TTntMenuItem;
    Image8: TTntImage;
    Label6: TTntLabel;
    Label12: TTntLabel;
    Label13: TTntLabel;
    Label16: TTntLabel;
    Label14: TTntLabel;
    lbSerialNumber: TTntLabel;
    lbSWRevision: TTntLabel;
    lbModel: TTntLabel;
    lbManufacturer: TTntLabel;
    lbtempphone: TTntLabel;
    Label30: TTntLabel;
    Label31: TTntLabel;
    Label34: TTntLabel;
    Label36: TTntLabel;
    Label37: TTntLabel;
    wArchiveNum: TTntLabel;
    Image16: TTntImage;
    Image17: TTntImage;
    Image18: TTntImage;
    Image19: TTntImage;
    Label38: TTntLabel;
    DiagramPanel: TTntPanel;
    Chart1: TChart;
    Series1: TLineSeries;
    Series3: TLineSeries;
    Series2: TLineSeries;
    linkGetMessages: TTntLabel;
    linkJumpInbox: TTntLabel;
    linkJumpArchive: TTntLabel;
    linkComposeMessage: TTntLabel;
    linkSendMessages: TTntLabel;
    linkShowNewMessages: TTntLabel;
    linkSyncPhonebook: TTntLabel;
    linkNewContact: TTntLabel;
    linkShowPhonebook: TTntLabel;
    linkJumpOutbox: TTntLabel;
    linkShowSIM: TTntLabel;
    linkShowCalendar: TTntLabel;
    linkSyncCalendar: TTntLabel;
    linkShowBookmarks: TTntLabel;
    linkNewTask: TTntLabel;
    linkSyncOutlook: TTntLabel;
    linkNewEvent: TTntLabel;
    linkWhatsNext: TTntLabel;
    linkShowFiles: TTntLabel;
    linkNewNote: TTntLabel;
    linkSyncBookmarks: TTntLabel;
    linkSyncAll: TTntLabel;
    linkJumpSent: TTntLabel;
    BatteryPanelLeft: TTntPanel;
    BatteryPanelRight: TTntPanel;
    procedure ListViewResize(Sender: TObject);
    procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
    procedure FrameResize(Sender: TObject);
    procedure Refresh1Click(Sender: TObject);
    procedure PopupMenu2Popup(Sender: TObject);
    procedure Properties1Click(Sender: TObject);
    procedure SplitterPaint(Sender: TObject);
    procedure OpenCloseImageClick(Sender: TObject);
    procedure TodayCaptionPanelResize(Sender: TObject);
    procedure linkGetMessagesClick(Sender: TObject);
    procedure linkJumpMsgFolderClick(Sender: TObject);
    procedure linkComposeMessageClick(Sender: TObject);
    procedure linkSendMessagesClick(Sender: TObject);
    procedure linkSyncPhonebookClick(Sender: TObject);
    procedure linkShowPhonebookClick(Sender: TObject);
    procedure linkNewContactClick(Sender: TObject);
    procedure linkShowSIMClick(Sender: TObject);
    procedure linkShowCalendarClick(Sender: TObject);
    procedure linkSyncCalendarClick(Sender: TObject);
    procedure linkShowBookmarksClick(Sender: TObject);
    procedure linkNewTaskClick(Sender: TObject);
    procedure linkSyncOutlookClick(Sender: TObject);
    procedure linkNewEventClick(Sender: TObject);
    procedure linkWhatsNextClick(Sender: TObject);
    procedure linkShowFilesClick(Sender: TObject);
    procedure linkNewNoteClick(Sender: TObject);
    procedure linkSyncAllClick(Sender: TObject);
    procedure linkSyncBookmarksClick(Sender: TObject);
    procedure linkJumpSentClick(Sender: TObject);
    procedure BatteryPanelResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure GetIdent;
    procedure UpdateWelcomePage(Init: boolean = False);
  end;

implementation

uses
  gnugettext, gnugettexthelpers, uThreadSafe, uConnProgress,
  uGlobal, Unit1, uMissedCalls, uCalling, uSyncPhonebook, uSIMEdit, uComposeSMS;

{$R *.dfm}

{ TfrmInfoView }

procedure TfrmInfoView.GetIdent;
begin
  try
    Form1.TxAndWait('AT+CGMI'); // do not localize
    lbManufacturer.Caption := ThreadSafe.RxBuffer[0];
  except
    lbManufacturer.Caption := '?'; //TODO -cl10n: localize?
  end;

  try
    Form1.TxAndWait('AT+CGMM'); // do not localize
    lbModel.Caption := ThreadSafe.RxBuffer[0];
  except
    lbModel.Caption := '?'; //TODO -cl10n: localize?
  end;

  try
    Form1.TxAndWait('AT+CGMR'); // do not localize
    lbSWRevision.Caption := ThreadSafe.RxBuffer[0];
  except
    lbSWRevision.Caption := '?'; //TODO -cl10n: localize?
  end;

  try
    Form1.TxAndWait('AT+CGSN'); // do not localize
    lbSerialNumber.Caption := ThreadSafe.RxBuffer[0];
  except
    lbSerialNumber.Caption := '?'; //TODO -cl10n: localize?
  end;
end;

procedure TfrmInfoView.UpdateWelcomePage(Init: boolean);
var
  i: integer;
  s: WideString;
  Node: PVirtualNode;
  EData, EData2: PFmaExplorerNode;
  function GetNewSMSCount(Node: PVirtualNode): Integer;
  var
    c: Integer;
    itNode: PVirtualNode;
    data: PFmaExplorerNode;
  begin
    c := Form1.GetNewMessagesCounter(Node);
    itNode := Node.FirstChild;
    while itNode <> nil do begin
      data := Form1.ExplorerNew.GetNodeData(itNode);
      if data.StateIndex = FmaSMSSubFolderFlag then
        c := c + GetNewSMSCount(itNode);
      itNode := itNode.NextSibling;
    end;
    Result := c;
  end;
  procedure AddCallsItem(Target: TTntListView);
  var
    ws: WideString;
  begin
    with Target.Items.Add do begin
      ImageIndex := EData.ImageIndex;
      if Form1.FUseUTF8 then
        ws := UTF8StringToWideString(TStrings(EData2.Data)[EData.StateIndex-1])
      else
        ws := TStrings(EData2.Data)[EData.StateIndex-1];
      Caption := GetFirstToken(ws);
      SubItems.Add(GetFirstToken(ws));
    end;
  end;
begin
  { Signal and Power }
  if Form1.FConnectingComplete then begin
    i := Form1.pbRSSI.Position;
    if Form1.FUseCSQ and (i <> 0) then
      wSignal.Caption := IntToStr(i)+'%'
    else
      wSignal.Caption := _('N/A');
    if Form1.FUseCBC then begin
      wBattery.Caption := IntToStr(Form1.pbPower.Position)+'%';
      if Form1.FOnACPower then wCharge.Caption := _('yes')
        else wCharge.Caption := _('no');
    end
    else begin
      wBattery.Caption := _('N/A');
      wCharge.Caption := _('N/A');
      lblTimeLeft.Caption := _('N/A');
    end;
    if Form1.FBatteryLow then
      wBattery.Font.Color := clRed
    else
      wBattery.ParentFont := True;
  end
  else begin
    wSignal.Caption := '?';
    wBattery.Caption := '?';
    wCharge.Caption := '?';
    //lblTimeLeft.Caption := '?';
  end;
  { Inbox and Outbox }
  i := GetNewSMSCount(Form1.FNodeMsgPhoneRoot) + GetNewSMSCount(Form1.FNodeMsgInbox) +
    GetNewSMSCount(Form1.FNodeMsgSent) + GetNewSMSCount(Form1.FNodeMsgArchive);
  if i <> 0 then begin
    wInboxNew.Caption := IntToStr(i);
    wInboxNew.Font.Style := wInboxNew.Font.Style + [fsBold];
    wInboxNew.Font.Color := clRed;
    linkShowNewMessages.Enabled := True;
  end
  else begin
    wInboxNew.Caption := _('none');
    wInboxNew.ParentFont := True;
    linkShowNewMessages.Enabled := False;
  end;
  i := Form1.GetNewMessagesCounter(Form1.FNodeMsgOutbox);
  if i <> 0 then begin
    wOutboxNew.Caption := IntToStr(i);
    wOutboxNew.Font.Style := wInboxNew.Font.Style + [fsBold];
    wOutboxNew.Font.Color := clRed;
    linkSendMessages.Enabled := True;
  end
  else begin
    wOutboxNew.Caption := _('none');
    wOutboxNew.ParentFont := True;
    linkSendMessages.Enabled := False;
  end;
  { Calls }
  if Form1.ActionMissedCalls.Enabled and (frmMissedCalls <> nil) and (frmMissedCalls.RecentMissedCalls <> 0) then begin
    i := frmMissedCalls.RecentMissedCalls;
    wMissedCallsNum.Caption := IntToStr(i);
    wMissedCallsNum.Font.Style := wMissedCallsNum.Font.Style + [fsBold];
    wMissedCallsNum.Font.Color := clRed;
  end
  else begin
    wMissedCallsNum.Caption := _('none');
    wMissedCallsNum.ParentFont := True;
  end;
  { Address book }
  if not Form1.FStartupOptions.NoObex and not Form1.FStartupOptions.NoIRMC then
    i := Form1.frmSyncPhonebook.ListContacts.RootNodeCount
  else begin
    EData := Form1.ExplorerNew.GetNodeData(Form1.FNodeContactsME);
    i := TStrings(EData.Data).Count;
  end;
  wMENum.Caption := IntToStr(i);
  EData := Form1.ExplorerNew.GetNodeData(Form1.FNodeMsgArchive);
  wArchiveNum.Caption := IntToStr(TStrings(EData.Data).Count); { TODO: Add long SMS support }
  { Today page components }
  if Form1.FShowDiagram {and Form1.CanUseEBCA(True)} then begin
    if DiagramPanel.Width = 0 then begin
      DiagramPanel.Width := 250;
      DiagramPanel.Left := LMDFill2.Left + LMDFill2.Width;
      wSignal.Left := wSignal.Left - DiagramPanel.Width;
      wOperator.Left := wOperator.Left - DiagramPanel.Width;
      SignalImage.Left := SignalImage.Left - DiagramPanel.Width;
      if not Form1.FShowTodayCaption then
        Form1.ShowCaption1.Click;
      Chart1.Left := 4;
      Chart1.Width := DiagramPanel.Width - 9;  
    end;
  end
  else begin
    if DiagramPanel.Width <> 0 then begin
      wSignal.Left := wSignal.Left + DiagramPanel.Width;
      wOperator.Left := wOperator.Left + DiagramPanel.Width;
      SignalImage.Left := SignalImage.Left + DiagramPanel.Width;
      DiagramPanel.Width := 0;
      LMDFill2.Left := 80;
    end;
  end;
  TodayCaptionPanel.Visible := Form1.FShowTodayCaption;
  { Initial update when Welcome page is shown }
  if Init then begin
    if not IsRightToLeft then
      begin
        { Inbox }
        linkJumpArchive.Left := linkJumpInbox.Left + linkJumpInbox.Width + 8;
        linkGetMessages.Left := linkJumpArchive.Left + linkJumpArchive.Width + 8;
        { Outbox }
        linkJumpSent.Left := linkComposeMessage.Left + linkComposeMessage.Width + 8;
        linkJumpOutbox.Left := linkJumpSent.Left + linkJumpSent.Width + 8;
        { My Data }
        linkNewTask.Left := linkNewContact.Left + linkNewContact.Width + 8;
        linkNewEvent.Left := linkNewTask.Left + linkNewTask.Width + 8;
        linkNewNote.Left := linkNewEvent.Left + linkNewEvent.Width + 8;
        // 2nd row
        linkShowSIM.Left := linkShowPhonebook.Left + linkShowPhonebook.Width + 8;
        linkShowCalendar.Left := linkShowSIM.Left + linkShowSIM.Width + 8;
        linkShowBookmarks.Left := linkShowCalendar.Left + linkShowCalendar.Width + 8;
        linkShowFiles.Left := linkShowBookmarks.Left + linkShowBookmarks.Width + 8;
        // 3rd row
        linkSyncCalendar.Left := linkSyncPhonebook.Left + linkSyncPhonebook.Width + 8;
        linkSyncBookmarks.Left := linkSyncCalendar.Left + linkSyncCalendar.Width + 8;
        linkSyncOutlook.Left := linkSyncBookmarks.Left + linkSyncBookmarks.Width + 8;
        linkSyncAll.Left := linkSyncOutlook.Left + linkSyncOutlook.Width + 8;
      end
    else
      begin
        (*
        linkJumpArchive.Left := linkJumpInbox.Left - linkJumpArchive.Width - 8;
        linkGetMessages.Left := linkJumpArchive.Left - linkGetMessages.Width - 8;
        linkJumpOutbox.Left := linkComposeMessage.Left - linkJumpOutbox.Width - 8;
        linkShowPhonebook.Left := linkNewContact.Left - linkShowPhonebook.Width - 8;
        linkShowSIM.Left := linkShowPhonebook.Left - linkShowSIM.Width - 8;
        //linkCalendar.Left := linkShowSIM.Left - linkCalendar.Width - 8;
        *)
      end;
    { Date and Operator }
    wDate.Caption := FormatDateTime(LongDateFormat,Date);
    s := Form1.FSelOperator;
    if s = '' then s := '?';
    wOperator.Caption := s;
    try
      { Calls }
      lvCalls.Items.BeginUpdate;
      try
        lvCalls.Clear;
        EData2 := Form1.ExplorerNew.GetNodeData(Form1.FNodeCallsIn);
        Node := Form1.FNodeCallsIn.FirstChild;
        while Node <> nil do begin
          EData := Form1.ExplorerNew.GetNodeData(Node);
          AddCallsItem(lvCalls);
          Node := Node.NextSibling;
        end;

        EData2 := Form1.ExplorerNew.GetNodeData(Form1.FNodeCallsOut);
        Node := Form1.FNodeCallsOut.FirstChild;
        while Node <> nil do begin
          EData := Form1.ExplorerNew.GetNodeData(Node);
          AddCallsItem(lvCalls);
          Node := Node.NextSibling;
        end;
        wRecentCallsNum.Caption := IntToStr(lvCalls.Items.Count);
      finally
        lvCalls.AlphaSort;
        lvCalls.Items.EndUpdate;
      end;
      lvMissed.Items.BeginUpdate;
      try

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?