mirror of https://gitlab.com/basile.b/dexed.git
use a common dialog to warn about unsaved changes, + use this in miniexplorer which didnt warn when opening a proj
This commit is contained in:
parent
89675d2c57
commit
6c90ec9a6c
|
@ -23,6 +23,10 @@ function dlgOkInfo(const aMsg: string): TModalResult;
|
|||
*)
|
||||
function dlgOkError(const aMsg: string): TModalResult;
|
||||
|
||||
(**
|
||||
* close aFilename Ok/Cancel.
|
||||
*)
|
||||
function dlgFileChangeClose(const aFilename: string): TModalResult;
|
||||
|
||||
const
|
||||
DdiagFilter = 'D source|*.d|D interface|*.di|All files|*.*';
|
||||
|
@ -51,5 +55,12 @@ begin
|
|||
exit( MessageDlg('Coedit', aMsg, mtError, Btns, ''));
|
||||
end;
|
||||
|
||||
function dlgFileChangeClose(const aFilename: string): TModalResult;
|
||||
const
|
||||
fmt = '"%s" latest modifications are not saved.'#13#10#13#10'Close it without saving ?';
|
||||
begin
|
||||
exit(dlgOkCancel(format(fmt, [aFilename])));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -249,9 +249,8 @@ var
|
|||
doc: TCESynMemo;
|
||||
begin
|
||||
doc := getDocument(index);
|
||||
if doc.modified then if dlgOkCancel(format(
|
||||
'The latest "%s" modifications are not saved, close without saving ?',
|
||||
[shortenPath(doc.fileName,25)])) = mrCancel then exit(false);
|
||||
if doc.modified and (dlgFileChangeClose(fDoc.fileName) = mrCancel) then
|
||||
exit(false);
|
||||
doc.Free;
|
||||
result := true;
|
||||
end;
|
||||
|
|
|
@ -1065,10 +1065,8 @@ var
|
|||
begin
|
||||
canClose := false;
|
||||
SaveLastDocsAndProj;
|
||||
if fProjectInterface <> nil then if fProjectInterface.modified then
|
||||
if dlgOkCancel(
|
||||
'The project modifications are not saved, close without saving ?') <> mrOK then
|
||||
exit;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
for i := fMultidoc.documentCount-1 downto 0 do
|
||||
if not fMultidoc.closeDocument(i) then exit;
|
||||
canClose := true;
|
||||
|
@ -1493,10 +1491,7 @@ end;
|
|||
procedure TCEMainForm.actFileCloseExecute(Sender: TObject);
|
||||
begin
|
||||
if fDoc = nil then exit;
|
||||
if fDoc.modified then if dlgOkCancel(
|
||||
'The file modifications are not saved, close without saving ?') = mrCancel
|
||||
then exit;
|
||||
//
|
||||
if fDoc.modified and (dlgFileChangeClose(fDoc.fileName) = mrCancel) then exit;
|
||||
fDoc.Free;
|
||||
end;
|
||||
|
||||
|
@ -2060,18 +2055,18 @@ end;
|
|||
|
||||
procedure TCEMainForm.actProjNewDubJsonExecute(Sender: TObject);
|
||||
begin
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and (dlgOkCancel(
|
||||
'The project modifications are not saved, close without saving ?') = mrCancel) then exit;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
closeProj;
|
||||
newDubProj;
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.actProjNewNativeExecute(Sender: TObject);
|
||||
begin
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and (dlgOkCancel(
|
||||
'The project modifications are not saved, close without saving ?') = mrCancel) then exit;
|
||||
closeProj;
|
||||
newNativeProj;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
closeProj;
|
||||
newNativeProj;
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.newNativeProj;
|
||||
|
@ -2117,16 +2112,15 @@ end;
|
|||
|
||||
procedure TCEMainForm.mruProjItemClick(Sender: TObject);
|
||||
begin
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and (dlgOkCancel(
|
||||
'The project modifications are not saved, close without saving ?') = mrCancel) then exit;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
openProj(TMenuItem(Sender).Hint);
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.actProjCloseExecute(Sender: TObject);
|
||||
begin
|
||||
if fProjectInterface = nil then exit;
|
||||
if fProjectInterface.modified and (dlgOkCancel(
|
||||
'The project modifications are not saved, clsoe without saving ?') = mrCancel) then exit;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
closeProj;
|
||||
end;
|
||||
|
||||
|
@ -2149,9 +2143,8 @@ end;
|
|||
|
||||
procedure TCEMainForm.actProjOpenExecute(Sender: TObject);
|
||||
begin
|
||||
if fProjectInterface <> nil then if fProjectInterface.modified then if dlgOkCancel(
|
||||
'The project modifications are not saved, close without saving ?')
|
||||
= mrCancel then exit;
|
||||
if (fProjectInterface <> nil) and fProjectInterface.modified and
|
||||
(dlgFileChangeClose(fProjectInterface.filename) = mrCancel) then exit;
|
||||
with TOpenDialog.Create(nil) do
|
||||
try
|
||||
if execute then openProj(filename);
|
||||
|
|
|
@ -8,7 +8,7 @@ uses
|
|||
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics,
|
||||
ExtCtrls, Menus, ComCtrls, Buttons, lcltype, strutils, ce_widget, ce_sharedres,
|
||||
ce_common, ce_interfaces, ce_observer, ce_writableComponent, ce_dubproject,
|
||||
ce_nativeproject, EditBtn;
|
||||
ce_nativeproject, EditBtn, ce_dialogs;
|
||||
|
||||
type
|
||||
|
||||
|
@ -351,13 +351,23 @@ begin
|
|||
{$ENDIF}
|
||||
if isValidNativeProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then fProj.getProject.Free;
|
||||
if assigned(fProj) then
|
||||
begin
|
||||
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
end;
|
||||
TCENativeProject.create(nil);
|
||||
proj := true;
|
||||
end
|
||||
else if isValidDubProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then fProj.getProject.Free;
|
||||
if assigned(fProj) then
|
||||
begin
|
||||
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
end;
|
||||
TCEDubProject.create(nil);
|
||||
proj := true;
|
||||
end;
|
||||
|
|
Loading…
Reference in New Issue