IDE: Custom IDE title, added preview

This commit is contained in:
Martin 2024-10-28 14:07:55 +01:00
parent 01d301d685
commit b83d624eee
3 changed files with 107 additions and 10 deletions

View File

@ -158,5 +158,56 @@ object WindowOptionsFrame: TWindowOptionsFrame
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 7 TabOrder = 7
OnChange = EdTitleBarChange
end
object lbTitlePreviewHeader: TLabel
AnchorSideLeft.Control = EdTitleBar
AnchorSideTop.Control = EdTitleBar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 15
Top = 216
Width = 573
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 10
Caption = 'lbTitlePreviewHeader'
end
object pnlTitlePreview: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lbTitlePreviewHeader
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 25
Top = 231
Width = 573
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BevelInner = bvRaised
BevelOuter = bvLowered
ClientHeight = 25
ClientWidth = 573
Color = clWindow
ParentBackground = False
ParentColor = False
TabOrder = 8
object lbTitlePreview: TLabel
AnchorSideLeft.Control = pnlTitlePreview
AnchorSideTop.Control = pnlTitlePreview
AnchorSideRight.Control = pnlTitlePreview
AnchorSideRight.Side = asrBottom
Left = 5
Height = 15
Top = 5
Width = 563
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 3
Caption = 'lbTitlePreview'
Transparent = False
WordWrap = True
end
end end
end end

View File

@ -27,15 +27,15 @@ interface
uses uses
SysUtils, SysUtils,
// LCL // LCL
Forms, StdCtrls, InterfaceBase, Forms, StdCtrls, InterfaceBase, ExtCtrls, Controls,
// LazControls // LazControls
DividerBevel, DividerBevel,
// IdeIntf // IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEOptionsIntf, IDEOptEditorIntf, LazStringUtils,
// IdeConfig // IdeConfig
EnvironmentOpts, EnvironmentOpts, LazConf, TransferMacros,
// IDE // IDE
LazarusIDEStrConsts, EnvGuiOptions; LazarusIDEStrConsts, EnvGuiOptions, Classes;
type type
{ TWindowOptionsFrame } { TWindowOptionsFrame }
@ -44,7 +44,10 @@ type
AutoAdjustIDEHeightFullCompPalCheckBox: TCheckBox; AutoAdjustIDEHeightFullCompPalCheckBox: TCheckBox;
bvWindowTitle: TDividerBevel; bvWindowTitle: TDividerBevel;
EdTitleBar: TComboBox; EdTitleBar: TComboBox;
lbTitlePreviewHeader: TLabel;
lbTitlePreview: TLabel;
lblTitleBar: TLabel; lblTitleBar: TLabel;
pnlTitlePreview: TPanel;
ProjectInspectorShowPropsCheckBox: TCheckBox; ProjectInspectorShowPropsCheckBox: TCheckBox;
lblShowingWindows: TDividerBevel; lblShowingWindows: TDividerBevel;
NameForDesignedFormListCheckBox: TCheckBox; NameForDesignedFormListCheckBox: TCheckBox;
@ -52,6 +55,7 @@ type
HideIDEOnRunCheckBox: TCheckBox; HideIDEOnRunCheckBox: TCheckBox;
SingleTaskBarButtonCheckBox: TCheckBox; SingleTaskBarButtonCheckBox: TCheckBox;
TitleStartsWithProjectCheckBox: TCheckBox; TitleStartsWithProjectCheckBox: TCheckBox;
procedure EdTitleBarChange(Sender: TObject);
public public
function GetTitle: String; override; function GetTitle: String; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
@ -66,6 +70,44 @@ implementation
{ TWindowOptionsFrame } { TWindowOptionsFrame }
procedure TWindowOptionsFrame.EdTitleBarChange(Sender: TObject);
function AddToCaption(const CurrentCaption, CaptAddition: string): String;
begin
if TitleStartsWithProjectCheckBox.Checked then
Result := CaptAddition + ' - ' + CurrentCaption
else
Result := CurrentCaption + ' - ' + CaptAddition;
end;
var
rev, NewCaption: String;
CustomCaption: TCaption;
OldMarkUnhandledMacros: Boolean;
begin
if GlobalMacroList = nil then
exit;
rev := LazarusRevisionStr;
if IsNumber(rev) then
NewCaption := Format(lisLazarusEditorV + ' r%s',
[LazarusVersionStr, rev])
else
NewCaption := Format(lisLazarusEditorV, [LazarusVersionStr]);
CustomCaption := EdTitleBar.Text;
if CustomCaption <> '' then begin
OldMarkUnhandledMacros := GlobalMacroList.MarkUnhandledMacros;
GlobalMacroList.MarkUnhandledMacros := false;
GlobalMacroList.SubstituteStr(CustomCaption, 0, 0, True);
if CustomCaption <> '' then begin
NewCaption := AddToCaption(NewCaption, CustomCaption);
end;
GlobalMacroList.MarkUnhandledMacros := OldMarkUnhandledMacros;
end;
lbTitlePreview.Caption := NewCaption;
end;
function TWindowOptionsFrame.GetTitle: String; function TWindowOptionsFrame.GetTitle: String;
begin begin
Result := dlgWindow; Result := dlgWindow;
@ -93,6 +135,9 @@ begin
AutoAdjustIDEHeightFullCompPalCheckBox.Caption:=lisAutoAdjustIDEHeightFullComponentPalette; AutoAdjustIDEHeightFullCompPalCheckBox.Caption:=lisAutoAdjustIDEHeightFullComponentPalette;
AutoAdjustIDEHeightFullCompPalCheckBox.Hint:=lisAutoAdjustIDEHeightFullComponentPaletteHint; AutoAdjustIDEHeightFullCompPalCheckBox.Hint:=lisAutoAdjustIDEHeightFullComponentPaletteHint;
ProjectInspectorShowPropsCheckBox.Caption:=lisProjectInspectorShowProps; ProjectInspectorShowPropsCheckBox.Caption:=lisProjectInspectorShowProps;
lbTitlePreviewHeader.Caption := dlgWRDPreview;
lbTitlePreviewHeader.Visible := GlobalMacroList <> nil;
pnlTitlePreview.Visible := GlobalMacroList <> nil;
EdTitleBar.AddItem('$project(TitleNew)', nil); EdTitleBar.AddItem('$project(TitleNew)', nil);
EdTitleBar.AddItem('$project(TitleNew) $EncloseBracket($project(infodir))', nil); EdTitleBar.AddItem('$project(TitleNew) $EncloseBracket($project(infodir))', nil);
@ -125,6 +170,7 @@ begin
AutoAdjustIDEHeightFullCompPalCheckBox.Checked := AutoAdjustIDEHeightFullCompPal; AutoAdjustIDEHeightFullCompPalCheckBox.Checked := AutoAdjustIDEHeightFullCompPal;
ProjectInspectorShowPropsCheckBox.Checked := ProjectInspectorShowProps; ProjectInspectorShowPropsCheckBox.Checked := ProjectInspectorShowProps;
end; end;
EdTitleBarChange(nil);
end; end;
procedure TWindowOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions); procedure TWindowOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);

