From 094a2938ea398fc69b35188c7cd19fdd08293070 Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 3 Nov 2019 19:59:21 +0000 Subject: [PATCH] EditorMacros: Add a warning / Show warning if PascalScript self-test failed. git-svn-id: trunk@62178 - --- components/ideintf/srceditorintf.pas | 39 ++++++++++ components/macroscript/emsstrings.pas | 1 + .../macroscript/languages/emsstrings.fr.po | 4 ++ .../macroscript/languages/emsstrings.hu.po | 4 ++ .../macroscript/languages/emsstrings.it.po | 4 ++ .../macroscript/languages/emsstrings.lt.po | 4 ++ .../macroscript/languages/emsstrings.pot | 4 ++ .../macroscript/languages/emsstrings.pt_BR.po | 4 ++ .../macroscript/languages/emsstrings.ru.po | 4 ++ .../macroscript/languages/emsstrings.uk.po | 4 ++ .../macroscript/languages/emsstrings.zh_CN.po | 4 ++ components/macroscript/registerems.pas | 4 ++ ide/editormacrolistviewer.lfm | 71 +++++++++++++++---- ide/editormacrolistviewer.pas | 28 +++++++- 14 files changed, 164 insertions(+), 15 deletions(-) diff --git a/components/ideintf/srceditorintf.pas b/components/ideintf/srceditorintf.pas index f847347033..bf402b779d 100644 --- a/components/ideintf/srceditorintf.pas +++ b/components/ideintf/srceditorintf.pas @@ -457,6 +457,15 @@ var DefaultBindingClass: TEditorMacroKeyBindingClass = nil; EditorMacroPlayerClass: TEditorMacroClass = nil; +function GetMacroListViewerWarningText: String; +procedure SetMacroListViewerWarningText(AValue: String); +function GetMacroListViewerWarningChanged: TNotifyProcedure; +procedure SetMacroListViewerWarningChanged(AValue: TNotifyProcedure); + +property MacroListViewerWarningText: string read GetMacroListViewerWarningText write SetMacroListViewerWarningText; +property MacroListViewerWarningChanged: TNotifyProcedure read GetMacroListViewerWarningChanged write SetMacroListViewerWarningChanged; + + type { TIDEInteractiveStringValue } @@ -745,6 +754,36 @@ begin CheckStateAndActivated; end; +var + FMacroListViewerWarningText: String; + FMacroListViewerWarningChanged: TNotifyProcedure; + +function GetMacroListViewerWarningText: String; +begin + Result := FMacroListViewerWarningText; +end; + +procedure SetMacroListViewerWarningText(AValue: String); +begin + FMacroListViewerWarningText := AValue; + if FMacroListViewerWarningChanged <> nil then + FMacroListViewerWarningChanged(nil); +end; + +function GetMacroListViewerWarningChanged: TNotifyProcedure; +begin + Result := FMacroListViewerWarningChanged; +end; + +procedure SetMacroListViewerWarningChanged(AValue: TNotifyProcedure); +begin + FMacroListViewerWarningChanged := AValue; + if (FMacroListViewerWarningChanged <> nil) and + (FMacroListViewerWarningText <> '') + then + FMacroListViewerWarningChanged(nil); +end; + { TEditorMacro } { TSourceEditorInterface } diff --git a/components/macroscript/emsstrings.pas b/components/macroscript/emsstrings.pas index e13aa72285..aac6c9319d 100644 --- a/components/macroscript/emsstrings.pas +++ b/components/macroscript/emsstrings.pas @@ -17,6 +17,7 @@ resourcestring EMSBtnTestAgain = 'Test again'; EMSNotSupported = 'Scripting not active. Not supported on this platform or CPU.'; EMSNotActive = 'Scripting not active. Selftest failed.'; + EMSNotActiveVerbose = 'EditorMacroScript failed its self-test and is not active. Some macros may not work.'; EMSActive = 'Scripting active.'; EMSPending = 'Scripting not active. Selftest will run next time the IDE is ' +'started.'; diff --git a/components/macroscript/languages/emsstrings.fr.po b/components/macroscript/languages/emsstrings.fr.po index 71f6f67666..4c95e64814 100644 --- a/components/macroscript/languages/emsstrings.fr.po +++ b/components/macroscript/languages/emsstrings.fr.po @@ -28,6 +28,10 @@ msgstr "Script de macro de l'éditeur" msgid "Scripting not active. Selftest failed." msgstr "Script inactif. L'autotest a échoué." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Script inactif. Non supporté par cette plateforme ou ce CPU." diff --git a/components/macroscript/languages/emsstrings.hu.po b/components/macroscript/languages/emsstrings.hu.po index 6c2b5be94d..09240cc609 100644 --- a/components/macroscript/languages/emsstrings.hu.po +++ b/components/macroscript/languages/emsstrings.hu.po @@ -27,6 +27,10 @@ msgstr "Szerkesztő Makrószkript" msgid "Scripting not active. Selftest failed." msgstr "Szkriptek használata kikapcsolva. Az önellenőrzés sikertelen volt." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Szkriptek használata kikapcsolva. Nem támogatott platform vagy CPU." diff --git a/components/macroscript/languages/emsstrings.it.po b/components/macroscript/languages/emsstrings.it.po index 5b4dd995ba..f628972680 100644 --- a/components/macroscript/languages/emsstrings.it.po +++ b/components/macroscript/languages/emsstrings.it.po @@ -26,6 +26,10 @@ msgstr "Editor di Macro Script" msgid "Scripting not active. Selftest failed." msgstr "Lo scripting non è attivo. L'autotest è fallito." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Lo scripting non è attivo. Non supportato su questa piattaforma o CPU." diff --git a/components/macroscript/languages/emsstrings.lt.po b/components/macroscript/languages/emsstrings.lt.po index f7ca110b99..c2568eff10 100644 --- a/components/macroscript/languages/emsstrings.lt.po +++ b/components/macroscript/languages/emsstrings.lt.po @@ -28,6 +28,10 @@ msgstr "Makrokomandos scenarijaus rengyklė" msgid "Scripting not active. Selftest failed." msgstr "Scenarijaus rengimas nevyksta. Savasis testas nepavyko." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Scenarijaus rengimas nevyksta. Ši platforma ar procesorius nėra palaikomi." diff --git a/components/macroscript/languages/emsstrings.pot b/components/macroscript/languages/emsstrings.pot index 82d2134807..dbd1a0afa1 100644 --- a/components/macroscript/languages/emsstrings.pot +++ b/components/macroscript/languages/emsstrings.pot @@ -17,6 +17,10 @@ msgstr "" msgid "Scripting not active. Selftest failed." msgstr "" +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "" diff --git a/components/macroscript/languages/emsstrings.pt_BR.po b/components/macroscript/languages/emsstrings.pt_BR.po index 0067a47e7c..580418a841 100644 --- a/components/macroscript/languages/emsstrings.pt_BR.po +++ b/components/macroscript/languages/emsstrings.pt_BR.po @@ -27,6 +27,10 @@ msgstr "Editor Macro Script" msgid "Scripting not active. Selftest failed." msgstr "Scripting não ativo. Autoteste falhou." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Scripting não ativo. Não é suportado nesta plataforma ou CPU." diff --git a/components/macroscript/languages/emsstrings.ru.po b/components/macroscript/languages/emsstrings.ru.po index d8057b575e..92462d02f6 100644 --- a/components/macroscript/languages/emsstrings.ru.po +++ b/components/macroscript/languages/emsstrings.ru.po @@ -25,6 +25,10 @@ msgstr "Сценарии редактора" msgid "Scripting not active. Selftest failed." msgstr "Сценарии отключены. Не прошло самотестирование." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Сценарии отключены. Они не поддерживаются на данной платформе." diff --git a/components/macroscript/languages/emsstrings.uk.po b/components/macroscript/languages/emsstrings.uk.po index 687d04e8f7..038dcbf841 100644 --- a/components/macroscript/languages/emsstrings.uk.po +++ b/components/macroscript/languages/emsstrings.uk.po @@ -29,6 +29,10 @@ msgstr "Сценарії редактора" msgid "Scripting not active. Selftest failed." msgstr "Сценарії не активні. Не пройшло самотестування." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Сценарії не активні. Вони не підтримуються на даній платформі або ЦП." diff --git a/components/macroscript/languages/emsstrings.zh_CN.po b/components/macroscript/languages/emsstrings.zh_CN.po index 02bc826e8b..9c68d81a01 100644 --- a/components/macroscript/languages/emsstrings.zh_CN.po +++ b/components/macroscript/languages/emsstrings.zh_CN.po @@ -28,6 +28,10 @@ msgstr "编辑器宏脚本" msgid "Scripting not active. Selftest failed." msgstr "Scripting非激活状态.自检失败." +#: emsstrings.emsnotactiveverbose +msgid "EditorMacroScript failed its self-test and is not active. Some macros may not work." +msgstr "" + #: emsstrings.emsnotsupported msgid "Scripting not active. Not supported on this platform or CPU." msgstr "Scripting非活跃状态.不支持这个平台或者CPU." diff --git a/components/macroscript/registerems.pas b/components/macroscript/registerems.pas index 9576fbec48..76699921eb 100644 --- a/components/macroscript/registerems.pas +++ b/components/macroscript/registerems.pas @@ -43,6 +43,7 @@ begin MessageDlg(EmsSelfTestErrCaption, format(EmsSelfTestFailedLastTime, [LineEnding]), mtError, [mbOK], 0); + MacroListViewerWarningText := EMSNotActiveVerbose; exit; end; @@ -56,6 +57,7 @@ begin mtError, [mbOK], 0); end; if conf.SelfTestFailed >= EMSVersion then begin + MacroListViewerWarningText := EMSNotActiveVerbose; exit; end; @@ -76,6 +78,8 @@ begin MessageDlg(EmsSelfTestErrCaption, format(EmsSelfTestFailed, [LineEnding, SelfTestErrorMsg]), mtError, [mbOK], 0); + + MacroListViewerWarningText := EMSNotActiveVerbose; exit; end; diff --git a/ide/editormacrolistviewer.lfm b/ide/editormacrolistviewer.lfm index 9f6e76fb6b..74475b25b0 100644 --- a/ide/editormacrolistviewer.lfm +++ b/ide/editormacrolistviewer.lfm @@ -10,11 +10,11 @@ object MacroListView: TMacroListView Constraints.MinWidth = 300 OnActivate = FormActivate OnDeactivate = FormActivate - LCLVersion = '1.9.0.0' + LCLVersion = '2.1.0.0' object Panel1: TPanel AnchorSideRight.Control = pnlButtons Left = 6 - Height = 335 + Height = 313 Top = 6 Width = 295 Align = alLeft @@ -23,12 +23,12 @@ object MacroListView: TMacroListView BorderSpacing.Top = 6 BorderSpacing.Right = 6 BevelOuter = bvNone - ClientHeight = 335 + ClientHeight = 313 ClientWidth = 295 TabOrder = 0 object lbMacroView: TListView Left = 0 - Height = 288 + Height = 266 Top = 22 Width = 295 Align = alClient @@ -103,7 +103,7 @@ object MacroListView: TMacroListView object ToolBar2: TToolBar Left = 0 Height = 22 - Top = 313 + Top = 291 Width = 295 Align = alBottom AutoSize = True @@ -116,20 +116,20 @@ object MacroListView: TMacroListView Left = 1 Height = 22 Top = 0 - Width = 54 + Width = 52 Align = alLeft Caption = 'lbMoveTo' Layout = tlCenter ParentColor = False end object tbMoveProject: TToolButton - Left = 55 + Left = 53 Top = 0 Caption = 'tbMoveProject' OnClick = tbMoveProjectClick end object tbMoveIDE: TToolButton - Left = 141 + Left = 139 Top = 0 Caption = 'tbMoveIDE' OnClick = tbMoveIDEClick @@ -155,13 +155,13 @@ object MacroListView: TMacroListView end object pnlButtons: TPanel Left = 307 - Height = 341 + Height = 319 Top = 0 Width = 117 Align = alRight AutoSize = True BevelOuter = bvNone - ClientHeight = 341 + ClientHeight = 319 ClientWidth = 117 Constraints.MinHeight = 250 TabOrder = 1 @@ -212,7 +212,7 @@ object MacroListView: TMacroListView AnchorSideBottom.Control = PanelRepeat Left = 6 Height = 25 - Top = 200 + Top = 178 Width = 105 Anchors = [akLeft, akRight, akBottom] AutoSize = True @@ -232,7 +232,7 @@ object MacroListView: TMacroListView AnchorSideBottom.Control = btnRecordStop Left = 6 Height = 25 - Top = 285 + Top = 263 Width = 105 Anchors = [akLeft, akRight, akBottom] AutoSize = True @@ -253,7 +253,7 @@ object MacroListView: TMacroListView AnchorSideBottom.Side = asrBottom Left = 6 Height = 25 - Top = 316 + Top = 294 Width = 105 Anchors = [akLeft, akRight, akBottom] AutoSize = True @@ -332,7 +332,7 @@ object MacroListView: TMacroListView AnchorSideBottom.Control = btnRecord Left = 6 Height = 54 - Top = 228 + Top = 206 Width = 105 Anchors = [akLeft, akRight, akBottom] AutoSize = True @@ -384,6 +384,49 @@ object MacroListView: TMacroListView end end end + object PanelWarnings: TPanel + Left = 0 + Height = 22 + Top = 319 + Width = 424 + Align = alBottom + AutoSize = True + BevelOuter = bvNone + ClientHeight = 22 + ClientWidth = 424 + TabOrder = 3 + Visible = False + object LabelWarning: TLabel + Left = 0 + Height = 22 + Top = 0 + Width = 401 + Align = alClient + Font.Color = clRed + ParentColor = False + ParentFont = False + WordWrap = True + end + object PnlWarnClose: TPanel + Left = 401 + Height = 22 + Top = 0 + Width = 23 + Align = alRight + AutoSize = True + BevelOuter = bvNone + ClientHeight = 22 + ClientWidth = 23 + TabOrder = 0 + object BtnWarnClose: TSpeedButton + Left = 0 + Height = 22 + Top = 0 + Width = 23 + OnClick = BtnWarnCloseClick + end + end + end object PopupMenu1: TPopupMenu left = 144 top = 72 diff --git a/ide/editormacrolistviewer.pas b/ide/editormacrolistviewer.pas index 05a4e3710a..d67cf2d5c9 100644 --- a/ide/editormacrolistviewer.pas +++ b/ide/editormacrolistviewer.pas @@ -8,7 +8,7 @@ uses Classes, SysUtils, // LCL LCLType, Forms, Controls, Dialogs, StdCtrls, ButtonPanel, ComCtrls, ExtCtrls, - Spin, Menus, + Spin, Menus, Buttons, // LazUtils LazFileUtils, Laz2_XMLCfg, LazUTF8, LazLoggerBase, // SynEdit @@ -181,18 +181,22 @@ type ButtonPanel1: TButtonPanel; chkRepeat: TCheckBox; GroupBox1: TGroupBox; + LabelWarning: TLabel; lbMoveTo: TLabel; lbMacroView: TListView; mnExport: TMenuItem; mnImport: TMenuItem; OpenDialog1: TOpenDialog; Panel1: TPanel; + PnlWarnClose: TPanel; + PanelWarnings: TPanel; PanelRepeat: TPanel; pnlButtons: TPanel; PopupMenu1: TPopupMenu; RenameButton: TPanelBitBtn; edRepeat: TSpinEdit; SaveDialog1: TSaveDialog; + BtnWarnClose: TSpeedButton; ToolBar1: TToolBar; tbRecorded: TToolButton; tbProject: TToolButton; @@ -210,6 +214,7 @@ type procedure btnRenameClick(Sender: TObject); procedure btnSelectClick(Sender: TObject); procedure btnSetKeysClick(Sender: TObject); + procedure BtnWarnCloseClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure HelpButtonClick(Sender: TObject); procedure lbMacroViewSelectItem(Sender: TObject; {%H-}Item: TListItem; {%H-}Selected: Boolean); @@ -282,6 +287,17 @@ begin if MacroListView = nil then MacroListView := TMacroListView.Create(Application); Result := MacroListView; + + MacroListView.LabelWarning.Caption := MacroListViewerWarningText; + MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> ''; +end; + +procedure DoMacroListViewerWarningChanged(ASender: TObject); +begin + if MacroListView <> nil then begin + MacroListView.LabelWarning.Caption := MacroListViewerWarningText; + MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> ''; + end; end; procedure ShowMacroListViewer; @@ -1199,6 +1215,11 @@ begin if OnKeyMapReloaded <> nil then OnKeyMapReloaded(); end; +procedure TMacroListView.BtnWarnCloseClick(Sender: TObject); +begin + PanelWarnings.Visible := False; +end; + procedure TMacroListView.DoMacroStateChanged(Sender: TObject); begin if OnEditorMacroStateChange <> nil then @@ -1482,6 +1503,9 @@ begin FImageErr := IDEImages.LoadImage('state_error'); FIsPlaying := False; + BtnWarnClose.Images := IDEImages.Images_16; + BtnWarnClose.ImageIndex := IDEImages.LoadImage('menu_close'); + UpdateDisplay; end; @@ -1632,6 +1656,8 @@ initialization EditorMacroListGlob := TEditorMacroList.Create; CurrentEditorMacroList := EditorMacroListRec; + MacroListViewerWarningChanged := @DoMacroListViewerWarningChanged; + finalization CurrentEditorMacroList := nil; FreeAndNil(EditorMacroListRec);