mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 09:40:27 +02:00
IDE: Improve the desktops feature. Prevent access violation and exception. Store z-order of windows. Patch from Ondrej Pokorny.
git-svn-id: trunk@49525 -
This commit is contained in:
parent
c783e32fb3
commit
4f0f211f3c
@ -282,11 +282,12 @@ type
|
|||||||
procedure StoreWindowPositions;
|
procedure StoreWindowPositions;
|
||||||
procedure SetDefaultPosition(const AForm: TCustomForm);
|
procedure SetDefaultPosition(const AForm: TCustomForm);
|
||||||
procedure Assign(SrcList: TSimpleWindowLayoutList; AssignOnlyNewlyCreated,
|
procedure Assign(SrcList: TSimpleWindowLayoutList; AssignOnlyNewlyCreated,
|
||||||
DestroyNotAssigned: Boolean);
|
DestroyNotAssigned, AssignOrder: Boolean);
|
||||||
function Add(ALayout: TSimpleWindowLayout): integer;
|
function Add(ALayout: TSimpleWindowLayout): integer;
|
||||||
function CreateWindowLayout(const TheFormID: string): TSimpleWindowLayout;
|
function CreateWindowLayout(const TheFormID: string): TSimpleWindowLayout;
|
||||||
function CreateWindowLayout(const TheForm: TCustomForm): TSimpleWindowLayout;
|
function CreateWindowLayout(const TheForm: TCustomForm): TSimpleWindowLayout;
|
||||||
function IndexOf(const FormID: string): integer;
|
function IndexOf(const FormID: string): integer;
|
||||||
|
function IndexOf(const AForm: TCustomForm): integer;
|
||||||
function ItemByForm(AForm: TCustomForm): TSimpleWindowLayout;
|
function ItemByForm(AForm: TCustomForm): TSimpleWindowLayout;
|
||||||
function ItemByFormID(const FormID: string): TSimpleWindowLayout;
|
function ItemByFormID(const FormID: string): TSimpleWindowLayout;
|
||||||
function ItemByFormCaption(const aFormCaption: string): TSimpleWindowLayout;
|
function ItemByFormCaption(const aFormCaption: string): TSimpleWindowLayout;
|
||||||
@ -1502,11 +1503,18 @@ begin
|
|||||||
while (Result>=0) and (FormID<>Items[Result].GetFormID) do dec(Result);
|
while (Result>=0) and (FormID<>Items[Result].GetFormID) do dec(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSimpleWindowLayoutList.IndexOf(const AForm: TCustomForm): integer;
|
||||||
|
begin
|
||||||
|
Result:=Count-1;
|
||||||
|
while (Result>=0) and (AForm<>Items[Result].Form) do dec(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSimpleWindowLayoutList.LoadFromConfig(Config: TConfigStorage; const Path: string);
|
procedure TSimpleWindowLayoutList.LoadFromConfig(Config: TConfigStorage; const Path: string);
|
||||||
// do not clear, just add/replace the values from the config
|
// do not clear, just add/replace the values from the config
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
ID: String;
|
ID: String;
|
||||||
|
xLayoutIndex: Integer;
|
||||||
begin
|
begin
|
||||||
// create new windows
|
// create new windows
|
||||||
i := Config.GetValue(Path+'Desktop/FormIdCount', 0);
|
i := Config.GetValue(Path+'Desktop/FormIdCount', 0);
|
||||||
@ -1514,9 +1522,16 @@ begin
|
|||||||
while i > 0 do begin
|
while i > 0 do begin
|
||||||
ID := Config.GetValue(Path+'Desktop/FormIdList/a'+IntToStr(i), '');
|
ID := Config.GetValue(Path+'Desktop/FormIdList/a'+IntToStr(i), '');
|
||||||
//debugln(['TSimpleWindowLayoutList.LoadFromConfig ',i,' ',ID]);
|
//debugln(['TSimpleWindowLayoutList.LoadFromConfig ',i,' ',ID]);
|
||||||
if (ID <> '') and IsValidIdent(ID)
|
if (ID <> '') and IsValidIdent(ID) then
|
||||||
and (IDEWindowCreators.SimpleLayoutStorage.ItemByFormID(ID) = nil) then
|
begin
|
||||||
|
xLayoutIndex := IndexOf(ID);
|
||||||
|
if (xLayoutIndex = -1) then
|
||||||
|
begin
|
||||||
CreateWindowLayout(ID);
|
CreateWindowLayout(ID);
|
||||||
|
xLayoutIndex := Count-1;
|
||||||
|
end;
|
||||||
|
fItems.Move(xLayoutIndex, 0);
|
||||||
|
end;
|
||||||
dec(i);
|
dec(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1557,12 +1572,10 @@ function TSimpleWindowLayoutList.ItemByForm(AForm: TCustomForm): TSimpleWindowLa
|
|||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
i:=Count-1;
|
i:=IndexOf(AForm);
|
||||||
while (i>=0) do begin
|
if i>=0 then
|
||||||
Result:=Items[i];
|
Result:=Items[i]
|
||||||
if Result.Form=AForm then exit;
|
else
|
||||||
dec(i);
|
|
||||||
end;
|
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1755,14 +1768,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSimpleWindowLayoutList.StoreWindowPositions;
|
procedure TSimpleWindowLayoutList.StoreWindowPositions;
|
||||||
var i: integer;
|
var
|
||||||
|
i, l: integer;
|
||||||
|
xOldLayoutIndex: Integer;
|
||||||
begin
|
begin
|
||||||
|
//store positions
|
||||||
for i:=0 to Count-1 do
|
for i:=0 to Count-1 do
|
||||||
Items[i].GetCurrentPosition;
|
Items[i].GetCurrentPosition;
|
||||||
|
|
||||||
|
//store z-order
|
||||||
|
for i:=Screen.CustomFormCount-1 downto 0 do
|
||||||
|
begin
|
||||||
|
xOldLayoutIndex := IndexOf(Screen.CustomForms[i]);
|
||||||
|
if xOldLayoutIndex > 0 then
|
||||||
|
fItems.Move(xOldLayoutIndex, 0);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSimpleWindowLayoutList.Assign(SrcList: TSimpleWindowLayoutList;
|
procedure TSimpleWindowLayoutList.Assign(SrcList: TSimpleWindowLayoutList;
|
||||||
AssignOnlyNewlyCreated, DestroyNotAssigned: Boolean);
|
AssignOnlyNewlyCreated, DestroyNotAssigned, AssignOrder: Boolean);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
xItemIndex: Integer;
|
xItemIndex: Integer;
|
||||||
@ -1779,20 +1803,26 @@ begin
|
|||||||
xItemIndex := Self.Add(TSimpleWindowLayout.Create(SrcList[i].FormID));//not found, create
|
xItemIndex := Self.Add(TSimpleWindowLayout.Create(SrcList[i].FormID));//not found, create
|
||||||
xNewlyCreated := True;
|
xNewlyCreated := True;
|
||||||
end;
|
end;
|
||||||
if xItemIndex<>i then
|
if (xItemIndex<>i) and (AssignOrder) then
|
||||||
|
begin
|
||||||
Self.fItems.Move(xItemIndex, i);//move it to right position
|
Self.fItems.Move(xItemIndex, i);//move it to right position
|
||||||
xItemIndex := i;
|
xItemIndex := i;
|
||||||
end;
|
end;
|
||||||
|
end else
|
||||||
|
xItemIndex := i;
|
||||||
if not AssignOnlyNewlyCreated or xNewlyCreated then
|
if not AssignOnlyNewlyCreated or xNewlyCreated then
|
||||||
Self.Items[i].Assign(SrcList[i])
|
Self.Items[xItemIndex].Assign(SrcList[i])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i := Count-1 downto xItemIndex+1 do
|
for i := Count-1 downto 0 do
|
||||||
|
if SrcList.IndexOf(Items[i].FormID) = -1 then
|
||||||
|
begin
|
||||||
if DestroyNotAssigned then
|
if DestroyNotAssigned then
|
||||||
Delete(i)
|
Delete(i)
|
||||||
else
|
else
|
||||||
Items[i].Clear;
|
Items[i].Clear;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSimpleWindowLayoutList.Add(ALayout: TSimpleWindowLayout): integer;
|
function TSimpleWindowLayoutList.Add(ALayout: TSimpleWindowLayout): integer;
|
||||||
begin
|
begin
|
||||||
@ -2206,21 +2236,18 @@ var
|
|||||||
begin
|
begin
|
||||||
if IDEDockMaster=nil then
|
if IDEDockMaster=nil then
|
||||||
begin
|
begin
|
||||||
for i:=0 to SimpleLayoutStorage.Count-1 do begin
|
for i:=SimpleLayoutStorage.Count-1 downto 0 do//loop down in order to keep z-order of the forms
|
||||||
|
begin
|
||||||
ALayout:=SimpleLayoutStorage[i];
|
ALayout:=SimpleLayoutStorage[i];
|
||||||
AForm:=GetForm(ALayout.FormID,ALayout.Visible);
|
AForm:=GetForm(ALayout.FormID,ALayout.Visible);
|
||||||
if AForm=nil then Continue;
|
if AForm=nil then Continue;
|
||||||
ALayout.Apply(True);
|
ALayout.Apply(True);
|
||||||
if ALayout.Visible then
|
if ALayout.Visible or (AForm=Application.MainForm) then
|
||||||
ShowForm(AForm,false)
|
ShowForm(AForm,true)
|
||||||
else
|
else if AForm.Visible then
|
||||||
begin
|
|
||||||
//ALayout.Apply;
|
|
||||||
if AForm.Visible then
|
|
||||||
AForm.Close;
|
AForm.Close;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
LayoutChanged;
|
LayoutChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ object DesktopForm: TDesktopForm
|
|||||||
AnchorSideTop.Control = DesktopListBox
|
AnchorSideTop.Control = DesktopListBox
|
||||||
AnchorSideRight.Control = DeleteBitBtn
|
AnchorSideRight.Control = DeleteBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 237
|
Left = 280
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 189
|
Width = 146
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Caption = 'Save current desktop'
|
Caption = 'Save current desktop'
|
||||||
@ -40,7 +40,7 @@ object DesktopForm: TDesktopForm
|
|||||||
CancelButton.Name = 'CancelButton'
|
CancelButton.Name = 'CancelButton'
|
||||||
CancelButton.Caption = 'Close'
|
CancelButton.Caption = 'Close'
|
||||||
CancelButton.DefaultCaption = False
|
CancelButton.DefaultCaption = False
|
||||||
TabOrder = 4
|
TabOrder = 5
|
||||||
ShowButtons = [pbOK, pbCancel]
|
ShowButtons = [pbOK, pbCancel]
|
||||||
ShowGlyphs = [pbOK, pbClose, pbHelp]
|
ShowGlyphs = [pbOK, pbClose, pbHelp]
|
||||||
end
|
end
|
||||||
@ -49,7 +49,7 @@ object DesktopForm: TDesktopForm
|
|||||||
Left = 11
|
Left = 11
|
||||||
Height = 147
|
Height = 147
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 216
|
Width = 259
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Right = 10
|
BorderSpacing.Right = 10
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
@ -62,33 +62,61 @@ object DesktopForm: TDesktopForm
|
|||||||
end
|
end
|
||||||
object DeleteBitBtn: TBitBtn
|
object DeleteBitBtn: TBitBtn
|
||||||
AnchorSideLeft.Control = SetDebugDesktopBitBtn
|
AnchorSideLeft.Control = SetDebugDesktopBitBtn
|
||||||
AnchorSideTop.Control = SaveBitBtn
|
AnchorSideTop.Control = RenameBitBtn
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 237
|
Left = 280
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 43
|
Top = 120
|
||||||
Width = 189
|
Width = 146
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 4
|
||||||
Caption = 'Delete selected desktop'
|
Caption = 'Delete'
|
||||||
OnClick = DeleteBitBtnClick
|
OnClick = DeleteBitBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object SetDebugDesktopBitBtn: TBitBtn
|
object SetDebugDesktopBitBtn: TBitBtn
|
||||||
AnchorSideTop.Control = DeleteBitBtn
|
AnchorSideTop.Control = SelectedDesktopLabel
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 237
|
Left = 280
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 86
|
Top = 66
|
||||||
Width = 189
|
Width = 146
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Top = 20
|
BorderSpacing.Top = 6
|
||||||
Caption = 'Toggle selected as debug desktop'
|
Caption = 'Toggle as debug desktop'
|
||||||
OnClick = SetDebugDesktopBitBtnClick
|
OnClick = SetDebugDesktopBitBtnClick
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object SelectedDesktopLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = SaveBitBtn
|
||||||
|
AnchorSideTop.Control = SaveBitBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 280
|
||||||
|
Height = 13
|
||||||
|
Top = 47
|
||||||
|
Width = 86
|
||||||
|
BorderSpacing.Top = 10
|
||||||
|
Caption = 'Selected desktop:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object RenameBitBtn: TBitBtn
|
||||||
|
AnchorSideLeft.Control = SetDebugDesktopBitBtn
|
||||||
|
AnchorSideTop.Control = SetDebugDesktopBitBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = SetDebugDesktopBitBtn
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 280
|
||||||
|
Height = 23
|
||||||
|
Top = 93
|
||||||
|
Width = 146
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Top = 4
|
||||||
|
Caption = 'Rename'
|
||||||
|
OnClick = RenameBitBtnClick
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,8 @@ type
|
|||||||
|
|
||||||
TDesktopForm = class(TForm)
|
TDesktopForm = class(TForm)
|
||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
|
RenameBitBtn: TBitBtn;
|
||||||
|
SelectedDesktopLabel: TLabel;
|
||||||
SetDebugDesktopBitBtn: TBitBtn;
|
SetDebugDesktopBitBtn: TBitBtn;
|
||||||
DesktopListBox: TListBox;
|
DesktopListBox: TListBox;
|
||||||
SaveBitBtn: TBitBtn;
|
SaveBitBtn: TBitBtn;
|
||||||
@ -22,10 +24,11 @@ type
|
|||||||
procedure DeleteBitBtnClick(Sender: TObject);
|
procedure DeleteBitBtnClick(Sender: TObject);
|
||||||
procedure DesktopListBoxDblClick(Sender: TObject);
|
procedure DesktopListBoxDblClick(Sender: TObject);
|
||||||
procedure DesktopListBoxDrawItem(Control: TWinControl; Index: Integer;
|
procedure DesktopListBoxDrawItem(Control: TWinControl; Index: Integer;
|
||||||
ARect: TRect; 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 FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure RenameBitBtnClick(Sender: TObject);
|
||||||
procedure SaveBitBtnClick(Sender: TObject);
|
procedure SaveBitBtnClick(Sender: TObject);
|
||||||
procedure SetDebugDesktopBitBtnClick(Sender: TObject);
|
procedure SetDebugDesktopBitBtnClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
@ -78,10 +81,13 @@ begin
|
|||||||
|
|
||||||
// buttons captions & text
|
// buttons captions & text
|
||||||
Caption := dlgManageDesktops;
|
Caption := dlgManageDesktops;
|
||||||
|
SelectedDesktopLabel.Caption := dlgSelectedDesktop;
|
||||||
SaveBitBtn.Caption := dlgSaveCurrentDesktop;
|
SaveBitBtn.Caption := dlgSaveCurrentDesktop;
|
||||||
SaveBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_save');
|
SaveBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_save');
|
||||||
DeleteBitBtn.Caption := dlgDeleteSelectedDesktop;
|
DeleteBitBtn.Caption := lisDelete;
|
||||||
DeleteBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_delete');
|
DeleteBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_delete');
|
||||||
|
RenameBitBtn.Caption := lisRename;
|
||||||
|
RenameBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_edit');
|
||||||
SetDebugDesktopBitBtn.Caption := dlgToggleSelectedDebugDesktop;
|
SetDebugDesktopBitBtn.Caption := dlgToggleSelectedDebugDesktop;
|
||||||
SetDebugDesktopBitBtn.LoadGlyphFromResourceName(HInstance, 'menu_run');
|
SetDebugDesktopBitBtn.LoadGlyphFromResourceName(HInstance, 'menu_run');
|
||||||
ButtonPanel1.OKButton.Caption := dlgCloseAndUseSelectedDesktop;
|
ButtonPanel1.OKButton.Caption := dlgCloseAndUseSelectedDesktop;
|
||||||
@ -98,10 +104,48 @@ begin
|
|||||||
for i:=0 to Desktops.Count-1 do
|
for i:=0 to Desktops.Count-1 do
|
||||||
DesktopListBox.Items.Add(Desktops[i].Name);
|
DesktopListBox.Items.Add(Desktops[i].Name);
|
||||||
|
|
||||||
DesktopListBox.ItemIndex := DesktopListBox.Items.IndexOf(SelectName);
|
i := DesktopListBox.Items.IndexOf(SelectName);
|
||||||
|
if (i < 0) and (DesktopListBox.Count > 0) then
|
||||||
|
i := 0;
|
||||||
|
DesktopListBox.ItemIndex := i;
|
||||||
|
|
||||||
DesktopListBoxSelectionChange(DesktopListBox, False);
|
DesktopListBoxSelectionChange(DesktopListBox, False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDesktopForm.RenameBitBtnClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
xDesktopName, xOldDesktopName: String;
|
||||||
|
dskIndex: Integer;
|
||||||
|
begin
|
||||||
|
if DesktopListBox.ItemIndex = -1 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
xDesktopName := DesktopListBox.Items[DesktopListBox.ItemIndex];
|
||||||
|
xOldDesktopName := xDesktopName;
|
||||||
|
|
||||||
|
if not InputQuery(dlgRenameDesktop, dlgDesktopName, xDesktopName)
|
||||||
|
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
||||||
|
or (xDesktopName = xOldDesktopName)
|
||||||
|
then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
with EnvironmentOptions do
|
||||||
|
begin
|
||||||
|
dskIndex := Desktops.IndexOf(xDesktopName);//delete old entry in list if new name is present
|
||||||
|
if (dskIndex >= 0) then
|
||||||
|
begin
|
||||||
|
if (MessageDlg(Format(dlgOverwriteDesktop, [xDesktopName]), mtWarning, mbYesNo, 0) = mrYes) then
|
||||||
|
Desktops.Delete(dskIndex)
|
||||||
|
else
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
dskIndex := Desktops.IndexOf(xOldDesktopName);//rename
|
||||||
|
Desktops[dskIndex].Name := xDesktopName;
|
||||||
|
RefreshList(xDesktopName);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDesktopForm.DeleteBitBtnClick(Sender: TObject);
|
procedure TDesktopForm.DeleteBitBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
xDesktopName: String;
|
xDesktopName: String;
|
||||||
@ -198,6 +242,7 @@ procedure TDesktopForm.DesktopListBoxSelectionChange(Sender: TObject;
|
|||||||
User: boolean);
|
User: boolean);
|
||||||
begin
|
begin
|
||||||
DeleteBitBtn.Enabled := DesktopListBox.ItemIndex>=0;
|
DeleteBitBtn.Enabled := DesktopListBox.ItemIndex>=0;
|
||||||
|
RenameBitBtn.Enabled := DeleteBitBtn.Enabled;
|
||||||
SetDebugDesktopBitBtn.Enabled := DeleteBitBtn.Enabled;
|
SetDebugDesktopBitBtn.Enabled := DeleteBitBtn.Enabled;
|
||||||
ButtonPanel1.OKButton.Enabled := DeleteBitBtn.Enabled;
|
ButtonPanel1.OKButton.Enabled := DeleteBitBtn.Enabled;
|
||||||
end;
|
end;
|
||||||
@ -205,14 +250,15 @@ end;
|
|||||||
procedure TDesktopForm.SaveBitBtnClick(Sender: TObject);
|
procedure TDesktopForm.SaveBitBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
dsk: TDesktopOpt;
|
dsk: TDesktopOpt;
|
||||||
xDesktopName: string;
|
xDesktopName, xOldDesktopName: string;
|
||||||
begin
|
begin
|
||||||
if DesktopListBox.ItemIndex >= 0 then
|
if DesktopListBox.ItemIndex >= 0 then
|
||||||
xDesktopName := DesktopListBox.Items[DesktopListBox.ItemIndex]
|
xDesktopName := DesktopListBox.Items[DesktopListBox.ItemIndex]
|
||||||
else
|
else
|
||||||
xDesktopName := '';
|
xDesktopName := '';
|
||||||
|
xOldDesktopName := xDesktopName;
|
||||||
|
|
||||||
if not InputQuery(dlgSaveCurrentDesktop, dlgDesktopNameWillBeOverwritten, xDesktopName)
|
if not InputQuery(dlgSaveCurrentDesktop, dlgDesktopName, xDesktopName)
|
||||||
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
or (xDesktopName = '') // xDesktopName MUST NOT BE EMPTY !!!
|
||||||
then
|
then
|
||||||
Exit;
|
Exit;
|
||||||
@ -220,6 +266,12 @@ begin
|
|||||||
with EnvironmentOptions do
|
with EnvironmentOptions do
|
||||||
begin
|
begin
|
||||||
dsk := Desktops.Find(xDesktopName);
|
dsk := Desktops.Find(xDesktopName);
|
||||||
|
if Assigned(dsk) and
|
||||||
|
(xOldDesktopName <> xDesktopName) and//ask only if manually inserted
|
||||||
|
(MessageDlg(Format(dlgOverwriteDesktop, [xDesktopName]), mtWarning, mbYesNo, 0) <> mrYes)
|
||||||
|
then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if not Assigned(dsk) then
|
if not Assigned(dsk) then
|
||||||
begin
|
begin
|
||||||
debugln(['TDesktopForm.SaveBitBtnClick: Adding ', xDesktopName]);
|
debugln(['TDesktopForm.SaveBitBtnClick: Adding ', xDesktopName]);
|
||||||
|
@ -979,7 +979,7 @@ begin
|
|||||||
FIDEDialogLayoutList:=TIDEDialogLayoutList.Create;
|
FIDEDialogLayoutList:=TIDEDialogLayoutList.Create;
|
||||||
FIDEWindowCreatorsLayoutList:=TSimpleWindowLayoutList.Create(False);
|
FIDEWindowCreatorsLayoutList:=TSimpleWindowLayoutList.Create(False);
|
||||||
FIDEDialogLayoutList.Assign(IDEWindowIntf.IDEDialogLayoutList);
|
FIDEDialogLayoutList.Assign(IDEWindowIntf.IDEDialogLayoutList);
|
||||||
FIDEWindowCreatorsLayoutList.Assign(IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage, True, True);
|
FIDEWindowCreatorsLayoutList.Assign(IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage, True, True, True);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1007,8 +1007,8 @@ begin
|
|||||||
|
|
||||||
// window layout
|
// window layout
|
||||||
if Source.FIDEWindowCreatorsLayoutList <> IDEWindowCreators.SimpleLayoutStorage then
|
if Source.FIDEWindowCreatorsLayoutList <> IDEWindowCreators.SimpleLayoutStorage then
|
||||||
Source.FIDEWindowCreatorsLayoutList.Assign(IDEWindowCreators.SimpleLayoutStorage, True, True);
|
Source.FIDEWindowCreatorsLayoutList.Assign(IDEWindowCreators.SimpleLayoutStorage, True, True, False);
|
||||||
FIDEWindowCreatorsLayoutList.Assign(Source.FIDEWindowCreatorsLayoutList, False, False);
|
FIDEWindowCreatorsLayoutList.Assign(Source.FIDEWindowCreatorsLayoutList, False, False, True);
|
||||||
FIDEDialogLayoutList.Assign(Source.FIDEDialogLayoutList);
|
FIDEDialogLayoutList.Assign(Source.FIDEDialogLayoutList);
|
||||||
FSingleTaskBarButton := Source.FSingleTaskBarButton;
|
FSingleTaskBarButton := Source.FSingleTaskBarButton;
|
||||||
FHideIDEOnRun := Source.FHideIDEOnRun;
|
FHideIDEOnRun := Source.FHideIDEOnRun;
|
||||||
@ -2316,33 +2316,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEnvironmentOptions.UseDesktop(ADesktop: TDesktopOpt);
|
procedure TEnvironmentOptions.UseDesktop(ADesktop: TDesktopOpt);
|
||||||
procedure _UpdateEditorOptions(const aAfter: Boolean);
|
function _ContainsControl(const _Parent, _Control: TWinControl): Boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
I: Integer;
|
||||||
Rec: PIDEOptionsGroupRec;
|
|
||||||
Instance: TAbstractIDEOptions;
|
|
||||||
begin
|
begin
|
||||||
for i := 0 to IDEEditorGroups.Count - 1 do
|
for I := 0 to _Parent.ControlCount-1 do
|
||||||
|
if _Parent.Controls[I] is TWinControl then
|
||||||
begin
|
begin
|
||||||
Rec := IDEEditorGroups[i];
|
if (_Parent.Controls[I] = _Control) or
|
||||||
if Assigned(Rec^.Items) and Assigned(Rec^.GroupClass) then
|
_ContainsControl(TWinControl(_Parent.Controls[I]), _Control)
|
||||||
begin
|
then
|
||||||
Instance := Rec^.GroupClass.GetInstance;
|
Exit(True);
|
||||||
if Assigned(Instance) then
|
|
||||||
begin
|
|
||||||
if aAfter then
|
|
||||||
Instance.DoAfterWrite(False)
|
|
||||||
else
|
|
||||||
Instance.DoBeforeWrite(False)
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
var
|
||||||
|
xLastFocusControl: TWinControl;
|
||||||
|
xLastFocusForm: TCustomForm;
|
||||||
begin
|
begin
|
||||||
_UpdateEditorOptions(False);
|
xLastFocusControl := Screen.ActiveControl;
|
||||||
|
xLastFocusForm := Screen.ActiveCustomForm;
|
||||||
|
DoBeforeWrite(False);
|
||||||
Desktop.Assign(ADesktop);
|
Desktop.Assign(ADesktop);
|
||||||
_UpdateEditorOptions(True);
|
DoAfterWrite(False);
|
||||||
IDEWindowCreators.RestoreSimpleLayout;
|
IDEWindowCreators.RestoreSimpleLayout;
|
||||||
|
|
||||||
|
//set focus back to the previously focused control
|
||||||
|
if Screen.CustomFormIndex(xLastFocusForm) >= 0 then//check if form hasn't been destroyed
|
||||||
|
begin
|
||||||
|
if ((xLastFocusForm = xLastFocusControl) or _ContainsControl(xLastFocusForm, xLastFocusControl)) and//check if control hasn't been destroyed
|
||||||
|
xLastFocusForm.CanFocus and
|
||||||
|
xLastFocusControl.CanFocus
|
||||||
|
then
|
||||||
|
xLastFocusControl.SetFocus;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEnvironmentOptions.SetLazarusDirectory(const AValue: string);
|
procedure TEnvironmentOptions.SetLazarusDirectory(const AValue: string);
|
||||||
|
@ -150,7 +150,7 @@ begin
|
|||||||
ProjectDirInIdeTitleCheckBox.Checked:=IDEProjectDirectoryInIdeTitle;
|
ProjectDirInIdeTitleCheckBox.Checked:=IDEProjectDirectoryInIdeTitle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FLayouts.Assign(IDEWindowCreators.SimpleLayoutStorage, False, True);
|
FLayouts.Assign(IDEWindowCreators.SimpleLayoutStorage, False, True, True);
|
||||||
|
|
||||||
if FShowSimpleLayout then begin
|
if FShowSimpleLayout then begin
|
||||||
// Window Positions
|
// Window Positions
|
||||||
@ -217,8 +217,8 @@ end;
|
|||||||
procedure TWindowOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
|
procedure TWindowOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
|
||||||
begin
|
begin
|
||||||
SaveLayout;
|
SaveLayout;
|
||||||
FLayouts.Assign(IDEWindowCreators.SimpleLayoutStorage, True, True);
|
FLayouts.Assign(IDEWindowCreators.SimpleLayoutStorage, True, True, False);
|
||||||
IDEWindowCreators.SimpleLayoutStorage.Assign(FLayouts, False, False);
|
IDEWindowCreators.SimpleLayoutStorage.Assign(FLayouts, False, False, True);
|
||||||
|
|
||||||
with (AOptions as TEnvironmentOptions).Desktop do
|
with (AOptions as TEnvironmentOptions).Desktop do
|
||||||
begin
|
begin
|
||||||
|
@ -1235,12 +1235,14 @@ resourcestring
|
|||||||
dlgExportDesktop = 'Export desktop';
|
dlgExportDesktop = 'Export desktop';
|
||||||
dlgImportDesktop = 'Import desktop';
|
dlgImportDesktop = 'Import desktop';
|
||||||
dlgManageDesktops = 'Manage desktops';
|
dlgManageDesktops = 'Manage desktops';
|
||||||
|
dlgSelectedDesktop = 'Selected desktop:';
|
||||||
dlgSaveCurrentDesktop = 'Save current desktop';
|
dlgSaveCurrentDesktop = 'Save current desktop';
|
||||||
dlgCloseAndUseSelectedDesktop = 'Close and use selected desktop';
|
dlgCloseAndUseSelectedDesktop = 'Close and use selected desktop';
|
||||||
dlgDeleteSelectedDesktop = 'Delete selected desktop';
|
|
||||||
dlgReallyDeleteDesktop = 'Really delete desktop "%s"?';
|
dlgReallyDeleteDesktop = 'Really delete desktop "%s"?';
|
||||||
dlgToggleSelectedDebugDesktop = 'Toggle selected as debug desktop';
|
dlgRenameDesktop = 'Rename desktop';
|
||||||
dlgDesktopNameWillBeOverwritten = 'Desktop name (old entry will be overwritten):';
|
dlgToggleSelectedDebugDesktop = 'Toggle as debug desktop';
|
||||||
|
dlgDesktopName = 'Desktop name:';
|
||||||
|
dlgOverwriteDesktop = 'Desktop with the name "%s" was found.'+sLineBreak+'Should the old desktop be overwritten?';
|
||||||
dlgDebugDesktop = 'debug desktop';
|
dlgDebugDesktop = 'debug desktop';
|
||||||
dlgDesktopHints = 'Hints';
|
dlgDesktopHints = 'Hints';
|
||||||
dlgDesktopButtons = 'Buttons - ';
|
dlgDesktopButtons = 'Buttons - ';
|
||||||
|
@ -8221,10 +8221,12 @@ begin
|
|||||||
end else if State=iwgfDisabled then
|
end else if State=iwgfDisabled then
|
||||||
SearchResultsView.DisableAutoSizing;
|
SearchResultsView.DisableAutoSizing;
|
||||||
if State>=iwgfShow then
|
if State>=iwgfShow then
|
||||||
|
begin
|
||||||
IDEWindowCreators.ShowForm(SearchresultsView,State=iwgfShowOnTop);
|
IDEWindowCreators.ShowForm(SearchresultsView,State=iwgfShowOnTop);
|
||||||
if SearchresultsView.SearchInListEdit.CanFocus then
|
if (State=iwgfShowOnTop) and SearchresultsView.SearchInListEdit.CanFocus then
|
||||||
SearchresultsView.SearchInListEdit.SetFocus;
|
SearchresultsView.SearchInListEdit.SetFocus;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.GetTestBuildDirectory: string;
|
function TMainIDE.GetTestBuildDirectory: string;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user