View File

@ -9022,7 +9022,7 @@ procedure TMainIDE.UpdateCaption;
end; end;
var var
rev, NewCaption, DirName, CustomnCaption: String; rev, NewCaption, DirName, CustomCaption: String;
OldMarkUnhandledMacros: boolean; OldMarkUnhandledMacros: boolean;
begin begin
if MainIDEBar = nil then Exit; if MainIDEBar = nil then Exit;
@ -9037,13 +9037,13 @@ begin
NewCaption := AddToCaption(NewCaption, MainBarSubTitle); NewCaption := AddToCaption(NewCaption, MainBarSubTitle);
if (GlobalMacroList <> nil) then begin if (GlobalMacroList <> nil) then begin
CustomnCaption := EnvironmentGuiOpts.Desktop.IDETitleBarCustomText; CustomCaption := EnvironmentGuiOpts.Desktop.IDETitleBarCustomText;
if CustomnCaption <> '' then begin if CustomCaption <> '' then begin
OldMarkUnhandledMacros := GlobalMacroList.MarkUnhandledMacros; OldMarkUnhandledMacros := GlobalMacroList.MarkUnhandledMacros;
GlobalMacroList.MarkUnhandledMacros := false; GlobalMacroList.MarkUnhandledMacros := false;
GlobalMacroList.SubstituteStr(CustomnCaption, 0, 0, True); GlobalMacroList.SubstituteStr(CustomCaption, 0, 0, True);
if CustomnCaption <> '' then begin if CustomCaption <> '' then begin
NewCaption := AddToCaption(NewCaption, CustomnCaption); NewCaption := AddToCaption(NewCaption, CustomCaption);
end; end;
GlobalMacroList.MarkUnhandledMacros := OldMarkUnhandledMacros; GlobalMacroList.MarkUnhandledMacros := OldMarkUnhandledMacros;
end; end;