Save All is enabled and disabled as requiered

This commit is contained in:
Margers 2024-09-16 19:01:30 +00:00 committed by Michael Van Canneyt
parent 29ee863e8f
commit 69d552415a
2 changed files with 30 additions and 2 deletions

View File

@ -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);

View File

@ -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;