📄 qjediinstallermain.pas
字号:
Result := nil
else
with Installation do
Result := FindComponent(TProductFrame.GetName(Installation)) as TProductFrame;
end;
procedure TMainForm.ReadSystemPaths;
var
PathVar: string;
I: Integer;
begin
if GetEnvironmentVar('PATH', PathVar, False) then
begin
StrToStrings(PathVar, PathSep, FSystemPaths, False);
for I := 0 to FSystemPaths.Count - 1 do
begin
PathVar := StrTrimQuotes(FSystemPaths[I]);
ExpandEnvironmentVar(PathVar);
{$IFDEF MSWINDOWS}
PathVar := AnsiUpperCase(PathRemoveSeparator(PathGetLongName(PathVar)));
{$ENDIF MSWINDOWS}
FSystemPaths[I] := PathVar;
end;
FSystemPaths.Sorted := True;
end;
end;
function TMainForm.SystemPathValid(const Path: string): Boolean;
begin
Result := FSystemPaths.IndexOf({$IFDEF MSWINDOWS}AnsiUpperCase{$ENDIF}(Path)) <> -1;
end;
procedure TMainForm.UpdateInfo(Installation: TJclBorRADToolInstallation; const InfoText: String);
var
P: TProductFrame;
begin
P := View(Installation);
if Assigned(P) then
begin
P.InfoDisplay.Text := InfoText;
end;
end;
procedure TMainForm.UpdateStatus(const Text: string);
begin
if Text = '' then
begin
StatusBevel.Visible := False;
StatusLabel.Visible := False;
end
else
begin
StatusLabel.Caption := Text;
StatusBevel.Visible := True;
StatusLabel.Visible := True;
end;
Application.ProcessMessages; //Update;
end;
procedure TMainForm.WriteInstallLog(Installation: TJclBorRADToolInstallation; const Text: string);
var
P: TProductFrame;
begin
P := View(Installation);
if Assigned(P) then
P.LogOutputLine(Text);
end;
function TMainForm.GetBPLPath(Installation: TJclBorRADToolInstallation): string;
var
P: TProductFrame;
Path: string;
begin
P := View(Installation);
if Assigned(P) then
Path := P.BplPathEdit.Text;
Result := PathRemoveSeparator(Installation.SubstitutePath(Path));
end;
function TMainForm.GetDCPPath(Installation: TJclBorRADToolInstallation): string;
var
P: TProductFrame;
Path: string;
begin
P := View(Installation);
if Assigned(P) then
Path := P.DcpPathEdit.Text;
Result := PathRemoveSeparator(Installation.SubstitutePath(Path));
end;
procedure TMainForm.BplPathEditChange(Sender: TObject);
begin
with (Sender as TEdit) do
if SystemPathValid(Text) then
Font.Color := clWindowText
else
Font.Color := clRed;
end;
function TMainForm.FeatureChecked(FeatureID: Cardinal; Installation: TJclBorRADToolInstallation): Boolean;
var
P: TProductFrame;
begin
Result := False;
P := View(Installation);
if Assigned(P) then
Result := P.FeatureChecked(FeatureID);
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnException := HandleException;
FBorRADToolInstallations := TJclBorRADToolInstallations.Create;
FSystemPaths := TStringList.Create;
JediImage.Hint := DelphiJediURL;
FJclInstall := CreateJclInstall;
FJclInstall.SetOnProgress(InstallationProgress);
FJclInstall.SetOnStarting(InstallationStarted);
FJclInstall.SetOnEnding(InstallationFinished);
FJclInstall.SetTool(Self);
BorRADToolInstallations.Iterate(ExpandOptionTree);
UpdateStatus('');
ReadSystemPaths;
//WindowState := wsMaximized; // wouldn't work in Form resource
Application.HintPause := 50;
Application.OnShowHint := ShowFeatureHint;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
FreeAndNil(FBorRADToolInstallations);
FreeAndNil(FSystemPaths);
end;
function TMainForm.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
begin
if QEvent_type(Event) = QEventType_UMCheckUpdates then
begin
BorRADToolInstallations.Iterate(CheckUpdatePack);
Result := True;
end
else
Result := inherited EventFilter(Sender, Event);
end;
procedure TMainForm.QuitBtnClick(Sender: TObject);
begin
Close;
end;
function TMainForm.ExpandOptionTree(
Installation: TJclBorRADToolInstallation): Boolean;
var
P: TProductFrame;
begin
Result := False;
P := View(Installation);
if Assigned(P) then
begin
P.UpdateTree;
Result := True;
end;
end;
procedure TMainForm.InstallBtnClick(Sender: TObject);
begin
if ({$IFDEF MSWINDOWS} IsDebuggerAttached or {$ENDIF} not CheckRunningInstances) and
(Dialog(RsConfirmInstall, dtConfirmation, [drYes, drNo]) = drYes) then
begin
Install;
QuitBtn.SetFocus;
end;
end;
procedure TMainForm.UninstallBtnClick(Sender: TObject);
begin
if ({$IFDEF MSWINDOWS} IsDebuggerAttached or {$ENDIF} not CheckRunningInstances) then
begin
Uninstall;
QuitBtn.SetFocus;
end;
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
QApplication_postEvent(Handle, QCustomEvent_create(QEventType_UMCheckUpdates, Self));
end;
procedure TMainForm.JediImageClick(Sender: TObject);
begin
{ TODO : implement for Unix }
{$IFDEF MSWINDOWS}
ShellExecEx(DelphiJediURL);
{$ENDIF MSWINDOWS}
end;
procedure TMainForm.TreeViewCollapsing(Sender: TObject; Node: TTreeNode;
var AllowCollapse: Boolean);
begin
AllowCollapse := Collapsable(Node);
end;
function TMainForm.GetBorRADToolInstallations: TJclBorRADToolInstallations;
begin
Result := FBorRADToolInstallations;
end;
procedure TMainForm.InstallationStarted(Installation: TJclBorRADToolInstallation);
var
P: TProductFrame;
begin
P := View(Installation);
P.InfoDisplay.Lines.Clear;
ProductsPageControl.ActivePage := P.Parent as TTabSheet;
P.StartCompilation(Installation);
end;
procedure TMainForm.InstallationFinished(Installation: TJclBorRADToolInstallation);
var
P: TProductFrame;
begin
P := View(Installation);
P.StopCompilation(Installation);
P.InfoDisplay.Lines.SaveToFile(JclInstall.LogFileName(Installation));
end;
function TMainForm.Dialog(const Text: string; DialogType: TDialogType = dtInformation;
Options: TDialogResponses = [drOK]): TDialogResponse;
const
DlgType: array[TDialogType] of TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation);
DlgButton: array[TDialogResponse] of TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel);
DlgResult: array[TDialogResponse] of Word = (mrYes, mrNo, mrOK, mrCancel);
var
Buttons: TMsgDlgButtons;
Res: Integer;
begin
Buttons := [];
for Result := Low(TDialogResponse) to High(TDialogResponse) do
if Result in Options then
Include(Buttons, DlgButton[Result]);
Res := MessageDlg(Text, DlgType[DialogType], Buttons, 0);
for Result := Low(TDialogResponse) to High(TDialogResponse) do
if DlgResult[Result] = Res then
Break;
end;
procedure TMainForm.SetBPLPath(Installation: TJclBorRADToolInstallation; const Value: string);
var
P: TProductFrame;
begin
P := View(Installation);
if Assigned(P) then
P.BplPathEdit.Text := Value;
end;
procedure TMainForm.SetDCPPath(Installation: TJclBorRADToolInstallation; const Value: string);
var
P: TProductFrame;
begin
P := View(Installation);
if Assigned(P) then
P.DcpPathEdit.Text := Value;
end;
procedure TMainForm.SetReadme(const FileName: string);
begin
ReadmePane.LoadFromFile(FileName);
{$IFDEF MSWINDOWS}
ShellExecEx('..\docs\Readme.html');
{$ENDIF MSWINDOWS}
end;
procedure TMainForm.TreeViewChange(Sender: TObject; Node: TTreeNode);
begin
UpdateFeatureInfo(Node);
end;
procedure TMainForm.TreeViewEnter(Sender: TObject);
begin
with ActiveView do
UpdateFeatureInfo(TreeView.Selected);
end;
procedure TMainForm.TreeViewExit(Sender: TObject);
begin
//
end;
procedure TMainForm.TreeViewMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
UpdateFeatureInfo(ActiveView.TreeView.GetNodeAt(X, Y));
end;
procedure TMainForm.UpdateFeatureInfo(Node: TTreeNode);
begin
if Assigned(Node) and (Node <> FFeatureNode) then
begin
FFeatureNode := Node;
FFeatureChanged := True;
end;
end;
procedure TMainForm.ShowFeatureHint;
var
View: TProductFrame;
begin
View := ActiveView;
if Assigned(View) and (HintInfo.HintControl = View.TreeView) then
begin
if FFeatureChanged then
begin
HintInfo.HintStr := FJclInstall.GetHint(TJediInstallOption(FeatureID(FFeatureNode) and $FF));
FHintPos := HintInfo.HintPos;
FFeatureChanged := False;
end
else
HintInfo.HintPos := FHintPos;
HintInfo.ReshowTimeout := 500;
end;
end;
function TMainForm.OptionGUI(
Installation: TJclBorRADToolInstallation): TObject;
begin
Result := View(Installation);
if Result = nil then
CreateView(Installation);
Result := View(Installation).TreeView.Items;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -