mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-10 14:39:14 +02:00
anchordocking: load/save layout file
git-svn-id: trunk@26186 -
This commit is contained in:
parent
b515150abb
commit
14da0dee1f
@ -97,6 +97,15 @@ resourcestring
|
|||||||
adrsHideHeaderCaptionsForSitesWithOnlyOneDockedControl = 'Hide header '
|
adrsHideHeaderCaptionsForSitesWithOnlyOneDockedControl = 'Hide header '
|
||||||
+'captions for sites with only one docked control, as that is already '
|
+'captions for sites with only one docked control, as that is already '
|
||||||
+'shown in the normal window title';
|
+'shown in the normal window title';
|
||||||
|
adrsErrorWritingWindowLayoutToFile = 'Error writing window layout to file "%'
|
||||||
|
+'s"%s%s';
|
||||||
|
adrsLoadWindowLayoutFromFileXml = 'Load window layout from file (*.xml)';
|
||||||
|
adrsSaveWindowLayoutToFile = 'Save window layout to file ...';
|
||||||
|
adrsLoadWindowLayoutFromFile = 'Load window layout from file ...';
|
||||||
|
adrsErrorLoadingWindowLayoutFromFile = 'Error loading window layout from '
|
||||||
|
+'file "%s"%s%s';
|
||||||
|
adrsError = 'Error';
|
||||||
|
adrsSaveWindowLayoutToFileXml = 'Save window layout to file (*.xml)';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -34,12 +34,17 @@ unit RegisterAnchorDocking;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, Classes, SysUtils, LCLProc, Forms, Controls, FileUtil,
|
Math, Classes, SysUtils, LCLProc, Forms, Controls, FileUtil, Dialogs,
|
||||||
BaseIDEIntf, LazConfigStorage, LazIDEIntf, IDEWindowIntf,
|
LazConfigStorage, XMLCfg, XMLPropStorage,
|
||||||
AnchorDocking, AnchorDockOptionsDlg;
|
BaseIDEIntf, IDEDialogs, MenuIntf, LazIDEIntf, IDEWindowIntf,
|
||||||
|
AnchorDockStr, AnchorDocking, AnchorDockOptionsDlg;
|
||||||
|
|
||||||
const
|
const
|
||||||
DefaultConfigFileName = 'anchordocklayout.xml';
|
DefaultConfigFileName = 'anchordocklayout.xml';
|
||||||
|
var
|
||||||
|
mnuAnchorDockSection: TIDEMenuSection;
|
||||||
|
mnuADSaveLayoutToFile: TIDEMenuCommand;
|
||||||
|
mnuADLoadLayoutFromFile: TIDEMenuCommand;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -61,10 +66,14 @@ type
|
|||||||
function GetDefaultLayoutFilename: string;
|
function GetDefaultLayoutFilename: string;
|
||||||
procedure LoadDefaultLayout;
|
procedure LoadDefaultLayout;
|
||||||
procedure SaveDefaultLayout;
|
procedure SaveDefaultLayout;
|
||||||
|
procedure LoadLayoutFromFile(Filename: string);
|
||||||
|
procedure SaveLayoutToFile(Filename: string);
|
||||||
procedure ShowForm(AForm: TCustomForm; BringToFront: boolean); override;
|
procedure ShowForm(AForm: TCustomForm; BringToFront: boolean); override;
|
||||||
procedure CloseAll; override;
|
procedure CloseAll; override;
|
||||||
procedure OnIDEClose(Sender: TObject);
|
procedure OnIDEClose(Sender: TObject);
|
||||||
procedure OnIDERestoreWindows(Sender: TObject);
|
procedure OnIDERestoreWindows(Sender: TObject);
|
||||||
|
procedure LoadLayoutFromFileClicked(Sender: TObject);
|
||||||
|
procedure SaveLayoutToFileClicked(Sender: TObject);
|
||||||
property DefaultLayoutLoaded: boolean read FDefaultLayoutLoaded write SetDefaultLayoutLoaded;
|
property DefaultLayoutLoaded: boolean read FDefaultLayoutLoaded write SetDefaultLayoutLoaded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -77,8 +86,19 @@ implementation
|
|||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
|
if not (IDEDockMaster is TIDEAnchorDockMaster) then exit;
|
||||||
|
|
||||||
LazarusIDE.AddHandlerOnIDERestoreWindows(@IDEAnchorDockMaster.OnIDERestoreWindows);
|
LazarusIDE.AddHandlerOnIDERestoreWindows(@IDEAnchorDockMaster.OnIDERestoreWindows);
|
||||||
LazarusIDE.AddHandlerOnIDEClose(@IDEAnchorDockMaster.OnIDEClose);
|
LazarusIDE.AddHandlerOnIDEClose(@IDEAnchorDockMaster.OnIDEClose);
|
||||||
|
|
||||||
|
// add menu section
|
||||||
|
mnuAnchorDockSection:=RegisterIDEMenuSection(mnuEnvironment,'AnchorDocking');
|
||||||
|
mnuADSaveLayoutToFile:=RegisterIDEMenuCommand(mnuAnchorDockSection,
|
||||||
|
'ADSaveLayoutToFile', adrsSaveWindowLayoutToFile,
|
||||||
|
@IDEAnchorDockMaster.SaveLayoutToFileClicked);
|
||||||
|
mnuADLoadLayoutFromFile:=RegisterIDEMenuCommand(mnuAnchorDockSection,
|
||||||
|
'ADLoadLayoutFromFile', adrsLoadWindowLayoutFromFile,
|
||||||
|
@IDEAnchorDockMaster.LoadLayoutFromFileClicked);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIDEAnchorDockMaster }
|
{ TIDEAnchorDockMaster }
|
||||||
@ -204,6 +224,47 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TIDEAnchorDockMaster.LoadLayoutFromFile(Filename: string);
|
||||||
|
var
|
||||||
|
XMLConfig: TXMLConfig;
|
||||||
|
Config: TXMLConfigStorage;
|
||||||
|
begin
|
||||||
|
XMLConfig:=TXMLConfig.Create(nil);
|
||||||
|
try
|
||||||
|
XMLConfig.Filename:=Filename;
|
||||||
|
Config:=TXMLConfigStorage.Create(XMLConfig);
|
||||||
|
try
|
||||||
|
DockMaster.LoadLayoutFromConfig(Config);
|
||||||
|
finally
|
||||||
|
Config.Free;
|
||||||
|
end;
|
||||||
|
XMLConfig.Flush;
|
||||||
|
finally
|
||||||
|
XMLConfig.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEAnchorDockMaster.SaveLayoutToFile(Filename: string);
|
||||||
|
var
|
||||||
|
XMLConfig: TXMLConfig;
|
||||||
|
Config: TXMLConfigStorage;
|
||||||
|
begin
|
||||||
|
XMLConfig:=TXMLConfig.Create(nil);
|
||||||
|
try
|
||||||
|
XMLConfig.StartEmpty:=true;
|
||||||
|
XMLConfig.Filename:=Filename;
|
||||||
|
Config:=TXMLConfigStorage.Create(XMLConfig);
|
||||||
|
try
|
||||||
|
DockMaster.SaveLayoutToConfig(Config);
|
||||||
|
finally
|
||||||
|
Config.Free;
|
||||||
|
end;
|
||||||
|
XMLConfig.Flush;
|
||||||
|
finally
|
||||||
|
XMLConfig.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TIDEAnchorDockMaster.ShowForm(AForm: TCustomForm;
|
procedure TIDEAnchorDockMaster.ShowForm(AForm: TCustomForm;
|
||||||
BringToFront: boolean);
|
BringToFront: boolean);
|
||||||
var
|
var
|
||||||
@ -293,10 +354,72 @@ begin
|
|||||||
LoadDefaultLayout;
|
LoadDefaultLayout;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TIDEAnchorDockMaster.LoadLayoutFromFileClicked(Sender: TObject);
|
||||||
|
var
|
||||||
|
Dlg: TSaveDialog;
|
||||||
|
Filename: String;
|
||||||
|
begin
|
||||||
|
Dlg:=TSaveDialog.Create(nil);
|
||||||
|
try
|
||||||
|
InitIDEFileDialog(Dlg);
|
||||||
|
Dlg.Title:=adrsLoadWindowLayoutFromFileXml;
|
||||||
|
Dlg.Options:=Dlg.Options+[ofFileMustExist];
|
||||||
|
if Dlg.Execute then begin
|
||||||
|
Filename:=CleanAndExpandFilename(Dlg.FileName);
|
||||||
|
try
|
||||||
|
LoadLayoutFromFile(Filename);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
IDEMessageDialog(adrsError,
|
||||||
|
Format(adrsErrorLoadingWindowLayoutFromFile, [Filename, #13, E.Message]),
|
||||||
|
mtError,[mbCancel]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
StoreIDEFileDialog(Dlg);
|
||||||
|
finally
|
||||||
|
Dlg.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEAnchorDockMaster.SaveLayoutToFileClicked(Sender: TObject);
|
||||||
|
var
|
||||||
|
Dlg: TSaveDialog;
|
||||||
|
Filename: String;
|
||||||
|
begin
|
||||||
|
Dlg:=TSaveDialog.Create(nil);
|
||||||
|
try
|
||||||
|
InitIDEFileDialog(Dlg);
|
||||||
|
Dlg.Title:=adrsSaveWindowLayoutToFileXml;
|
||||||
|
Dlg.Options:=Dlg.Options+[ofPathMustExist,ofNoReadOnlyReturn];
|
||||||
|
Dlg.Filter:='Anchor Docking Layout|*.xml|All files|'+GetAllFilesMask;
|
||||||
|
if Dlg.Execute then begin
|
||||||
|
Filename:=CleanAndExpandFilename(Dlg.FileName);
|
||||||
|
if ExtractFileExt(Filename)='' then
|
||||||
|
Filename:=Filename+'.xml';
|
||||||
|
try
|
||||||
|
SaveLayoutToFile(Filename);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
IDEMessageDialog(adrsError,
|
||||||
|
Format(adrsErrorWritingWindowLayoutToFile, [Filename, #13, E.Message]),
|
||||||
|
mtError,[mbCancel]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
StoreIDEFileDialog(Dlg);
|
||||||
|
finally
|
||||||
|
Dlg.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
// create the dockmaster in the initialization section, so that it is ready
|
// create the dockmaster in the initialization section, so that it is ready
|
||||||
// when the Register procedures of the packages are called.
|
// when the Register procedures of the packages are called.
|
||||||
IDEDockMaster:=TIDEAnchorDockMaster.Create;
|
if IDEDockMaster<>nil then
|
||||||
|
debugln('WARNING: there is already another IDEDOckMaster installed.')
|
||||||
|
else
|
||||||
|
IDEDockMaster:=TIDEAnchorDockMaster.Create;
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
FreeAndNil(IDEDockMaster);
|
FreeAndNil(IDEDockMaster);
|
||||||
|
@ -73,6 +73,18 @@ msgstr ""
|
|||||||
msgid "Enlarge %s side"
|
msgid "Enlarge %s side"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrserror
|
||||||
|
msgid "Error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrserrorloadingwindowlayoutfromfile
|
||||||
|
msgid "Error loading window layout from file \"%s\"%s%s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrserrorwritingwindowlayouttofile
|
||||||
|
msgid "Error writing window layout to file \"%s\"%s%s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: anchordockstr.adrsgeneraldockingoptions
|
#: anchordockstr.adrsgeneraldockingoptions
|
||||||
msgid "General docking options"
|
msgid "General docking options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -97,6 +109,14 @@ msgstr ""
|
|||||||
msgid "left"
|
msgid "left"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrsloadwindowlayoutfromfile
|
||||||
|
msgid "Load window layout from file ..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrsloadwindowlayoutfromfilexml
|
||||||
|
msgid "Load window layout from file (*.xml)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: anchordockstr.adrslocked
|
#: anchordockstr.adrslocked
|
||||||
msgid "Locked"
|
msgid "Locked"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -161,6 +181,14 @@ msgstr ""
|
|||||||
msgid "right"
|
msgid "right"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrssavewindowlayouttofile
|
||||||
|
msgid "Save window layout to file ..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: anchordockstr.adrssavewindowlayouttofilexml
|
||||||
|
msgid "Save window layout to file (*.xml)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: anchordockstr.adrsscaleonresize
|
#: anchordockstr.adrsscaleonresize
|
||||||
msgid "Scale on resize"
|
msgid "Scale on resize"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -328,7 +328,6 @@ var
|
|||||||
itmProjectWindowSection: TIDEMenuSection;
|
itmProjectWindowSection: TIDEMenuSection;
|
||||||
itmProjectAddRemoveSection: TIDEMenuSection;
|
itmProjectAddRemoveSection: TIDEMenuSection;
|
||||||
|
|
||||||
|
|
||||||
// run menu
|
// run menu
|
||||||
mnuRun: TIDEMenuSection;
|
mnuRun: TIDEMenuSection;
|
||||||
itmRunBuilding: TIDEMenuSection;
|
itmRunBuilding: TIDEMenuSection;
|
||||||
|
Loading…
Reference in New Issue
Block a user