📄 qjediinstallermain.pas
字号:
{**************************************************************************************************}
{ WARNING: JEDI preprocessor generated unit. Do not edit. }
{**************************************************************************************************}
{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) extension }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is JediInstallerMain.pas. }
{ }
{ The Initial Developer of the Original Code is Petr Vones. Portions created by Petr Vones are }
{ Copyright (C) of Petr Vones. All Rights Reserved. }
{ }
{ Contributors: }
{ Andreas Hausladen (ahuser) }
{ Robert Rossmair (rrossmair) - crossplatform & BCB support, refactoring }
{ }
{**************************************************************************************************}
// $Id: JediInstallerMain.pas,v 1.28 2005/03/05 06:33:17 rrossmair Exp $
unit QJediInstallerMain;
{$I jcl.inc}
{$I crossplatform.inc}
interface
uses
{$IFDEF MSWINDOWS}
Windows, Messages,
{$ENDIF MSWINDOWS}
SysUtils, Classes,
Types,
Qt, QGraphics, QControls, QForms, QDialogs, QStdCtrls, QExtCtrls, QMenus, QButtons, QComCtrls, QImgList,
QProductFrames,
JclBorlandTools, JediInstall;
const
QEventType_UMCheckUpdates = QEventType(Integer(QEventType_ClxUser) + $100);
type
TMainForm = class(TForm, IJediInstallTool)
InstallBtn: TBitBtn;
UninstallBtn: TBitBtn;
QuitBtn: TBitBtn;
JediImage: TImage;
TitlePanel: TPanel;
Title: TLabel;
ProductsPageControl: TPageControl;
StatusBevel: TBevel;
StatusLabel: TLabel;
Bevel1: TBevel;
ProgressBar: TProgressBar;
ImageList: TImageList;
ReadmePage: TTabSheet;
ReadmePane: TTextViewer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure QuitBtnClick(Sender: TObject);
procedure InstallBtnClick(Sender: TObject);
procedure UninstallBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure JediImageClick(Sender: TObject);
procedure TreeViewCollapsing(Sender: TObject; Node: TTreeNode;
var AllowCollapse: Boolean);
procedure BplPathEditChange(Sender: TObject);
private
FBorRADToolInstallations: TJclBorRADToolInstallations;
FJclInstall: IJediInstall;
FSystemPaths: TStringList;
FFeatureNode: TTreeNode;
FFeatureChanged: Boolean;
FHintPos: TPoint;
function ActiveView: TProductFrame;
function CheckUpdatePack(Installation: TJclBorRADToolInstallation): Boolean;
function CreateView(Installation: TJclBorRADToolInstallation): Boolean;
function ExpandOptionTree(Installation: TJclBorRADToolInstallation): Boolean;
procedure InstallationStarted(Installation: TJclBorRADToolInstallation);
procedure InstallationFinished(Installation: TJclBorRADToolInstallation);
procedure InstallationProgress(Percent: Cardinal);
procedure ReadSystemPaths;
function View(Installation: TJclBorRADToolInstallation): TProductFrame;
procedure TreeViewChange(Sender: TObject; Node: TTreeNode);
procedure TreeViewEnter(Sender: TObject);
procedure TreeViewExit(Sender: TObject);
procedure TreeViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure UpdateFeatureInfo(Node: TTreeNode);
protected
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; override;
function InfoFile(Node: TTreeNode): string;
function OptionGUI(Installation: TJclBorRADToolInstallation): TObject;
function GUIAddOption(GUI, Parent: TObject; Option: TJediInstallOption; const Text: string;
GUIOptions: TJediInstallGUIOptions): TObject;
procedure HandleException(Sender: TObject; E: Exception);
property JclDistribution: IJediInstall read FJclInstall;
// IJediInstallTool
function GetBPLPath(Installation: TJclBorRADToolInstallation): string;
function GetDCPPath(Installation: TJclBorRADToolInstallation): string;
procedure SetBPLPath(Installation: TJclBorRADToolInstallation; const Value: string);
procedure SetDCPPath(Installation: TJclBorRADToolInstallation; const Value: string);
public
procedure ShowFeatureHint(var HintStr: WideString;
var CanShow: Boolean; var HintInfo: THintInfo);
function CheckRunningInstances: Boolean;
procedure Install;
procedure Uninstall;
function SystemPathValid(const Path: string): Boolean;
// IJediInstallTool
function FeatureChecked(FeatureID: Cardinal; Installation: TJclBorRADToolInstallation): Boolean;
function GetBorRADToolInstallations: TJclBorRADToolInstallations;
function Dialog(const Text: string; DialogType: TDialogType = dtInformation;
Options: TDialogResponses = [drOK]): TDialogResponse;
procedure SetReadme(const FileName: string);
procedure UpdateInfo(Installation: TJclBorRADToolInstallation; const InfoText: String);
procedure UpdateStatus(const Text: string);
procedure WriteInstallLog(Installation: TJclBorRADToolInstallation; const Text: string);
property BorRADToolInstallations: TJclBorRADToolInstallations read FBorRADToolInstallations;
property BPLPath[Installation: TJclBorRADToolInstallation]: string read GetBPLPath write SetBPLPath;
property DCPPath[Installation: TJclBorRADToolInstallation]: string read GetDCPPath write SetDCPPath;
end;
var
MainForm: TMainForm;
implementation
{$R *.xfm}
uses
{$IFDEF UNIX}
Libc,
{$ENDIF UNIX}
{$IFDEF MSWINDOWS}
FileCtrl,
JclDebug, JclShell,
{$ENDIF MSWINDOWS}
JclBase, JclFileUtils, JclStrings, JclSysInfo, JclSysUtils,
JclInstall;
const
{$IFNDEF RTL140_UP}
PathSep = ';';
{$ENDIF RTL140_UP}
{$IFDEF MSWINDOWS}
SupportURLs: array[TJclBorRADToolKind] of string = (
'http://www.borland.com/devsupport/delphi/',
'http://www.borland.com/devsupport/bcppbuilder/');
{$ENDIF MSWINDOWS}
{$IFDEF KYLIX}
KylixSupportURL = 'http://www.borland.com/devsupport/kylix/';
{$ENDIF KYLIX}
DelphiJediURL = 'http://delphi-jedi.org';
VersionSignature = 'D%d';
BCBTag = $10000;
VersionMask = $FFFF;
function FeatureID(Node: TTreeNode): Cardinal;
begin
Result := Cardinal(Node.Data) and FID_NumberMask;
end;
{ TMainForm }
function TMainForm.ActiveView: TProductFrame;
var
Page: TTabSheet;
Control: TControl;
begin
Result := nil;
Page := ProductsPageControl.ActivePage;
Control := Page.Controls[0];
if Control is TProductFrame then
Result := TProductFrame(Control);
end;
function TMainForm.InfoFile(Node: TTreeNode): string;
begin
if Assigned(Node) then
Result := FJclInstall.FeatureInfoFileName(FeatureID(Node));
end;
function TMainForm.CreateView(Installation: TJclBorRADToolInstallation): Boolean;
var
Page: TTabSheet;
ProductFrame: TProductFrame;
begin
Page := TTabSheet.Create(Self);
with Installation do
begin
Page.Name := Format('%s%dPage', [Prefixes[RADToolKind], VersionNumber]);
Page.Caption := Name;
end;
Page.PageControl := ProductsPageControl;
ProductFrame := TProductFrame.Create(Self);
ProductFrame.Installation := Installation;
ProductFrame.TreeView.Images := ImageList;
ProductFrame.TreeView.OnChange := TreeViewChange;
ProductFrame.TreeView.OnCollapsing := TreeViewCollapsing;
ProductFrame.TreeView.OnEnter := TreeViewEnter;
ProductFrame.TreeView.OnExit := TreeViewExit;
ProductFrame.TreeView.OnMouseMove := TreeViewMouseMove;
ProductFrame.Align := alClient;
ProductFrame.Parent := Page;
FJclInstall.SetOnWriteLog(Installation, ProductFrame.LogOutputLine);
Result := True;
end;
function TMainForm.CheckRunningInstances: Boolean;
begin
Result := FBorRADToolInstallations.AnyInstanceRunning;
if Result then
Dialog(RsCloseRADTool, dtWarning);
end;
function TMainForm.CheckUpdatePack(Installation: TJclBorRADToolInstallation): Boolean;
var
Msg: string;
begin
Result := True;
with Installation do
if UpdateNeeded then
begin
Msg := Format(RsUpdateNeeded, [LatestUpdatePack, Name]);
if Dialog(Msg, dtWarning, [drYes, drNo]) = drYes then
{$IFDEF MSWINDOWS}
ShellExecEx(SupportURLs[RadToolKind]);
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
{ TODO : Analoguous function for Linux };
// Exec(KylixSupportURL);
{$ENDIF UNIX}
end;
end;
function TMainForm.GUIAddOption(GUI, Parent: TObject; Option: TJediInstallOption;
const Text: string; GUIOptions: TJediInstallGUIOptions): TObject;
const
Icon: array[Boolean] of Integer = (IcoUnchecked, IcoChecked);
Flag: array[Boolean] of Cardinal = (0, FID_Checked);
var
FeatureID: Cardinal;
Nodes: TTreeNodes;
Node, ParentNode: TTreeNode;
Checked: Boolean;
begin
ParentNode := TTreeNode(Parent);
Checked := goChecked in GUIOptions;
if Assigned(Parent) then
begin
Assert(Parent is TTreeNode);
if Checked and Assigned(Parent) then
if ParentNode.ImageIndex <> IcoChecked then
begin
Checked := False;
Exclude(GUIOptions, goChecked);
end;
end;
FeatureID := Cardinal(Ord(Option)) + Flag[goChecked in GUIOptions];
if goStandAloneParent in GUIOptions then
FeatureID := FeatureID + FID_StandAloneParent;
if goRadioButton in GUIOptions then
FeatureID := FeatureID + FID_RadioButton;
if goExpandable in GUIOptions then
FeatureID := FeatureID + FID_Expandable;
Nodes := TTreeNodes(GUI);
if Parent = nil then
Node := Nodes.AddObject(nil, Text, Pointer(FeatureID))
else
Node := Nodes.AddChildObject(ParentNode, Text, Pointer(FeatureID));
Node.ImageIndex := Icon[Checked];
Node.SelectedIndex := Icon[Checked];
Result := Node;
end;
procedure TMainForm.HandleException(Sender: TObject; E: Exception);
begin
if E is EJediInstallInitFailure then
begin
Dialog(E.Message, dtError);
Application.ShowMainForm := False;
Application.Terminate;
end
else
Application.ShowException(E);
end;
procedure TMainForm.Install;
var
Res: Boolean;
begin
ProgressBar.Position := 0;
ProgressBar.Visible := True;
Screen.Cursor := crHourGlass;
try
Res := FJclInstall.Install;
Screen.Cursor := crDefault;
if Res then
Dialog(RsInstallSuccess)
else
Dialog(RsInstallFailure);
finally
ProgressBar.Visible := False;
Screen.Cursor := crDefault;
end;
end;
procedure TMainForm.Uninstall;
begin
ProgressBar.Position := 0;
ProgressBar.Visible := True;
Screen.Cursor := crHourGlass;
try
FJclInstall.Uninstall;
Screen.Cursor := crDefault;
finally
ProgressBar.Visible := False;
Screen.Cursor := crDefault;
end;
end;
procedure TMainForm.InstallationProgress(Percent: Cardinal);
begin
ProgressBar.Position := Percent;
end;
function TMainForm.View(Installation: TJclBorRADToolInstallation): TProductFrame;
begin
if not Assigned(Installation) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -