tvplanit: Add "Don't ask again" checkbox to VpPrtFmt editor save prompt by using a TTaskDialog. Update resource strings and translations.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8540 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-10-12 11:33:16 +00:00
parent 521c9e0d90
commit 03e1ff9059
25 changed files with 479 additions and 176 deletions

View File

@ -109,6 +109,7 @@ type
LastX, LastY: Integer;
DragItem: Integer;
FDrawingStyle: TVpDrawingStyle;
FShowSavePrompt: Boolean;
procedure PositionControls;
procedure SetCaptions;
procedure SetDrawingStyle(const v: TVpDrawingStyle);
@ -137,6 +138,7 @@ type
function Execute: Boolean;
property ControlLink: TVpControlLink read FControlLink write SetControlLink;
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle;
property ShowSavePrompt: Boolean read FShowSavePrompt write FShowSavePrompt;
published
property FormatFileName : string read FFormatFileName write SetFormatFileName;
@ -167,6 +169,7 @@ begin
OpenDialog.InitialDir := ExtractFilePath(Application.ExeName);
SaveDialog.InitialDir := ExtractFilePath(Application.ExeName);
IsDirty := False;
FShowSavePrompt := true;
FormatFileName := UnnamedFile;
EnableFormatButtons(False);
@ -374,12 +377,26 @@ end;
function TfrmPrnFormat.DirtyPrompt: Integer;
var
msg: String;
taskDlg: TTaskDialog;
begin
if FormatFileName = '' then
msg := RSSaveFormatChangesToFile
else
msg := Format(RSSaveFormatChangesToFilename, [FormatFileName]);
Result := MessageDlg(msg, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
taskDlg := TTaskDialog.Create(self);
taskDlg.Text := msg;
taskDlg.Caption := RSConfirmation;
taskDlg.MainIcon := tdiQuestion;
taskDlg.Title := RSSavePrintFormat;
taskDlg.CommonButtons := [tcbYes, tcbNo, tcbCancel];
taskDlg.VerificationText := RSDoNotAskAgain;
taskDlg.Execute;
FShowSavePrompt := not (tfVerificationFlagChecked in taskDlg.Flags);
Result := taskDlg.ModalResult;
taskDlg.Free;
//Result := MessageDlg(msg, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
end;
procedure TfrmPrnFormat.DoEditElement;
@ -451,9 +468,9 @@ begin
Cancelled := not frmEditElement.Execute(E);
if not Cancelled then begin
if lbElements.Items.IndexOf(E.ElementName) > -1 then begin
ShowMessage('An Element named ' + E.ElementName + ' already exists.' +
#13#10 + 'Please use another name.');
if lbElements.Items.IndexOf(E.ElementName) > -1 then
begin
MessageDlg(SysUtils.Format(RSElementAlreadyExists, [E.ElementName]), mtError, [mbOK], 0);
// Dump empty element
Format.Elements.Items[E.Index].Free;
Unique := False;
@ -468,7 +485,7 @@ begin
end else
// Dump empty element
Format.Elements.Items[E.Index].Free;
// ...until element name is Unique or operation is cancelled
// ...until element name is unique or operation is cancelled
until Unique or Cancelled;
EnableElementButtons(true);
@ -512,8 +529,7 @@ begin
if not Cancelled then begin
if lbFormats.Items.IndexOf(AFormat.FormatName) > -1 then begin
ShowMessage('A format named ' + AFormat.FormatName + ' already exists.' +
#13#10 + 'Please use another name.');
MessageDlg(Format(RSPrintFormatAlreadyExists, [AFormat.FormatName]), mtError, [mbOK], 0);
// Dump empty format
Prn.PrintFormats.Items[AFormat.Index].Free;
Unique := False;
@ -547,7 +563,8 @@ begin
SaveDialog.FileName := FormatFileName
else
SaveDialog.FileName := 'Unnamed.xml';
if SaveDialog.Execute then begin
if SaveDialog.Execute then
begin
FormatFileName := SaveDialog.FileName;
ControlLink.Printer.SaveToFile(FormatFileName);
IsDirty := False;
@ -582,7 +599,7 @@ procedure TfrmPrnFormat.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanClose := True;
if IsDirty then begin
if IsDirty and FShowSavePrompt then begin
case DirtyPrompt of
mrYes: DoSave;
mrNo: ;
@ -799,7 +816,6 @@ begin
Idx := Prn.Find(lbFormats.Items[lbFormats.ItemIndex]);
if Idx > - 1 then
Prn.CurFormat := Idx;
{Prn.CurFormat := lbFormats.ItemIndex; }
end;
Prn.NotifyLinked;
EnableMoveButtons;