From 8a58f7c8a7096a1851eda3d47cbeae4e0130e7ac Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 23 May 2017 19:28:36 +0000 Subject: [PATCH] tvplanit: Fix print format editor crashing due to translated radiogroup items. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5897 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/languages/vpsr.de.po | 17 ++++++++ components/tvplanit/languages/vpsr.fi.po | 19 ++++++++- components/tvplanit/languages/vpsr.fr.po | 16 +++++++ components/tvplanit/languages/vpsr.nl.po | 16 +++++++ components/tvplanit/languages/vpsr.po | 16 +++++++ components/tvplanit/languages/vpsr.ru.po | 16 +++++++ components/tvplanit/source/include/vpsr.inc | 6 +++ components/tvplanit/source/vpedfmt.lfm | 2 + components/tvplanit/source/vpedfmt.pas | 47 ++++++++++++--------- components/tvplanit/source/vpedfmtlst.lfm | 2 +- components/tvplanit/source/vpedfmtlst.pas | 19 +++++---- 11 files changed, 145 insertions(+), 31 deletions(-) diff --git a/components/tvplanit/languages/vpsr.de.po b/components/tvplanit/languages/vpsr.de.po index 891f6c7be..e847e04a1 100644 --- a/components/tvplanit/languages/vpsr.de.po +++ b/components/tvplanit/languages/vpsr.de.po @@ -711,6 +711,10 @@ msgstr "TCanvas wurde nicht zugewiesen." msgid "Component must be linked to a TVpControlLink" msgstr "Komponente muss mit einem TVpControlLink verbunden sein." +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "Sprachdatei nicht gefunden." @@ -727,6 +731,10 @@ msgstr "(Nichts)" msgid "none" msgstr "keine" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "Es sind keine Druckformate definiert." @@ -1056,6 +1064,14 @@ msgstr "Samstag" msgid "Save file..." msgstr "Datei speichern..." +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "Einen Klang auswählen" @@ -1613,3 +1629,4 @@ msgstr "Unbekannte Achsen-Spezifikation: %s" #: vpsr.sxmldecnotatbeg msgid "The XML declaration must appear before the first element" msgstr "Die XML-Deklaration muss vor dem ersten Element erscheinen." + diff --git a/components/tvplanit/languages/vpsr.fi.po b/components/tvplanit/languages/vpsr.fi.po index d705d90d4..44f0acd05 100644 --- a/components/tvplanit/languages/vpsr.fi.po +++ b/components/tvplanit/languages/vpsr.fi.po @@ -701,6 +701,10 @@ msgstr "" msgid "Component must be linked to a TVpControlLink" msgstr "" +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "" @@ -717,6 +721,10 @@ msgstr "" msgid "none" msgstr "" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "" @@ -1046,6 +1054,14 @@ msgstr "Lauantai" msgid "Save file..." msgstr "" +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "" @@ -1189,9 +1205,10 @@ msgid "top line" msgstr "" #: vpsr.rstrue +#, fuzzy msgctxt "vpsr.rstrue" msgid "T" -msgstr "" +msgstr "T" #: vpsr.rstuesday msgid "Tuesday" diff --git a/components/tvplanit/languages/vpsr.fr.po b/components/tvplanit/languages/vpsr.fr.po index 16afd5d78..67db06f4b 100644 --- a/components/tvplanit/languages/vpsr.fr.po +++ b/components/tvplanit/languages/vpsr.fr.po @@ -717,6 +717,10 @@ msgstr "TCanvas non spécifié" msgid "Component must be linked to a TVpControlLink" msgstr "Le composant doit être lié à un TVpControlLink" +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "Fichier de localization non-trouvé" @@ -733,6 +737,10 @@ msgstr "(Aucun)" msgid "none" msgstr "" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "Formats d'impression non-défini" @@ -1062,6 +1070,14 @@ msgstr "Samedi" msgid "Save file..." msgstr "" +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "Choissisez un son" diff --git a/components/tvplanit/languages/vpsr.nl.po b/components/tvplanit/languages/vpsr.nl.po index 9af1f6e06..bdf9c97c9 100644 --- a/components/tvplanit/languages/vpsr.nl.po +++ b/components/tvplanit/languages/vpsr.nl.po @@ -711,6 +711,10 @@ msgstr "TCanvas is niet toegewezen." msgid "Component must be linked to a TVpControlLink" msgstr "Component moet moet met een TVpControlLink verbonden zijn" +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "Vertalingenbestand niet gevonden." @@ -727,6 +731,10 @@ msgstr "(Geen)" msgid "none" msgstr "" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "Er zijn geen afdrukformaten gedefinieerd." @@ -1056,6 +1064,14 @@ msgstr "Zaterdag" msgid "Save file..." msgstr "" +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "Kies een geluid" diff --git a/components/tvplanit/languages/vpsr.po b/components/tvplanit/languages/vpsr.po index e6f0eae6f..abe3189cc 100644 --- a/components/tvplanit/languages/vpsr.po +++ b/components/tvplanit/languages/vpsr.po @@ -701,6 +701,10 @@ msgstr "" msgid "Component must be linked to a TVpControlLink" msgstr "" +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "" @@ -717,6 +721,10 @@ msgstr "" msgid "none" msgstr "" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "" @@ -1046,6 +1054,14 @@ msgstr "" msgid "Save file..." msgstr "" +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "" diff --git a/components/tvplanit/languages/vpsr.ru.po b/components/tvplanit/languages/vpsr.ru.po index 75ba223fb..df7d77f6d 100644 --- a/components/tvplanit/languages/vpsr.ru.po +++ b/components/tvplanit/languages/vpsr.ru.po @@ -711,6 +711,10 @@ msgstr "" msgid "Component must be linked to a TVpControlLink" msgstr "" +#: vpsr.rsnodayincrement +msgid "Day increment unit not specified." +msgstr "" + #: vpsr.rsnolocalizationfile msgid "Localization file not found." msgstr "" @@ -727,6 +731,10 @@ msgstr "(Нет)" msgid "none" msgstr "" +#: vpsr.rsnoprintformatname +msgid "Please supply a format name" +msgstr "" + #: vpsr.rsnoprintformats msgid "No print formats have been defined" msgstr "Не определён формат печати" @@ -1056,6 +1064,14 @@ msgstr "Суббота" msgid "Save file..." msgstr "Сохранить файл..." +#: vpsr.rssaveformatchangestofile +msgid "Save format to file?" +msgstr "" + +#: vpsr.rssaveformatchangestofilename +msgid "Save format to \"%s\"?" +msgstr "" + #: vpsr.rsselectasound msgid "Select A Sound" msgstr "Выберите звук" diff --git a/components/tvplanit/source/include/vpsr.inc b/components/tvplanit/source/include/vpsr.inc index 269faf18f..7df1ae13d 100644 --- a/components/tvplanit/source/include/vpsr.inc +++ b/components/tvplanit/source/include/vpsr.inc @@ -319,6 +319,10 @@ resourcestring { Misc strings } RSCategoryDesc = 'Category %d'; + { Print format list } + RSSaveFormatChangesToFile = 'Save format to file?'; + RSSaveFormatChangesToFilename = 'Save format to "%s"?'; + { Print Format Editor } RSEditPrintFormat = 'Edit Print Formats...'; RSPrintFormatDesigner = 'Print format designer'; @@ -332,6 +336,8 @@ resourcestring RSNewFileBtn = 'New file'; RSLoadFileBtn = 'Load file...'; RSSaveFileBtn = 'Save file...'; + RSNoPrintFormatName = 'Please supply a format name'; + RSNoDayIncrement = 'Day increment unit not specified.'; RSReportSetup = 'Report setup'; diff --git a/components/tvplanit/source/vpedfmt.lfm b/components/tvplanit/source/vpedfmt.lfm index 8077cc9e9..a2a71ed11 100644 --- a/components/tvplanit/source/vpedfmt.lfm +++ b/components/tvplanit/source/vpedfmt.lfm @@ -188,6 +188,7 @@ object frmEditFormat: TfrmEditFormat BorderSpacing.Bottom = 4 Caption = 'OK' Default = True + ModalResult = 1 OnClick = btnOkClick TabOrder = 0 end @@ -203,6 +204,7 @@ object frmEditFormat: TfrmEditFormat BorderSpacing.Bottom = 4 Cancel = True Caption = 'Cancel' + ModalResult = 2 OnClick = btnCancelClick TabOrder = 1 end diff --git a/components/tvplanit/source/vpedfmt.pas b/components/tvplanit/source/vpedfmt.pas index 22c36847d..4e1e8f01f 100644 --- a/components/tvplanit/source/vpedfmt.pas +++ b/components/tvplanit/source/vpedfmt.pas @@ -69,7 +69,7 @@ type protected procedure SaveData(AFormat: TVpPrintFormatItem); procedure SetData(AFormat: TVpPrintFormatItem); - function Validate: Boolean; + function Validate(out AMsg: String; out AControl: TWinControl): Boolean; public function Execute(AFormat: TVpPrintFormatItem) : Boolean; end; @@ -100,20 +100,22 @@ begin end; procedure TfrmEditFormat.btnOkClick(Sender: TObject); +var + msg: String; + C: TWinControl; begin - if Validate then - ModalResult := mrOk - else begin - ShowMessage('Please supply a Format Name'); - edName.SetFocus; - Exit; + if not Validate(msg, C) then + begin + C.SetFocus; + MessageDlg(msg, mtError, [mbOK], 0); + ModalResult := mrNone; end; end; function TfrmEditFormat.Execute(AFormat: TVpPrintFormatItem) : Boolean; begin SetData(AFormat); - Result := ShowModal = mrOk; + Result := (ShowModal = mrOk); if Result then SaveData(AFormat); end; @@ -130,8 +132,7 @@ begin AFormat.FormatName := edName.Text; AFormat.Description := edDescription.Text; AFormat.DayInc := udIncrement.Position; - - EnumVal := GetEnumValue(TypeInfo(TVpDayUnits), 'du' + rgDayIncrement.Items[rgDayIncrement.ItemIndex]); + EnumVal := rgDayIncrement.ItemIndex; if EnumVal > -1 then AFormat.DayIncUnits := TVpDayUnits(EnumVal) else @@ -160,24 +161,28 @@ begin end; procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem); -var - IncName : string; begin edName.Text := AFormat.FormatName; edDescription.Text := AFormat.Description; udIncrement.Position := AFormat.DayInc; - - IncName := GetEnumName(TypeInfo(TVpDayUnits), Ord(AFormat.DayIncUnits)); - if IncName <> '' then begin - rgDayIncrement.ItemIndex := rgDayIncrement.Items.IndexOf(Copy(IncName, 3, Length(IncName) - 2)); - end - else - rgDayIncrement.ItemIndex := 0; + rgDayIncrement.ItemIndex := ord(AFormat.DayIncUnits); end; -function TfrmEditFormat.Validate : Boolean; +function TfrmEditFormat.Validate(out AMsg: String; + out AControl: TWinControl) : Boolean; begin - Result := edName.Text <> ''; + Result := false; + if (edName.Text = '') then begin + AMsg := RSNoPrintFormatName; + AControl := edName; + exit; + end; + if (RgDayIncrement.ItemIndex < 0) then begin + AMsg := RSNoDayIncrement; + AControl := RgDayIncrement; + exit; + end; + Result := true; end; end. diff --git a/components/tvplanit/source/vpedfmtlst.lfm b/components/tvplanit/source/vpedfmtlst.lfm index 92c0820ac..2a810f1dc 100644 --- a/components/tvplanit/source/vpedfmtlst.lfm +++ b/components/tvplanit/source/vpedfmtlst.lfm @@ -11,7 +11,7 @@ object frmPrnFormat: TfrmPrnFormat OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.9.0.0' + LCLVersion = '1.6.4.0' object LblFormats: TLabel AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner diff --git a/components/tvplanit/source/vpedfmtlst.pas b/components/tvplanit/source/vpedfmtlst.pas index e41b171ec..186cbde26 100644 --- a/components/tvplanit/source/vpedfmtlst.pas +++ b/components/tvplanit/source/vpedfmtlst.pas @@ -246,9 +246,9 @@ begin if IsDirty then begin Rslt := DirtyPrompt; case Rslt of - ID_YES : DoSave; - ID_NO : ; // nothing - ID_CANCEL : Exit; + mrYes : DoSave; + mrNo : ; // nothing + mrCancel : Exit; end; end; @@ -340,12 +340,15 @@ begin end; {=====} function TfrmPrnFormat.DirtyPrompt: Integer; +var + msg: String; + fn: String; begin - Result := Application.MessageBox( - PChar('Save changes to ' + FormatFileName + '?'), - PChar('Inquiry'), - MB_YESNOCANCEL or MB_ICONQUESTION - ); + if FormatFileName = '' then + msg := RSSaveFormatChangesToFile + else + msg := Format(RSSaveFormatChangesToFilename, [FormatFileName]); + Result := MessageDlg(msg, mtConfirmation, [mbYes, mbNo, mbCancel], 0); end; {=====} procedure TfrmPrnFormat.DoEditElement;