mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 21:09:30 +02:00
IDE: Move loading and saving ButtonNames in IDECoolbar and EditorToolbar config into methods.
git-svn-id: trunk@50059 -
This commit is contained in:
parent
07673e317f
commit
1b137755fc
@ -24,10 +24,9 @@ unit EditorToolbarStatic;
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, Forms, ComCtrls, Controls, ExtCtrls, fgl,
|
||||
MenuIntf, IDEImagesIntf, SrcEditorIntf, BaseIDEIntf, LazIDEIntf,
|
||||
LazarusIDEStrConsts, LazConfigStorage, Laz2_XMLCfg, LCLProc, ToolbarConfig,
|
||||
ToolBarIntf;
|
||||
SysUtils, Classes, fgl, ComCtrls, Controls, LCLProc,
|
||||
MenuIntf, IDEImagesIntf, SrcEditorIntf, BaseIDEIntf,
|
||||
LazarusIDEStrConsts, LazConfigStorage, Laz2_XMLCfg, ToolbarConfig;
|
||||
|
||||
type
|
||||
|
||||
@ -167,15 +166,7 @@ begin
|
||||
begin
|
||||
FVisible := XMLConfig.GetValue(Path + 'Visible', True);
|
||||
FPosition := XMLConfig.GetValue(Path + 'Position', 'Top');
|
||||
ButtonCount := XMLConfig.GetValue(Path + 'Count', 0);
|
||||
for I := 1 to ButtonCount do
|
||||
begin
|
||||
ButtonName := XMLConfig.GetValue(Path + 'Button' + IntToStr(I) + '/Name', '');
|
||||
if ButtonName = '' then // Old format
|
||||
ButtonName := XMLConfig.GetValue(Path + 'Buttons/Name' + IntToStr(I) + '/Value', '');
|
||||
if ButtonName <> '' then
|
||||
ButtonNames.Add(ButtonName);
|
||||
end;
|
||||
LoadButtonNames(XMLConfig, Path);
|
||||
end
|
||||
else begin
|
||||
// Plan B: Load the old configuration. User settings are not lost.
|
||||
@ -205,15 +196,11 @@ begin
|
||||
end;
|
||||
|
||||
procedure TEditorToolBarOptions.Save(XMLConfig: TXMLConfig; Path: String);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
Path := Path + BasePath;
|
||||
XMLConfig.SetDeleteValue(Path + 'Visible', FVisible, True);
|
||||
XMLConfig.SetDeleteValue(Path + 'Position', FPosition, 'Top');
|
||||
XMLConfig.SetDeleteValue(Path + 'Count', ButtonNames.Count, 0);
|
||||
for I := 0 to ButtonNames.Count-1 do
|
||||
XMLConfig.SetDeleteValue(Path + 'Button' + IntToStr(I+1) + '/Name', ButtonNames[I], '');
|
||||
SaveButtonNames(XMLConfig, Path);
|
||||
end;
|
||||
|
||||
{ TEditorToolbar }
|
||||
|
@ -394,7 +394,6 @@ procedure TIdeCoolbarOptionsFrame.bConfigClick(Sender: TObject);
|
||||
var
|
||||
ToConfig: Integer;
|
||||
ToolBar: TToolBar;
|
||||
I: Integer;
|
||||
begin
|
||||
ToConfig := GetSelectedBand;
|
||||
if ToConfig = -1 then
|
||||
|
@ -34,7 +34,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, ComCtrls, ToolWin, Controls, fgl,
|
||||
ToolBarIntf, IDEImagesIntf, Laz2_XMLCfg, ToolbarConfig;
|
||||
IDEImagesIntf, Laz2_XMLCfg, ToolbarConfig;
|
||||
|
||||
type
|
||||
|
||||
@ -198,33 +198,15 @@ begin
|
||||
end;
|
||||
|
||||
procedure TIDEToolBarOptions.Load(XMLConfig: TXMLConfig; SubPath: String);
|
||||
var
|
||||
ButtonCount: Integer;
|
||||
ButtonName: string;
|
||||
I: Integer;
|
||||
begin
|
||||
FBreak := XMLConfig.GetValue(SubPath + 'Break/Value', False);
|
||||
ButtonCount := XMLConfig.GetValue(SubPath + 'Count', 0);
|
||||
if ButtonCount = 0 then // Old format
|
||||
ButtonCount := XMLConfig.GetValue(SubPath + 'ButtonCount/Value', 0);
|
||||
for I := 1 to ButtonCount do
|
||||
begin
|
||||
ButtonName := XMLConfig.GetValue(SubPath + 'Button' + IntToStr(I) + '/Name', '');
|
||||
if ButtonName = '' then // Old format
|
||||
ButtonName := XMLConfig.GetValue(SubPath + 'Buttons/Name' + IntToStr(I) + '/Value', '');
|
||||
if ButtonName <> '' then
|
||||
ButtonNames.Add(ButtonName);
|
||||
end;
|
||||
LoadButtonNames(XMLConfig, SubPath);
|
||||
end;
|
||||
|
||||
procedure TIDEToolBarOptions.Save(XMLConfig: TXMLConfig; SubPath: String);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(SubPath + 'Break/Value', FBreak, False);
|
||||
XMLConfig.SetDeleteValue(SubPath + 'Count', ButtonNames.Count, 0);
|
||||
for I := 0 to ButtonNames.Count-1 do
|
||||
XMLConfig.SetDeleteValue(SubPath + 'Button' + IntToStr(I+1) + '/Name', ButtonNames[I], '');
|
||||
SaveButtonNames(XMLConfig, SubPath);
|
||||
end;
|
||||
|
||||
{ TIDEToolBarOptionList }
|
||||
|
@ -771,9 +771,6 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMainIDEBar.CoolBarOnChange(Sender: TObject);
|
||||
var
|
||||
I, J: Integer;
|
||||
ToolBar: TToolBar;
|
||||
begin
|
||||
IDECoolBar.CopyFromRealCoolbar(Coolbar);
|
||||
IDECoolBar.CopyToOptions(EnvironmentOptions.Desktop.IDECoolBarOptions);
|
||||
|
@ -27,6 +27,8 @@ uses
|
||||
// LCL and LazControls
|
||||
LCLProc, Forms, Graphics, ExtCtrls, Buttons, StdCtrls,
|
||||
Controls, ComCtrls, Menus, ButtonPanel, TreeFilterEdit, LclIntf,
|
||||
// LazUtils
|
||||
Laz2_XMLCfg,
|
||||
// IdeIntf
|
||||
IDECommands, ToolBarIntf, IDEImagesIntf,
|
||||
// IDE
|
||||
@ -109,6 +111,9 @@ type
|
||||
TIDEToolBarOptionsBase = class
|
||||
private
|
||||
FButtonNames: TStringList;
|
||||
protected
|
||||
procedure LoadButtonNames(XMLConfig: TXMLConfig; SubPath: String);
|
||||
procedure SaveButtonNames(XMLConfig: TXMLConfig; SubPath: String);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -671,6 +676,34 @@ begin
|
||||
FButtonNames.Assign(Source.FButtonNames);
|
||||
end;
|
||||
|
||||
procedure TIDEToolBarOptionsBase.LoadButtonNames(XMLConfig: TXMLConfig; SubPath: String);
|
||||
var
|
||||
ButtonCount: Integer;
|
||||
ButtonName: string;
|
||||
I: Integer;
|
||||
begin
|
||||
ButtonCount := XMLConfig.GetValue(SubPath + 'Count', 0);
|
||||
if ButtonCount = 0 then // Old format
|
||||
ButtonCount := XMLConfig.GetValue(SubPath + 'ButtonCount/Value', 0);
|
||||
for I := 1 to ButtonCount do
|
||||
begin
|
||||
ButtonName := XMLConfig.GetValue(SubPath + 'Button' + IntToStr(I) + '/Name', '');
|
||||
if ButtonName = '' then // Old format
|
||||
ButtonName := XMLConfig.GetValue(SubPath + 'Buttons/Name' + IntToStr(I) + '/Value', '');
|
||||
if ButtonName <> '' then
|
||||
ButtonNames.Add(ButtonName);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIDEToolBarOptionsBase.SaveButtonNames(XMLConfig: TXMLConfig; SubPath: String);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(SubPath + 'Count', ButtonNames.Count, 0);
|
||||
for I := 0 to ButtonNames.Count-1 do
|
||||
XMLConfig.SetDeleteValue(SubPath + 'Button' + IntToStr(I+1) + '/Name', ButtonNames[I], '');
|
||||
end;
|
||||
|
||||
{ TIDEToolbarBase }
|
||||
{ For future needs ...
|
||||
constructor TIDEToolbarBase.Create(AOwner: TComponent);
|
||||
|
Loading…
Reference in New Issue
Block a user