diff --git a/components/ideintf/toolbarintf.pas b/components/ideintf/toolbarintf.pas index 096a9e3e97..3ea9f877b2 100644 --- a/components/ideintf/toolbarintf.pas +++ b/components/ideintf/toolbarintf.pas @@ -88,8 +88,8 @@ type const aCommand: TIDECommand): TIDEButtonCommand; overload; function AddButton(const aCommand: TIDECommand): TIDEButtonCommand; overload; function FindCreateCategory(const aName, aDescription: string): TIDEToolButtonCategory; - function FindItemByName(aName: string): TIDEButtonCommand; - function FindItemByMenuPathOrName(aName: string): TIDEButtonCommand; + function FindItemByName(const aName: string): TIDEButtonCommand; + function FindItemByMenuPathOrName(var aName: string): TIDEButtonCommand; function FindItemByCommand(const aCommand: TIDECommand): TIDEButtonCommand; property Items[Index: Integer]: TIDEToolButtonCategory read GetItems; default; end; @@ -396,26 +396,22 @@ begin inherited Destroy; end; -function TIDEToolButtonCategories.FindItemByMenuPathOrName(aName: string +function TIDEToolButtonCategories.FindItemByMenuPathOrName(var aName: string ): TIDEButtonCommand; var - i: Integer; xMI: TIDEMenuItem; begin - i := LastDelimiter('/', aName); - if (i > 0) then - begin - //find by path from aName (backwards compatibility) - xMI := IDEMenuRoots.FindByPath(aName, False); - if Assigned(xMI) and Assigned(xMI.Command) then - begin - Result := FindItemByCommand(xMI.Command); - if Assigned(Result) then - Exit; - end; - Delete(aName, 1, i); - end; Result := FindItemByName(aName); + if Result<>nil then Exit; + + //find by path from aName (backwards compatibility) + xMI := IDEMenuRoots.FindByPath(aName, False); + if Assigned(xMI) and Assigned(xMI.Command) then + begin + Result := FindItemByCommand(xMI.Command); + if Assigned(Result) then + aName := xMI.Command.Name; + end; end; function TIDEToolButtonCategories.FindCreateCategory(const aName, @@ -448,7 +444,8 @@ begin Result := nil; end; -function TIDEToolButtonCategories.FindItemByName(aName: string): TIDEButtonCommand; +function TIDEToolButtonCategories.FindItemByName(const aName: string + ): TIDEButtonCommand; var i: Integer; begin diff --git a/ide/toolbarconfig.pas b/ide/toolbarconfig.pas index 230986430c..ee680ac38f 100644 --- a/ide/toolbarconfig.pas +++ b/ide/toolbarconfig.pas @@ -625,12 +625,15 @@ var begin for I := 0 to SL.Count - 1 do begin - Value := SL.Strings[I]; + Value := SL[I]; if Value = '' then Continue; if Value = cIDEToolbarDivider then MI := nil else + begin MI := IDEToolButtonCategories.FindItemByMenuPathOrName(Value); + SL[I] := Value; + end; AddListItem(MI); end; FillToolBar; @@ -765,6 +768,7 @@ begin else begin mi := IDEToolButtonCategories.FindItemByMenuPathOrName(ButtonName); + Options.ButtonNames[i] := ButtonName; if Assigned(mi) then AddButton(mi); end;