From 69d552415a179d6b2aaaaf1fa93598d92650e0eb Mon Sep 17 00:00:00 2001 From: Margers Date: Mon, 16 Sep 2024 19:01:30 +0000 Subject: [PATCH] Save All is enabled and disabled as requiered --- packages/ide/fpide.pas | 3 ++- packages/ide/fpviews.pas | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/ide/fpide.pas b/packages/ide/fpide.pas index da01722438..63df6ed985 100644 --- a/packages/ide/fpide.pas +++ b/packages/ide/fpide.pas @@ -1039,6 +1039,7 @@ procedure TIDEApp.InitMenuBar; begin LoadMenuBar; DisableCommands(EditorCmds+SourceCmds+CompileCmds); + SetCmdState([cmTile,cmCascade],false); // Update; Desktop is still nil at that point ... end; @@ -1624,7 +1625,7 @@ procedure TIDEApp.Update; begin SetCmdState([cmSaveAll],IsThereAnyEditor); SetCmdState([cmCloseAll,cmWindowList],IsThereAnyWindow); - SetCmdState([cmTile,cmCascade],IsThereAnyVisibleWindow); + SetCmdState([cmTile,cmCascade],IsThereAnyVisibleEditorWindow); SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals,cmSymbol],IsSymbolInfoAvailable); {$ifndef NODEBUG} SetCmdState([cmResetDebugger,cmUntilReturn],assigned(debugger) and debugger^.debuggee_started); diff --git a/packages/ide/fpviews.pas b/packages/ide/fpviews.pas index b18c7e6d4a..9b9d3fb205 100644 --- a/packages/ide/fpviews.pas +++ b/packages/ide/fpviews.pas @@ -192,6 +192,8 @@ type function GetPalette: PPalette; virtual; constructor Load(var S: TStream); procedure Store(var S: TStream); + procedure Show; virtual; + procedure Hide; virtual; procedure Close; virtual; destructor Done; virtual; end; @@ -446,6 +448,7 @@ function IsWindow(P: PView): boolean; function IsThereAnyEditor: boolean; function IsThereAnyWindow: boolean; function IsThereAnyVisibleWindow: boolean; +function IsThereAnyVisibleEditorWindow: boolean; {any visible Source Editor, including Clipboard} function IsThereAnyNumberedWindow: boolean; function FirstEditorWindow: PSourceWindow; function EditorWindowFile(const Name : String): PSourceWindow; @@ -803,6 +806,15 @@ begin IsThereAnyVisibleWindow:=Desktop^.FirstThat(@CheckIt)<>nil; end; +function IsThereAnyVisibleEditorWindow: boolean; +function EditorWindow(P: PView): boolean; +begin + EditorWindow:=((P^.HelpCtx=hcSourceWindow) or (P^.HelpCtx=hcClipboardWindow)) and P^.GetState(sfVisible); +end; +begin + IsThereAnyVisibleEditorWindow:=Desktop^.FirstThat(@EditorWindow)<>nil; +end; + function FirstEditorWindow: PSourceWindow; function EditorWindow(P: PView): boolean; begin @@ -2323,7 +2335,7 @@ begin SetCmdState(SourceCmds+CompileCmds,Active); SetCmdState(EditorCmds,Active); end; - SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active); + SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd+[cmHide],Active); Message(Application,evBroadcast,cmCommandSetChanged,nil); end; @@ -2364,6 +2376,17 @@ begin PopStatus; end; +procedure TSourceWindow.Show; +begin + inherited Show; + IDEApp.SetCmdState([cmTile,cmCascade],true); +end; + +procedure TSourceWindow.Hide; +begin + inherited Hide; + IDEApp.SetCmdState([cmTile,cmCascade],IsThereAnyVisibleEditorWindow); +end; procedure TSourceWindow.Close; begin @@ -3931,6 +3954,10 @@ begin { this makes loading a lot slower and is not needed as far as I can see (FK) Message(Application,evBroadcast,cmUpdate,nil); } + if ShowIt then + W^.SetCmdState([cmTile,cmCascade,cmSaveAll],true) + else + W^.SetCmdState([cmSaveAll],true); end; PopStatus; IOpenEditorWindow:=W;