mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 04:58:11 +02:00
IDE: do not double check overwrite when savedialog already does
git-svn-id: branches/fixes_2_0@63607 -
This commit is contained in:
parent
764bbbc59c
commit
bda8742a72
@ -21,11 +21,30 @@ uses
|
||||
// LCL
|
||||
Dialogs,
|
||||
// LazUtils
|
||||
UITypes,
|
||||
UITypes, LazFileCache,
|
||||
// IdeIntf
|
||||
LazMsgDialogs;
|
||||
|
||||
type
|
||||
|
||||
{ TIDEOpenDialog }
|
||||
|
||||
TIDEOpenDialog = class(TOpenDialog)
|
||||
protected
|
||||
function DoExecute: boolean; override;
|
||||
end;
|
||||
TIDEOpenDialogClass = class of TIDEOpenDialog;
|
||||
|
||||
{ TIDESaveDialog }
|
||||
|
||||
TIDESaveDialog = class(TSaveDialog)
|
||||
protected
|
||||
function DoExecute: boolean; override;
|
||||
public
|
||||
class function NeedOverwritePrompt: boolean; virtual;
|
||||
end;
|
||||
TIDESaveDialogClass = class of TIDESaveDialog;
|
||||
|
||||
TIDESelectDirectory = function(const Title, InitialDir: string): string of object;
|
||||
TInitIDEFileDialog = procedure(AFileDialog: TFileDialog) of object;
|
||||
TStoreIDEFileDialog = procedure(AFileDialog: TFileDialog) of object;
|
||||
@ -34,6 +53,8 @@ var // set by the IDE
|
||||
LazIDESelectDirectory: TIDESelectDirectory = nil;
|
||||
InitIDEFileDialog: TInitIDEFileDialog = nil;
|
||||
StoreIDEFileDialog: TStoreIDEFileDialog = nil;
|
||||
IDEOpenDialogClass: TIDEOpenDialogClass = TIDEOpenDialog;
|
||||
IDESaveDialogClass: TIDESaveDialogClass = TIDESaveDialog;
|
||||
|
||||
// Wrapper function for LazIDESelectDirectory with a default parameter.
|
||||
function LazSelectDirectory(const Title: string; const InitialDir: string = ''): string;
|
||||
@ -153,6 +174,25 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TIDESaveDialog.DoExecute: boolean;
|
||||
begin
|
||||
Result:=inherited DoExecute;
|
||||
LazFileCache.InvalidateFileStateCache;
|
||||
end;
|
||||
|
||||
class function TIDESaveDialog.NeedOverwritePrompt: boolean;
|
||||
begin
|
||||
Result:={$if defined(LCLCocoa)}false{$else}true{$endif};
|
||||
end;
|
||||
|
||||
{ TIDEOpenDialog }
|
||||
|
||||
function TIDEOpenDialog.DoExecute: boolean;
|
||||
begin
|
||||
Result:=inherited DoExecute;
|
||||
LazFileCache.InvalidateFileStateCache;
|
||||
end;
|
||||
|
||||
{ TIgnoreIDEQuestionItem }
|
||||
|
||||
constructor TIgnoreIDEQuestionItem.Create(const TheIdentifier: string);
|
||||
|
@ -4528,7 +4528,7 @@ end;
|
||||
function ShowSaveFileAsDialog(var AFilename: string; AnUnitInfo: TUnitInfo;
|
||||
var LFMCode, LRSCode: TCodeBuffer; CanAbort: boolean): TModalResult;
|
||||
var
|
||||
SaveDialog: TSaveDialog;
|
||||
SaveDialog: TIDESaveDialog;
|
||||
SrcEdit: TSourceEditor;
|
||||
SaveAsFilename, SaveAsFileExt: string;
|
||||
NewFilename, NewFileExt: string;
|
||||
@ -4570,7 +4570,7 @@ begin
|
||||
SaveAsFilename:=LowerCase(SaveAsFilename);
|
||||
|
||||
// let user choose a filename
|
||||
SaveDialog:=TSaveDialog.Create(nil);
|
||||
SaveDialog:=IDESaveDialogClass.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(SaveDialog);
|
||||
SaveDialog.Title:=lisSaveSpace+SaveAsFilename+' (*'+SaveAsFileExt+')';
|
||||
@ -4697,7 +4697,9 @@ begin
|
||||
end;
|
||||
|
||||
// check overwrite existing file
|
||||
if ((not FilenameIsAbsolute(AFilename)) or (CompareFilenames(NewFilename,AFilename)<>0))
|
||||
if IDESaveDialogClass.NeedOverwritePrompt
|
||||
and ((not FilenameIsAbsolute(AFilename))
|
||||
or (CompareFilenames(NewFilename,AFilename)<>0))
|
||||
and FileExistsUTF8(NewFilename) then
|
||||
begin
|
||||
ACaption:=lisOverwriteFile;
|
||||
@ -7524,7 +7526,7 @@ function ShowSaveProjectAsDialog(UseMainSourceFile: boolean): TModalResult;
|
||||
var
|
||||
MainUnitSrcEdit: TSourceEditor;
|
||||
MainUnitInfo: TUnitInfo;
|
||||
SaveDialog: TSaveDialog;
|
||||
SaveDialog: TIDESaveDialog;
|
||||
NewBuf, OldBuf: TCodeBuffer;
|
||||
TitleWasDefault: Boolean;
|
||||
NewLPIFilename, NewProgramFN, NewProgramName, AFilename, NewTargetFN: String;
|
||||
@ -7539,7 +7541,7 @@ begin
|
||||
if Project1.MainUnitInfo = nil then
|
||||
UseMainSourceFile := False;
|
||||
|
||||
SaveDialog:=TSaveDialog.Create(nil);
|
||||
SaveDialog:=IDESaveDialogClass.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(SaveDialog);
|
||||
AFilename:='';
|
||||
@ -7655,10 +7657,13 @@ begin
|
||||
// Note: if user confirms overwriting .lpi do not ask for overwriting .lpr
|
||||
if FileExistsUTF8(NewLPIFilename) then
|
||||
begin
|
||||
ACaption:=lisOverwriteFile;
|
||||
AText:=Format(lisAFileAlreadyExistsReplaceIt, [NewLPIFilename, LineEnding]);
|
||||
Result:=IDEMessageDialog(ACaption, AText, mtConfirmation, [mbOk, mbCancel]);
|
||||
if Result=mrCancel then exit;
|
||||
if IDESaveDialogClass.NeedOverwritePrompt then
|
||||
begin
|
||||
ACaption:=lisOverwriteFile;
|
||||
AText:=Format(lisAFileAlreadyExistsReplaceIt, [NewLPIFilename, LineEnding]);
|
||||
Result:=IDEMessageDialog(ACaption, AText, mtConfirmation, [mbOk, mbCancel]);
|
||||
if Result=mrCancel then exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user