mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 12:39:18 +02:00
IDE: auto update of save speedbuttons and menu items
git-svn-id: trunk@12122 -
This commit is contained in:
parent
6808002ecd
commit
0d555e756d
@ -1317,6 +1317,7 @@ begin
|
|||||||
// write
|
// write
|
||||||
InvalidateFileStateCache;
|
InvalidateFileStateCache;
|
||||||
XMLConfigFile.Flush;
|
XMLConfigFile.Flush;
|
||||||
|
FModified := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBaseCompilerOptions.SetModified(const AValue: boolean);
|
procedure TBaseCompilerOptions.SetModified(const AValue: boolean);
|
||||||
|
34
ide/main.pp
34
ide/main.pp
@ -761,6 +761,7 @@ type
|
|||||||
IgnorePageIndex: integer): string;
|
IgnorePageIndex: integer): string;
|
||||||
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
||||||
function GetAncestorLookupRoot(AnUnitInfo: TUnitInfo): TComponent;
|
function GetAncestorLookupRoot(AnUnitInfo: TUnitInfo): TComponent;
|
||||||
|
procedure UpdateSaveMenuItemsAndButtons(UpdateSaveAll: boolean);
|
||||||
|
|
||||||
// useful file methods
|
// useful file methods
|
||||||
function FindUnitFile(const AFilename: string): string; override;
|
function FindUnitFile(const AFilename: string): string; override;
|
||||||
@ -5560,6 +5561,26 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.UpdateSaveMenuItemsAndButtons(UpdateSaveAll: boolean);
|
||||||
|
var
|
||||||
|
SrcEdit: TSourceEditor;
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
begin
|
||||||
|
GetCurrentUnit(SrcEdit,AnUnitInfo);
|
||||||
|
// menu items
|
||||||
|
if UpdateSaveAll then
|
||||||
|
MainIDEBar.itmProjectSave.Enabled := SomethingOfProjectIsModified;
|
||||||
|
MainIDEBar.itmFileSave.Enabled := (SrcEdit<>nil)
|
||||||
|
and SourceNotebook.GetActiveSe.Modified;
|
||||||
|
if UpdateSaveAll then
|
||||||
|
MainIDEBar.itmFileSaveAll.Enabled := (SrcEdit<>nil)
|
||||||
|
and SourceNotebook.SomethingModified;
|
||||||
|
// toolbar buttons
|
||||||
|
MainIDEBar.SaveSpeedBtn.Enabled := MainIDEBar.itmFileSave.Enabled;
|
||||||
|
if UpdateSaveAll then
|
||||||
|
MainIDEBar.SaveAllSpeedBtn.Enabled := MainIDEBar.itmFileSaveAll.Enabled;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.CreateProjectObject(ProjectDesc,
|
function TMainIDE.CreateProjectObject(ProjectDesc,
|
||||||
FallbackProjectDesc: TProjectDescriptor): TProject;
|
FallbackProjectDesc: TProjectDescriptor): TProject;
|
||||||
begin
|
begin
|
||||||
@ -6328,7 +6349,7 @@ begin
|
|||||||
if not (sfSaveToTestDir in Flags) then begin
|
if not (sfSaveToTestDir in Flags) then begin
|
||||||
ActiveUnitInfo.ClearModifieds;
|
ActiveUnitInfo.ClearModifieds;
|
||||||
ActiveSrcEdit.Modified:=false;
|
ActiveSrcEdit.Modified:=false;
|
||||||
MainIDEBar.SaveSpeedBtn.Enabled := SourceNotebook.GetActiveSe.Modified;
|
UpdateSaveMenuItemsAndButtons(not (sfProjectSaving in Flags));
|
||||||
end;
|
end;
|
||||||
SourceNoteBook.UpdateStatusBar;
|
SourceNoteBook.UpdateStatusBar;
|
||||||
|
|
||||||
@ -7359,6 +7380,9 @@ begin
|
|||||||
// everything went well => clear all modified flags
|
// everything went well => clear all modified flags
|
||||||
Project1.ClearModifieds(true);
|
Project1.ClearModifieds(true);
|
||||||
|
|
||||||
|
// update menu and buttons state
|
||||||
|
UpdateSaveMenuItemsAndButtons(true);
|
||||||
|
|
||||||
DebugLn('TMainIDE.DoSaveProject End');
|
DebugLn('TMainIDE.DoSaveProject End');
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
@ -8364,6 +8388,7 @@ begin
|
|||||||
CurResult:=DoCallModalFunctionHandler(lihtOnSavedAll);
|
CurResult:=DoCallModalFunctionHandler(lihtOnSavedAll);
|
||||||
if CurResult=mrAbort then exit(mrAbort);
|
if CurResult=mrAbort then exit(mrAbort);
|
||||||
if CurResult<>mrOk then Result:=mrCancel;
|
if CurResult<>mrOk then Result:=mrCancel;
|
||||||
|
UpdateSaveMenuItemsAndButtons(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.DoRestart;
|
procedure TMainIDE.DoRestart;
|
||||||
@ -11704,7 +11729,7 @@ begin
|
|||||||
Project1.UnitWithEditorIndex(SourceNotebook.Notebook.PageIndex);
|
Project1.UnitWithEditorIndex(SourceNotebook.Notebook.PageIndex);
|
||||||
if ActiveUnitInfo = nil then Exit;
|
if ActiveUnitInfo = nil then Exit;
|
||||||
|
|
||||||
MainIDEBar.SaveSpeedBtn.Enabled := SourceNotebook.GetActiveSe.Modified;
|
UpdateSaveMenuItemsAndButtons(false);
|
||||||
MainIDEBar.ToggleFormSpeedBtn.Enabled := Assigned(ActiveUnitInfo.Component)
|
MainIDEBar.ToggleFormSpeedBtn.Enabled := Assigned(ActiveUnitInfo.Component)
|
||||||
or (ActiveUnitInfo.ComponentName<>'');
|
or (ActiveUnitInfo.ComponentName<>'');
|
||||||
end;
|
end;
|
||||||
@ -11713,7 +11738,7 @@ end;
|
|||||||
Procedure TMainIDE.OnSrcNotebookEditorChanged(Sender: TObject);
|
Procedure TMainIDE.OnSrcNotebookEditorChanged(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNotebook.Notebook = nil then Exit;
|
if SourceNotebook.Notebook = nil then Exit;
|
||||||
MainIDEBar.SaveSpeedBtn.Enabled := SourceNotebook.GetActiveSE.Modified;
|
UpdateSaveMenuItemsAndButtons(false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNotebookCurCodeBufferChanged(Sender: TObject);
|
procedure TMainIDE.OnSrcNotebookCurCodeBufferChanged(Sender: TObject);
|
||||||
@ -12371,8 +12396,7 @@ begin
|
|||||||
FormEditor1.CheckDesignerPositions;
|
FormEditor1.CheckDesignerPositions;
|
||||||
FormEditor1.PaintAllDesignerItems;
|
FormEditor1.PaintAllDesignerItems;
|
||||||
GetCurrentUnit(SrcEdit,AnUnitInfo);
|
GetCurrentUnit(SrcEdit,AnUnitInfo);
|
||||||
MainIDEBar.SaveSpeedBtn.Enabled := (SrcEdit<>nil)
|
UpdateSaveMenuItemsAndButtons(true);
|
||||||
and SourceNotebook.GetActiveSe.Modified;
|
|
||||||
if Screen.ActiveForm<>nil then begin
|
if Screen.ActiveForm<>nil then begin
|
||||||
AnIDesigner:=Screen.ActiveForm.Designer;
|
AnIDesigner:=Screen.ActiveForm.Designer;
|
||||||
if AnIDesigner is TDesigner then begin
|
if AnIDesigner is TDesigner then begin
|
||||||
|
@ -3527,27 +3527,34 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
if CheckData then begin
|
if CheckData then begin
|
||||||
if Modified then begin
|
if Modified then begin
|
||||||
DebugLn('TProject.SomethingModified Modified');
|
//DebugLn('TProject.SomethingModified Modified');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if CompilerOptions.Modified then begin
|
||||||
|
Modified:=true;
|
||||||
|
DebugLn(['TProject.SomethingModified CompilerOptions']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if CompilerOptions.Modified then exit;
|
|
||||||
for i:=0 to UnitCount-1 do
|
for i:=0 to UnitCount-1 do
|
||||||
if (Units[i].IsPartOfProject) and Units[i].Modified then begin
|
if (Units[i].IsPartOfProject) and Units[i].Modified then begin
|
||||||
|
Modified:=true;
|
||||||
DebugLn('TProject.SomethingModified PartOfProject ',Units[i].Filename);
|
DebugLn('TProject.SomethingModified PartOfProject ',Units[i].Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if CheckSession then begin
|
if CheckSession then begin
|
||||||
if SessionModified then begin
|
if SessionModified then begin
|
||||||
DebugLn('TProject.SomethingModified SessionModified');
|
//DebugLn('TProject.SomethingModified SessionModified');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
for i:=0 to UnitCount-1 do begin
|
for i:=0 to UnitCount-1 do begin
|
||||||
if Units[i].SessionModified then begin
|
if Units[i].SessionModified then begin
|
||||||
|
SessionModified:=true;
|
||||||
DebugLn('TProject.SomethingModified Session ',Units[i].Filename);
|
DebugLn('TProject.SomethingModified Session ',Units[i].Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (not Units[i].IsPartOfProject) and Units[i].Modified then begin
|
if (not Units[i].IsPartOfProject) and Units[i].Modified then begin
|
||||||
|
SessionModified:=true;
|
||||||
DebugLn('TProject.SomethingModified Not PartOfProject ',Units[i].Filename);
|
DebugLn('TProject.SomethingModified Not PartOfProject ',Units[i].Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user