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
ShowHint = True
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

View File

@ -27,15 +27,15 @@ interface
uses
SysUtils,
// LCL
Forms, StdCtrls, InterfaceBase,
Forms, StdCtrls, InterfaceBase, ExtCtrls, Controls,
// LazControls
DividerBevel,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf,
IDEOptionsIntf, IDEOptEditorIntf, LazStringUtils,
// IdeConfig
EnvironmentOpts,
EnvironmentOpts, LazConf, TransferMacros,
// IDE
LazarusIDEStrConsts, EnvGuiOptions;
LazarusIDEStrConsts, EnvGuiOptions, Classes;
type
{ TWindowOptionsFrame }
@ -44,7 +44,10 @@ type
AutoAdjustIDEHeightFullCompPalCheckBox: TCheckBox;
bvWindowTitle: TDividerBevel;
EdTitleBar: TComboBox;
lbTitlePreviewHeader: TLabel;
lbTitlePreview: TLabel;
lblTitleBar: TLabel;
pnlTitlePreview: TPanel;
ProjectInspectorShowPropsCheckBox: TCheckBox;
lblShowingWindows: TDividerBevel;
NameForDesignedFormListCheckBox: TCheckBox;
@ -52,6 +55,7 @@ type
HideIDEOnRunCheckBox: TCheckBox;
SingleTaskBarButtonCheckBox: TCheckBox;
TitleStartsWithProjectCheckBox: TCheckBox;
procedure EdTitleBarChange(Sender: TObject);
public
function GetTitle: String; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
@ -66,6 +70,44 @@ implementation
{ 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;
begin
Result := dlgWindow;
@ -93,6 +135,9 @@ begin
AutoAdjustIDEHeightFullCompPalCheckBox.Caption:=lisAutoAdjustIDEHeightFullComponentPalette;
AutoAdjustIDEHeightFullCompPalCheckBox.Hint:=lisAutoAdjustIDEHeightFullComponentPaletteHint;
ProjectInspectorShowPropsCheckBox.Caption:=lisProjectInspectorShowProps;
lbTitlePreviewHeader.Caption := dlgWRDPreview;
lbTitlePreviewHeader.Visible := GlobalMacroList <> nil;
pnlTitlePreview.Visible := GlobalMacroList <> nil;
EdTitleBar.AddItem('$project(TitleNew)', nil);
EdTitleBar.AddItem('$project(TitleNew) $EncloseBracket($project(infodir))', nil);
@ -125,6 +170,7 @@ begin
AutoAdjustIDEHeightFullCompPalCheckBox.Checked := AutoAdjustIDEHeightFullCompPal;
ProjectInspectorShowPropsCheckBox.Checked := ProjectInspectorShowProps;
end;
EdTitleBarChange(nil);
end;
procedure TWindowOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);

View File

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