mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 03:59:17 +02:00
IDE: Improve exporting and importing desktops. By Ondrej Pokorny.
git-svn-id: trunk@49747 -
This commit is contained in:
parent
886b429940
commit
8546093cee
@ -15,11 +15,12 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideTop.Control = DesktopListBox
|
AnchorSideTop.Control = DesktopListBox
|
||||||
AnchorSideRight.Control = DeleteBitBtn
|
AnchorSideRight.Control = DeleteBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 29
|
Height = 25
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 178
|
Width = 159
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Caption = 'Save current desktop'
|
Caption = 'Save current desktop'
|
||||||
OnClick = SaveBitBtnClick
|
OnClick = SaveBitBtnClick
|
||||||
@ -27,8 +28,8 @@ object DesktopForm: TDesktopForm
|
|||||||
end
|
end
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 37
|
Height = 34
|
||||||
Top = 298
|
Top = 301
|
||||||
Width = 406
|
Width = 406
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.Caption = 'Close and use selected desktop'
|
OKButton.Caption = 'Close and use selected desktop'
|
||||||
@ -40,7 +41,7 @@ object DesktopForm: TDesktopForm
|
|||||||
CancelButton.Name = 'CancelButton'
|
CancelButton.Name = 'CancelButton'
|
||||||
CancelButton.Caption = 'Close'
|
CancelButton.Caption = 'Close'
|
||||||
CancelButton.DefaultCaption = False
|
CancelButton.DefaultCaption = False
|
||||||
TabOrder = 7
|
TabOrder = 8
|
||||||
ShowButtons = [pbOK, pbCancel]
|
ShowButtons = [pbOK, pbCancel]
|
||||||
end
|
end
|
||||||
object DesktopListBox: TListBox
|
object DesktopListBox: TListBox
|
||||||
@ -48,7 +49,7 @@ object DesktopForm: TDesktopForm
|
|||||||
Left = 11
|
Left = 11
|
||||||
Height = 286
|
Height = 286
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 213
|
Width = 232
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Right = 10
|
BorderSpacing.Right = 10
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
@ -59,7 +60,6 @@ object DesktopForm: TDesktopForm
|
|||||||
ScrollWidth = 211
|
ScrollWidth = 211
|
||||||
Style = lbOwnerDrawFixed
|
Style = lbOwnerDrawFixed
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
TopIndex = -1
|
|
||||||
end
|
end
|
||||||
object DeleteBitBtn: TBitBtn
|
object DeleteBitBtn: TBitBtn
|
||||||
AnchorSideLeft.Control = SetDebugDesktopBitBtn
|
AnchorSideLeft.Control = SetDebugDesktopBitBtn
|
||||||
@ -67,11 +67,12 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 29
|
Height = 25
|
||||||
Top = 144
|
Top = 130
|
||||||
Width = 178
|
Width = 159
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 4
|
BorderSpacing.Top = 4
|
||||||
Caption = 'Delete'
|
Caption = 'Delete'
|
||||||
OnClick = DeleteBitBtnClick
|
OnClick = DeleteBitBtnClick
|
||||||
@ -81,10 +82,10 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideTop.Control = SelectedDesktopLabel
|
AnchorSideTop.Control = SelectedDesktopLabel
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 29
|
Height = 25
|
||||||
Top = 76
|
Top = 70
|
||||||
Width = 178
|
Width = 159
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
@ -96,10 +97,10 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideLeft.Control = SaveBitBtn
|
AnchorSideLeft.Control = SaveBitBtn
|
||||||
AnchorSideTop.Control = SaveBitBtn
|
AnchorSideTop.Control = SaveBitBtn
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 17
|
Height = 15
|
||||||
Top = 53
|
Top = 49
|
||||||
Width = 121
|
Width = 92
|
||||||
BorderSpacing.Top = 10
|
BorderSpacing.Top = 10
|
||||||
Caption = 'Selected desktop:'
|
Caption = 'Selected desktop:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -110,11 +111,12 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 29
|
Height = 25
|
||||||
Top = 111
|
Top = 101
|
||||||
Width = 178
|
Width = 159
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Caption = 'Rename'
|
Caption = 'Rename'
|
||||||
OnClick = RenameBitBtnClick
|
OnClick = RenameBitBtnClick
|
||||||
@ -124,13 +126,13 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideLeft.Control = DeleteBitBtn
|
AnchorSideLeft.Control = DeleteBitBtn
|
||||||
AnchorSideTop.Control = DeleteBitBtn
|
AnchorSideTop.Control = DeleteBitBtn
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = DeleteBitBtn
|
AnchorSideRight.Control = ExportAllBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
Left = 253
|
||||||
Left = 234
|
Height = 25
|
||||||
Height = 29
|
Top = 167
|
||||||
Top = 185
|
Width = 121
|
||||||
Width = 178
|
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 12
|
BorderSpacing.Top = 12
|
||||||
Caption = 'Export'
|
Caption = 'Export'
|
||||||
OnClick = ExportBitBtnClick
|
OnClick = ExportBitBtnClick
|
||||||
@ -140,16 +142,34 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideLeft.Control = ExportBitBtn
|
AnchorSideLeft.Control = ExportBitBtn
|
||||||
AnchorSideTop.Control = ExportBitBtn
|
AnchorSideTop.Control = ExportBitBtn
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ExportBitBtn
|
AnchorSideRight.Control = DeleteBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 234
|
Left = 253
|
||||||
Height = 29
|
Height = 25
|
||||||
Top = 218
|
Top = 196
|
||||||
Width = 178
|
Width = 159
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 4
|
BorderSpacing.Top = 4
|
||||||
Caption = 'Import'
|
Caption = 'Import'
|
||||||
OnClick = ImportBitBtnClick
|
OnClick = ImportBitBtnClick
|
||||||
|
TabOrder = 7
|
||||||
|
end
|
||||||
|
object ExportAllBitBtn: TBitBtn
|
||||||
|
AnchorSideLeft.Control = ExportBitBtn
|
||||||
|
AnchorSideTop.Control = ExportBitBtn
|
||||||
|
AnchorSideRight.Control = DeleteBitBtn
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = ExportBitBtn
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 374
|
||||||
|
Height = 25
|
||||||
|
Top = 167
|
||||||
|
Width = 38
|
||||||
|
Anchors = [akTop, akRight, akBottom]
|
||||||
|
AutoSize = True
|
||||||
|
Caption = 'all'
|
||||||
|
OnClick = ExportAllBitBtnClick
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,6 +18,7 @@ type
|
|||||||
TDesktopForm = class(TForm)
|
TDesktopForm = class(TForm)
|
||||||
ExportBitBtn: TBitBtn;
|
ExportBitBtn: TBitBtn;
|
||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
|
ExportAllBitBtn: TBitBtn;
|
||||||
ImportBitBtn: TBitBtn;
|
ImportBitBtn: TBitBtn;
|
||||||
RenameBitBtn: TBitBtn;
|
RenameBitBtn: TBitBtn;
|
||||||
SelectedDesktopLabel: TLabel;
|
SelectedDesktopLabel: TLabel;
|
||||||
@ -31,6 +32,7 @@ type
|
|||||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||||
procedure DesktopListBoxKeyPress(Sender: TObject; var Key: char);
|
procedure DesktopListBoxKeyPress(Sender: TObject; var Key: char);
|
||||||
procedure DesktopListBoxSelectionChange(Sender: TObject; {%H-}User: boolean);
|
procedure DesktopListBoxSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||||
|
procedure ExportAllBitBtnClick(Sender: TObject);
|
||||||
procedure ExportBitBtnClick(Sender: TObject);
|
procedure ExportBitBtnClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure ImportBitBtnClick(Sender: TObject);
|
procedure ImportBitBtnClick(Sender: TObject);
|
||||||
@ -38,7 +40,8 @@ type
|
|||||||
procedure SaveBitBtnClick(Sender: TObject);
|
procedure SaveBitBtnClick(Sender: TObject);
|
||||||
procedure SetDebugDesktopBitBtnClick(Sender: TObject);
|
procedure SetDebugDesktopBitBtnClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
procedure RefreshList(const SelectName: string = '');
|
procedure RefreshList(SelectName: string = '');
|
||||||
|
procedure ExportDesktops(const aDesktops: array of TDesktopOpt);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TShowDesktopItem = class(TMenuItem)
|
TShowDesktopItem = class(TMenuItem)
|
||||||
@ -213,7 +216,7 @@ begin
|
|||||||
xShowOverwriteDlg := False;
|
xShowOverwriteDlg := False;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if not InputQuery(dlgSaveCurrentDesktop, dlgDesktopName, xDesktopName)
|
if not InputQuery(dlgDesktopName, dlgSaveCurrentDesktopAs, xDesktopName)
|
||||||
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
||||||
then
|
then
|
||||||
Exit;
|
Exit;
|
||||||
@ -240,6 +243,7 @@ begin
|
|||||||
RenameBitBtn.Caption := lisRename;
|
RenameBitBtn.Caption := lisRename;
|
||||||
RenameBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_edit');
|
RenameBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_edit');
|
||||||
ExportBitBtn.Caption := lisExport;
|
ExportBitBtn.Caption := lisExport;
|
||||||
|
ExportAllBitBtn.Caption := lisExportAll;
|
||||||
ImportBitBtn.Caption := lisImport;
|
ImportBitBtn.Caption := lisImport;
|
||||||
SetDebugDesktopBitBtn.Caption := dlgToggleSelectedDebugDesktop;
|
SetDebugDesktopBitBtn.Caption := dlgToggleSelectedDebugDesktop;
|
||||||
SetDebugDesktopBitBtn.LoadGlyphFromResourceName(HInstance, 'menu_run');
|
SetDebugDesktopBitBtn.LoadGlyphFromResourceName(HInstance, 'menu_run');
|
||||||
@ -247,10 +251,13 @@ begin
|
|||||||
ButtonPanel1.CancelButton.Caption := lisClose;
|
ButtonPanel1.CancelButton.Caption := lisClose;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesktopForm.RefreshList(const SelectName: string);
|
procedure TDesktopForm.RefreshList(SelectName: string);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
if (SelectName='') and (DesktopListBox.ItemIndex>=0) then
|
||||||
|
SelectName:=DesktopListBox.Items[DesktopListBox.ItemIndex];
|
||||||
|
|
||||||
DesktopListBox.Clear;
|
DesktopListBox.Clear;
|
||||||
// Saved desktops
|
// Saved desktops
|
||||||
with EnvironmentOptions do
|
with EnvironmentOptions do
|
||||||
@ -332,11 +339,8 @@ end;
|
|||||||
|
|
||||||
procedure TDesktopForm.ExportBitBtnClick(Sender: TObject);
|
procedure TDesktopForm.ExportBitBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
FXMLCfg: TRttiXMLConfig;
|
xDesktopName: String;
|
||||||
FConfigStore: TXMLOptionsStorage;
|
xDesktop: TDesktopOpt;
|
||||||
SaveDialog: TSaveDialog;
|
|
||||||
xDesktopName, Filename: string;
|
|
||||||
xDesktopID: Integer;
|
|
||||||
begin
|
begin
|
||||||
if DesktopListBox.ItemIndex < 0 then
|
if DesktopListBox.ItemIndex < 0 then
|
||||||
Exit;
|
Exit;
|
||||||
@ -345,96 +349,149 @@ begin
|
|||||||
if xDesktopName = '' then
|
if xDesktopName = '' then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
xDesktopID := EnvironmentOptions.Desktops.IndexOf(xDesktopName);
|
xDesktop := EnvironmentOptions.Desktops.Find(xDesktopName);
|
||||||
if xDesktopID = -1 then
|
if xDesktop = nil then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
SaveDialog := TSaveDialog.Create(nil);
|
ExportDesktops([xDesktop]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDesktopForm.ExportDesktops(const aDesktops: array of TDesktopOpt);
|
||||||
|
var
|
||||||
|
xXMLCfg: TRttiXMLConfig;
|
||||||
|
xConfigStore: TXMLOptionsStorage;
|
||||||
|
xSaveDialog: TSaveDialog;
|
||||||
|
xFileName: string;
|
||||||
|
xCurPath: String;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if Length(aDesktops) = 0 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
xSaveDialog := TSaveDialog.Create(nil);
|
||||||
try
|
try
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(SaveDialog);
|
InputHistories.ApplyFileDialogSettings(xSaveDialog);
|
||||||
SaveDialog.Filter := dlgFilterXML +' (*.xml)|*.xml';
|
xSaveDialog.Filter := dlgFilterXML +' (*.xml)|*.xml';
|
||||||
SaveDialog.Options := SaveDialog.Options + [ofOverwritePrompt];
|
xSaveDialog.Options := xSaveDialog.Options + [ofOverwritePrompt];
|
||||||
if SaveDialog.Execute then
|
if xSaveDialog.Execute then
|
||||||
begin
|
begin
|
||||||
Filename := SaveDialog.Filename;
|
xFileName := xSaveDialog.FileName;
|
||||||
if ExtractFileExt(Filename) = '' then
|
if ExtractFileExt(xFileName) = '' then
|
||||||
Filename := Filename + '.xml';
|
xFileName := xFileName + '.xml';
|
||||||
FXMLCfg := TRttiXMLConfig.CreateClean(Filename);
|
|
||||||
|
xXMLCfg := nil;
|
||||||
|
xConfigStore := nil;
|
||||||
try
|
try
|
||||||
FConfigStore := TXMLOptionsStorage.Create(FXMLCfg);
|
xXMLCfg := TRttiXMLConfig.CreateClean(xFileName);
|
||||||
try
|
xConfigStore := TXMLOptionsStorage.Create(xXMLCfg);
|
||||||
EnvironmentOptions.Desktops.SaveToXML(FXMLCfg, FConfigStore, xDesktopID);
|
xCurPath := 'Desktops/';
|
||||||
FConfigStore.WriteToDisk;
|
xXMLCfg.SetDeleteValue(xCurPath + 'Count', Length(aDesktops), 0);
|
||||||
ShowMessageFmt(lisSuccessfullyExported, [SaveDialog.Filename]);
|
for I := 0 to Length(aDesktops)-1 do
|
||||||
finally
|
begin
|
||||||
FConfigStore.Free;
|
aDesktops[I].SetConfig(xXMLCfg, xConfigStore);
|
||||||
|
aDesktops[I].Save(xCurPath + 'Desktop'+IntToStr(I+1)+'/');
|
||||||
end;
|
end;
|
||||||
|
xConfigStore.WriteToDisk;
|
||||||
|
ShowMessageFmt(dlgDesktopsExported, [Length(aDesktops), xFileName]);
|
||||||
finally
|
finally
|
||||||
FreeAndNil(FXMLCfg);
|
xConfigStore.Free;
|
||||||
|
xXMLCfg.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(SaveDialog);
|
InputHistories.StoreFileDialogSettings(xSaveDialog);
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do
|
||||||
begin
|
begin
|
||||||
DebugLn('ERROR: [TDesktopMangerDialog.ExportBitBtnClick] ', E.Message);
|
DebugLn('ERROR: [TDesktopMangerDialog.ExportBitBtnClick] ', E.Message);
|
||||||
|
Raise;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SaveDialog.Free;
|
xSaveDialog.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesktopForm.ImportBitBtnClick(Sender: TObject);
|
procedure TDesktopForm.ImportBitBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
FXMLCfg: TRttiXMLConfig;
|
xXMLCfg: TRttiXMLConfig;
|
||||||
FConfigStore: TXMLOptionsStorage;
|
xConfigStore: TXMLOptionsStorage;
|
||||||
OpenDialog: TOpenDialog;
|
xOpenDialog: TOpenDialog;
|
||||||
xDesktopName, Filename: string;
|
xDesktopName, xOldDesktopName, xFileName: string;
|
||||||
xDesktopID: Integer;
|
xCurPath, xDesktopPath: string;
|
||||||
|
I: Integer;
|
||||||
|
xCount, xImportedCount: Integer;
|
||||||
|
xDsk: TDesktopOpt;
|
||||||
begin
|
begin
|
||||||
if DesktopListBox.ItemIndex < 0 then
|
xOpenDialog := TOpenDialog.Create(nil);
|
||||||
Exit;
|
|
||||||
|
|
||||||
xDesktopName := DesktopListBox.Items[DesktopListBox.ItemIndex];
|
|
||||||
if xDesktopName = '' then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
xDesktopID := EnvironmentOptions.Desktops.IndexOf(xDesktopName);
|
|
||||||
if xDesktopID = -1 then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
OpenDialog := TOpenDialog.Create(nil);
|
|
||||||
try
|
try
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(xOpenDialog);
|
||||||
OpenDialog.Filter := dlgFilterXML +' (*.xml)|*.xml';
|
xOpenDialog.Filter := dlgFilterXML +' (*.xml)|*.xml';
|
||||||
if OpenDialog.Execute then
|
if xOpenDialog.Execute then
|
||||||
begin
|
begin
|
||||||
Filename := OpenDialog.Filename;
|
xFileName := xOpenDialog.FileName;
|
||||||
FXMLCfg := TRttiXMLConfig.Create(Filename);
|
xXMLCfg := nil;
|
||||||
|
xConfigStore := nil;
|
||||||
try
|
try
|
||||||
FConfigStore := TXMLOptionsStorage.Create(FXMLCfg);
|
xXMLCfg := TRttiXMLConfig.Create(xFileName);
|
||||||
try
|
xConfigStore := TXMLOptionsStorage.Create(xXMLCfg);
|
||||||
EnvironmentOptions.Desktops.LoadFromXML(FXMLCfg, FConfigStore, xDesktopID);
|
|
||||||
ShowMessageFmt(lisSuccessfullyImported, [OpenDialog.Filename]);
|
xCurPath := 'Desktops/';
|
||||||
finally
|
xCount := xXMLCfg.GetValue(xCurPath+'Count', 0);
|
||||||
FConfigStore.Free;
|
xImportedCount := 0;
|
||||||
|
for I := 1 to xCount do
|
||||||
|
begin
|
||||||
|
xDesktopPath := xCurPath+'Desktop'+IntToStr(I)+'/';
|
||||||
|
if not xXMLCfg.HasPath(xDesktopPath, True) then
|
||||||
|
Continue;
|
||||||
|
|
||||||
|
xDesktopName := xXMLCfg.GetValue(xDesktopPath+'Name', '');
|
||||||
|
xOldDesktopName := xDesktopName;
|
||||||
|
//show a dialog to modify desktop name
|
||||||
|
if (EnvironmentOptions.Desktops.IndexOf(xDesktopName) >= 0) and
|
||||||
|
not InputQuery(dlgDesktopName, dlgImportDesktopExists, xDesktopName)
|
||||||
|
then
|
||||||
|
Continue;
|
||||||
|
|
||||||
|
if xDesktopName = '' then
|
||||||
|
Continue;
|
||||||
|
xDsk := EnvironmentOptions.Desktops.Find(xDesktopName);
|
||||||
|
if not Assigned(xDsk) then
|
||||||
|
begin
|
||||||
|
xDsk := TDesktopOpt.Create(xDesktopName, False);
|
||||||
|
EnvironmentOptions.Desktops.Add(xDsk);
|
||||||
|
end else
|
||||||
|
if (xOldDesktopName <> xDesktopName) and
|
||||||
|
(MessageDlg(Format(dlgOverwriteDesktop, [xDesktopName]), mtWarning, mbYesNo, 0) <> mrYes)
|
||||||
|
then
|
||||||
|
Continue;
|
||||||
|
|
||||||
|
xDsk.SetConfig(xXMLCfg, xConfigStore);
|
||||||
|
xDsk.Load(xDesktopPath);
|
||||||
|
Inc(xImportedCount);
|
||||||
|
end;//for
|
||||||
|
|
||||||
|
if xImportedCount>0 then
|
||||||
|
begin
|
||||||
|
ShowMessageFmt(dlgDesktopsImported, [xImportedCount, xFileName]);
|
||||||
|
RefreshList;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(FXMLCfg);
|
xConfigStore.Free;
|
||||||
|
xXMLCfg.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
InputHistories.StoreFileDialogSettings(xOpenDialog);
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do
|
||||||
begin
|
begin
|
||||||
DebugLn('ERROR: [TDesktopMangerDialog.ImportBitBtnClick] ', E.Message);
|
DebugLn('ERROR: [TDesktopMangerDialog.ImportBitBtnClick] ', E.Message);
|
||||||
|
Raise;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
OpenDialog.Free;
|
xOpenDialog.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -508,7 +565,18 @@ begin
|
|||||||
SetDebugDesktopBitBtn.Enabled := DeleteBitBtn.Enabled;
|
SetDebugDesktopBitBtn.Enabled := DeleteBitBtn.Enabled;
|
||||||
ButtonPanel1.OKButton.Enabled := DeleteBitBtn.Enabled;
|
ButtonPanel1.OKButton.Enabled := DeleteBitBtn.Enabled;
|
||||||
ExportBitBtn.Enabled := DeleteBitBtn.Enabled;
|
ExportBitBtn.Enabled := DeleteBitBtn.Enabled;
|
||||||
ImportBitBtn.Enabled := DeleteBitBtn.Enabled;
|
ExportAllBitBtn.Enabled := DesktopListBox.Items.Count>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDesktopForm.ExportAllBitBtnClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
xDesktops: array of TDesktopOpt;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
SetLength(xDesktops, EnvironmentOptions.Desktops.Count);
|
||||||
|
for I := 0 to Length(xDesktops)-1 do
|
||||||
|
xDesktops[I] := EnvironmentOptions.Desktops[I];
|
||||||
|
ExportDesktops(xDesktops);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesktopForm.SaveBitBtnClick(Sender: TObject);
|
procedure TDesktopForm.SaveBitBtnClick(Sender: TObject);
|
||||||
@ -521,7 +589,7 @@ begin
|
|||||||
xDesktopName := '';
|
xDesktopName := '';
|
||||||
xOldDesktopName := xDesktopName;
|
xOldDesktopName := xDesktopName;
|
||||||
|
|
||||||
if not InputQuery(dlgSaveCurrentDesktop, dlgDesktopName, xDesktopName)
|
if not InputQuery(dlgDesktopName, dlgSaveCurrentDesktopAs, xDesktopName)
|
||||||
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
||||||
then
|
then
|
||||||
Exit;
|
Exit;
|
||||||
|
@ -283,14 +283,15 @@ type
|
|||||||
// component palette
|
// component palette
|
||||||
FComponentPaletteOptions: TCompPaletteOptions;
|
FComponentPaletteOptions: TCompPaletteOptions;
|
||||||
|
|
||||||
procedure SetConfig(aXMLCfg: TRttiXMLConfig; aConfigStore: TXMLOptionsStorage);
|
|
||||||
procedure InitLayoutList;
|
procedure InitLayoutList;
|
||||||
procedure Load(Path: String);
|
|
||||||
procedure Save(Path: String);
|
|
||||||
public
|
public
|
||||||
constructor Create(aName: String; const aUseIDELayouts: Boolean);
|
constructor Create(aName: String; const aUseIDELayouts: Boolean);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Assign(Source: TDesktopOpt);
|
procedure Assign(Source: TDesktopOpt);
|
||||||
|
public
|
||||||
|
procedure SetConfig(aXMLCfg: TRttiXMLConfig; aConfigStore: TXMLOptionsStorage);
|
||||||
|
procedure Load(Path: String);
|
||||||
|
procedure Save(Path: String);
|
||||||
|
|
||||||
property Name: String read FName write FName;
|
property Name: String read FName write FName;
|
||||||
property IDEWindowCreatorsLayoutList: TSimpleWindowLayoutList read FIDEWindowCreatorsLayoutList write FIDEWindowCreatorsLayoutList;
|
property IDEWindowCreatorsLayoutList: TSimpleWindowLayoutList read FIDEWindowCreatorsLayoutList write FIDEWindowCreatorsLayoutList;
|
||||||
@ -330,10 +331,6 @@ type
|
|||||||
constructor Create(aEnvOpts: TEnvironmentOptions);
|
constructor Create(aEnvOpts: TEnvironmentOptions);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AddFromCfg(Path: String);
|
procedure AddFromCfg(Path: String);
|
||||||
procedure SaveToXML(aXMLCfg: TRttiXMLConfig; aConfigStore: TXMLOptionsStorage;
|
|
||||||
Index: Integer);
|
|
||||||
procedure LoadFromXML(aXMLCfg: TRttiXMLConfig; aConfigStore: TXMLOptionsStorage;
|
|
||||||
Index: Integer);
|
|
||||||
function IndexOf(aName: string): integer;
|
function IndexOf(aName: string): integer;
|
||||||
function Find(aName: string): TDesktopOpt;
|
function Find(aName: string): TDesktopOpt;
|
||||||
property Items[Index: Integer]: TDesktopOpt read GetItem; default;
|
property Items[Index: Integer]: TDesktopOpt read GetItem; default;
|
||||||
@ -918,33 +915,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesktopOptList.SaveToXML(aXMLCfg: TRttiXMLConfig;
|
|
||||||
aConfigStore: TXMLOptionsStorage; Index: Integer);
|
|
||||||
var
|
|
||||||
CurPath: String;
|
|
||||||
begin
|
|
||||||
CurPath := 'Desktops/';
|
|
||||||
Items[Index].SetConfig(aXMLCfg, aConfigStore);
|
|
||||||
aXMLCfg.SetDeleteValue(CurPath + 'Count', 1, 0);
|
|
||||||
Items[Index].Save(CurPath + 'Desktop1/');
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDesktopOptList.LoadFromXML(aXMLCfg: TRttiXMLConfig;
|
|
||||||
aConfigStore: TXMLOptionsStorage; Index: Integer);
|
|
||||||
var
|
|
||||||
CurPath: String;
|
|
||||||
xDesktop: TDesktopOpt;
|
|
||||||
begin
|
|
||||||
CurPath := 'Desktops/';
|
|
||||||
if aXMLCfg.HasPath(CurPath, True) then
|
|
||||||
begin
|
|
||||||
xDesktop := TDesktopOpt.Create(Items[Index].Name, False);
|
|
||||||
Items[Index].Assign(xDesktop);
|
|
||||||
Items[Index].SetConfig(aXMLCfg, aConfigStore);
|
|
||||||
Items[Index].Load(CurPath + 'Desktop1/');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDesktopOptList.IndexOf(aName: string): integer;
|
function TDesktopOptList.IndexOf(aName: string): integer;
|
||||||
begin
|
begin
|
||||||
Result:=Count-1;
|
Result:=Count-1;
|
||||||
|
@ -1268,9 +1268,13 @@ resourcestring
|
|||||||
dlgRenameDesktop = 'Rename desktop';
|
dlgRenameDesktop = 'Rename desktop';
|
||||||
dlgNewDesktop = 'New desktop ...';
|
dlgNewDesktop = 'New desktop ...';
|
||||||
dlgToggleSelectedDebugDesktop = 'Toggle as debug desktop';
|
dlgToggleSelectedDebugDesktop = 'Toggle as debug desktop';
|
||||||
dlgDesktopName = 'Desktop name:';
|
dlgDesktopName = 'Desktop name';
|
||||||
dlgOverwriteDesktop = 'Desktop with the name "%s" was found.'+sLineBreak+'Should the old desktop be overwritten?';
|
dlgOverwriteDesktop = 'Desktop with the name "%s" was found.'+sLineBreak+'Should the old desktop be overwritten?';
|
||||||
dlgDebugDesktop = 'debug desktop';
|
dlgDebugDesktop = 'debug desktop';
|
||||||
|
dlgImportDesktopExists = 'A desktop with the same name already exists.'+sLineBreak+'Please confirm the desktop name:';
|
||||||
|
dlgDesktopsImported = '%d desktop(s) successfully imported from "%s"';
|
||||||
|
dlgDesktopsExported = '%d desktop(s) successfully exported to "%s"';
|
||||||
|
lisExportAll = 'all';
|
||||||
|
|
||||||
// Window options
|
// Window options
|
||||||
dlgShowingWindows = 'Showing Windows';
|
dlgShowingWindows = 'Showing Windows';
|
||||||
|
Loading…
Reference in New Issue
Block a user