FormMain.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. unit FormMain;
  2. interface
  3. uses
  4. {$IFDEF MACOS}
  5. MacOpenFileDelegate, Macapi.AppKit, Macapi.ObjectiveC, Macapi.Foundation,
  6. Macapi.Helpers, FMX.Platform.Mac,
  7. {$ELSE}
  8. FMXTrayIcon, FMX.Platform.Win, Winapi.Windows,
  9. {$ENDIF}
  10. SaveDialogsEnhanced,
  11. System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  12. FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.IOUtils,
  13. FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, System.Actions,
  14. FMX.ActnList, FMX.Menus;
  15. type
  16. TfmMain = class(TForm)
  17. StyleBookBlack: TStyleBook;
  18. StyleBookWhite: TStyleBook;
  19. actsMain: TActionList;
  20. actFileNew: TAction;
  21. actFileOpen: TAction;
  22. OpenDialog: TOpenDialog;
  23. actFileSave: TAction;
  24. actFileSaveAs: TAction;
  25. actFileClose: TAction;
  26. actViewShowLog: TAction;
  27. actViewDarkStyle: TAction;
  28. actViewFont: TAction;
  29. actHelpHelp: TAction;
  30. actHelpAbout: TAction;
  31. actEditMoveUp: TAction;
  32. actEditMoveDown: TAction;
  33. mmMain: TMainMenu;
  34. miFile: TMenuItem;
  35. miEdit: TMenuItem;
  36. miNone: TMenuItem;
  37. miFileNew: TMenuItem;
  38. miFileOpen: TMenuItem;
  39. miSystem: TMenuItem;
  40. miHelpAbout: TMenuItem;
  41. miOption: TMenuItem;
  42. miSystemExit: TMenuItem;
  43. miSystemUpdate: TMenuItem;
  44. miFileSave: TMenuItem;
  45. miFileSaveAs: TMenuItem;
  46. miEditMoveUp: TMenuItem;
  47. miEditMoveDown: TMenuItem;
  48. miView: TMenuItem;
  49. miViewShowLog: TMenuItem;
  50. miViewDarkStyle: TMenuItem;
  51. miFileClose: TMenuItem;
  52. miFileOpenRecent: TMenuItem;
  53. mi1: TMenuItem;
  54. mi2: TMenuItem;
  55. actFile: TAction;
  56. actViewLang: TAction;
  57. actEdit: TAction;
  58. miViewLang: TMenuItem;
  59. actView: TAction;
  60. actWindow: TAction;
  61. actHelp: TAction;
  62. actSystemUpdate: TAction;
  63. actFileOpenRecent: TAction;
  64. actWindowItems: TAction;
  65. actWindowShowAll: TAction;
  66. actFileClearRecent: TAction;
  67. procedure FormCreate(Sender: TObject);
  68. procedure FormClose(Sender: TObject; var Action: TCloseAction);
  69. procedure FormDestroy(Sender: TObject);
  70. procedure FormActivate(Sender: TObject);
  71. procedure actFileNewExecute(Sender: TObject);
  72. procedure actFileOpenExecute(Sender: TObject);
  73. procedure actFileSaveExecute(Sender: TObject);
  74. procedure actFileSaveAsExecute(Sender: TObject);
  75. procedure actFileCloseExecute(Sender: TObject);
  76. procedure actViewShowLogExecute(Sender: TObject);
  77. procedure actViewDarkStyleExecute(Sender: TObject);
  78. procedure actViewFontExecute(Sender: TObject);
  79. procedure actHelpAboutExecute(Sender: TObject);
  80. procedure actEditMoveUpExecute(Sender: TObject);
  81. procedure actEditMoveDownExecute(Sender: TObject);
  82. procedure miSystemExitClick(Sender: TObject);
  83. procedure actViewLangExecute(Sender: TObject);
  84. procedure actNoneExecute(Sender: TObject);
  85. procedure actWindowShowAllExecute(Sender: TObject);
  86. procedure actFileClearRecentExecute(Sender: TObject);
  87. private
  88. FSaveDialog: TEnhancedSaveDialog;
  89. {$IFDEF MSWINDOWS}
  90. FTrayIcon: TTrayIcon;
  91. procedure OnRunOnlyOnce(ASender: TObject; AParams: TArray<String>);
  92. {$ELSE}
  93. procedure InitMacOsMenu;
  94. {$ENDIF}
  95. public
  96. {$IFDEF MACOS}
  97. procedure InitMacOsRecentFile;
  98. procedure RecentFileClick(Sender: TObject);
  99. {$ENDIF}
  100. procedure SetLang;
  101. end;
  102. var
  103. fmMain: TfmMain;
  104. implementation
  105. {$R *.fmx}
  106. uses JsonDocument, pub, Logger, FormLogger, FormAbout, JSONTreeView;
  107. {$IFDEF MSWINDOWS}
  108. {-------------------------------------------------------------------------------
  109. 名称: TfmMain.OnRunOnlyOnce
  110. 说明: 程序重复运行事件
  111. 参数: ASender
  112. AParams
  113. -------------------------------------------------------------------------------}
  114. procedure TfmMain.OnRunOnlyOnce(ASender: TObject; AParams: TArray<String>);
  115. begin
  116. if Length(AParams) > 1 then
  117. begin
  118. for var item in g_pub.DocumentWindowList do
  119. begin
  120. if item.Doc.FileName = AParams[1] then
  121. begin
  122. item.Show;
  123. item.Activate;
  124. item.BringToFront;
  125. Exit;
  126. end;
  127. end;
  128. var
  129. lastForm := g_pub.DocumentWindowList.ActiveWindow;
  130. if lastForm = nil then
  131. lastForm := g_pub.DocumentWindowList.Last;
  132. with TDocumentWindow.Create(nil) do
  133. begin
  134. Show;
  135. OpenFile(AParams[1]);
  136. Left := lastForm.Left + 20;
  137. Top := lastForm.Top + 28;
  138. end;
  139. end
  140. else
  141. begin
  142. var
  143. lastForm := g_pub.DocumentWindowList.Last;
  144. with TDocumentWindow.Create(nil) do
  145. begin
  146. Show;
  147. NewFile;
  148. Left := lastForm.Left + 20;
  149. Top := lastForm.Top + 28;
  150. end;
  151. end;
  152. end;
  153. {$ELSE}
  154. {-------------------------------------------------------------------------------
  155. 名称: OpenFileDelegate
  156. 说明: 处理文件关联打开
  157. 参数: AFilename
  158. -------------------------------------------------------------------------------}
  159. procedure OpenFileDelegate(const AFilename: string);
  160. var
  161. LDocForm: TDocumentWindow;
  162. begin
  163. if FileExists(AFilename) then
  164. begin
  165. if (g_pub.DocumentWindowList.Count = 1) and (g_pub.DocumentWindowList.First.Doc.FileName = '') then
  166. begin
  167. g_pub.DocumentWindowList.Last.OpenFile(AFilename);
  168. end
  169. else
  170. begin
  171. for var item in g_pub.DocumentWindowList do
  172. begin
  173. if item.Doc.FileName = AFilename then
  174. begin
  175. item.Activate;
  176. item.BringToFront;
  177. Exit;
  178. end;
  179. end;
  180. var
  181. lastForm := g_pub.DocumentWindowList.Last;
  182. LDocForm := TDocumentWindow.Create(nil);
  183. LDocForm.Show;
  184. LDocForm.OpenFile(AFilename);
  185. LDocForm.Left := lastForm.Left + 20;
  186. LDocForm.Top := lastForm.Top + 28;
  187. end;
  188. end
  189. else
  190. begin
  191. g_Logger.Error('file does not exist - ' + AFilename);
  192. end;
  193. end;
  194. {-------------------------------------------------------------------------------
  195. 名称: TfmMain.InitMacOsMenu
  196. 说明: 初始化MacOS菜单
  197. -------------------------------------------------------------------------------}
  198. procedure TfmMain.InitMacOsMenu;
  199. var
  200. NSApp: NSApplication;
  201. LMainMenu: NSMenu;
  202. begin
  203. NSApp := TNSApplication.Wrap(TNSApplication.OCClass.sharedApplication);
  204. LMainMenu := NSApp.MainMenu;
  205. LMainMenu.itemAtIndex(0).setHidden(True);
  206. actFileNew.ShortCut := scCommand + Ord('N');
  207. actFileOpen.ShortCut := scCommand + Ord('O');
  208. actFileClose.ShortCut := scCommand + Ord('W');
  209. actFileSave.ShortCut := scCommand + Ord('S');
  210. end;
  211. {-------------------------------------------------------------------------------
  212. 名称: TfmMain.InitMacOsRecentFile
  213. 说明: 初始化Mac下的历史文件菜单
  214. -------------------------------------------------------------------------------}
  215. procedure TfmMain.InitMacOsRecentFile;
  216. var
  217. miTmp: TMenuItem;
  218. begin
  219. miFileOpenRecent.Clear;
  220. for var item in g_pub.Config['recent'] do
  221. begin
  222. miTmp := TMenuItem.Create(fmMain.miFileOpenRecent);
  223. miTmp.Text := item;
  224. miTmp.OnClick := RecentFileClick;
  225. miFileOpenRecent.AddObject(miTmp);
  226. miTmp.Enabled := FileExists(miTmp.Text);
  227. end;
  228. if miFileOpenRecent.ItemsCount > 0 then
  229. begin
  230. miTmp := TMenuItem.Create(miFileOpenRecent);
  231. miTmp.Text := '-';
  232. miFileOpenRecent.AddObject(miTmp);
  233. miTmp := TMenuItem.Create(miFileOpenRecent);
  234. miTmp.Action := actFileClearRecent;
  235. miFileOpenRecent.AddObject(miTmp);
  236. end
  237. else
  238. begin
  239. miTmp := TMenuItem.Create(miFileOpenRecent);
  240. miTmp.Text := 'No file';
  241. miTmp.Enabled := False;
  242. miFileOpenRecent.AddObject(miTmp);
  243. end;
  244. end;
  245. procedure TfmMain.RecentFileClick(Sender: TObject);
  246. var
  247. LFilename: string;
  248. LDocWin: TDocumentWindow;
  249. begin
  250. LFilename := TMenuItem(Sender).Text;
  251. LDocWin := g_pub.DocumentWindowList.GetWindowByFilename(LFilename);
  252. if LDocWin <> nil then
  253. begin
  254. LDocWin.Show;
  255. end
  256. else
  257. begin
  258. LDocWin := TDocumentWindow.Create(nil);
  259. LDocWin.Show;
  260. LDocWin.OpenFile(LFilename);
  261. end;
  262. end;
  263. {$ENDIF}
  264. {-------------------------------------------------------------------------------
  265. 名称: TfmMain.miSystemExitClick
  266. 说明: 退出
  267. -------------------------------------------------------------------------------}
  268. procedure TfmMain.miSystemExitClick(Sender: TObject);
  269. begin
  270. Close;
  271. end;
  272. procedure TfmMain.FormCreate(Sender: TObject);
  273. var
  274. LDocForm: TDocumentWindow;
  275. begin
  276. Left := -102400;
  277. fmLogger := TfmLogger.Create(nil);
  278. {$IFDEF MACOS} // 初始化mac下的语言选择菜单
  279. miViewLang.Clear;
  280. for var item in g_pub.Languages do
  281. begin
  282. var
  283. mi := TMenuItem.Create(miViewLang);
  284. mi.Text := item['caption'].ToStr('None');
  285. mi.RadioItem := True;
  286. mi.GroupIndex := 10;
  287. mi.OnClick := actViewLangExecute;
  288. miViewLang.AddObject(mi);
  289. end;
  290. {$ENDIF}
  291. FSaveDialog := TEnhancedSaveDialog.Create(self);
  292. FSaveDialog.Filter := '缩进格式|*.json|缩进格式、转义非ASCII字符|*.json|紧凑格式|*.json|紧凑格式、转义非ASCII字符|*.json';
  293. SetLang;
  294. LDocForm := TDocumentWindow.Create(nil);
  295. LDocForm.Show;
  296. LDocForm.NewFile;
  297. {$IFDEF MSWINDOWS}
  298. FTrayIcon := TTrayIcon.Create(self);
  299. FTrayIcon.RunOnlyOnce := True;
  300. FTrayIcon.OnRunOnlyOnce := OnRunOnlyOnce;
  301. if ParamCount > 0 then
  302. begin
  303. if FileExists(ParamStr(1)) then
  304. begin
  305. LDocForm.OpenFile(ParamStr(1));
  306. end
  307. else
  308. begin
  309. g_Logger.Error('File does not exist - ' + ParamStr(1));
  310. end;
  311. end;
  312. {$ELSE}
  313. width := 1;
  314. height := 1;
  315. InitMacOsMenu;
  316. InitMacOsRecentFile;
  317. InstallApplicationOpenFileDelegate(OpenFileDelegate);
  318. {$ENDIF}
  319. end;
  320. procedure TfmMain.FormDestroy(Sender: TObject);
  321. begin
  322. fmLogger.Free;
  323. end;
  324. {-------------------------------------------------------------------------------
  325. 名称: TfmMain.FormActivate
  326. 说明: 窗口激活
  327. 参数: Sender
  328. -------------------------------------------------------------------------------}
  329. procedure TfmMain.FormActivate(Sender: TObject);
  330. begin
  331. {$IFDEF MSWINDOWS}
  332. g_pub.DocumentWindowList.ShowAll;
  333. {$ENDIF}
  334. end;
  335. {-------------------------------------------------------------------------------
  336. 名称: TfmMain.FormClose
  337. 说明: 窗口关闭
  338. 参数: Sender
  339. Action
  340. -------------------------------------------------------------------------------}
  341. procedure TfmMain.FormClose(Sender: TObject; var Action: TCloseAction);
  342. begin
  343. {$IFDEF MSWINDOWS}
  344. for var item in g_pub.DocumentWindowList do
  345. begin
  346. item.OnClose := nil;
  347. item.Free;
  348. end;
  349. {$ENDIF}
  350. end;
  351. {-------------------------------------------------------------------------------
  352. 名称: TfmMain.actFileClearRecentExecute
  353. 说明: 清除历史文件
  354. -------------------------------------------------------------------------------}
  355. procedure TfmMain.actFileClearRecentExecute(Sender: TObject);
  356. begin
  357. g_pub.Config['recent'] := nil;
  358. {$IFDEF MACOS}
  359. InitMacOsRecentFile;
  360. {$ENDIF}
  361. end;
  362. {-------------------------------------------------------------------------------
  363. 名称: TfmMain.actFileCloseExecute
  364. 说明: 关闭文件
  365. 参数: Sender
  366. -------------------------------------------------------------------------------}
  367. procedure TfmMain.actFileCloseExecute(Sender: TObject);
  368. begin
  369. if g_pub.DocumentWindowList.ActiveWindow <> nil then
  370. g_pub.DocumentWindowList.ActiveWindow.Close;
  371. end;
  372. {-------------------------------------------------------------------------------
  373. 名称: TfmMain.actNoneExecute
  374. 说明: 空函数,为了使Action生效
  375. -------------------------------------------------------------------------------}
  376. procedure TfmMain.actNoneExecute(Sender: TObject);
  377. begin
  378. //
  379. end;
  380. {-------------------------------------------------------------------------------
  381. 名称: TfmMain.actFileNewExecute
  382. 说明: 新建文件
  383. 参数: Sender
  384. -------------------------------------------------------------------------------}
  385. procedure TfmMain.actFileNewExecute(Sender: TObject);
  386. var
  387. LDocWin: TDocumentWindow;
  388. begin
  389. LDocWin := TDocumentWindow.Create(nil);
  390. LDocWin.Show;
  391. LDocWin.NewFile;
  392. end;
  393. {-------------------------------------------------------------------------------
  394. 名称: TfmMain.actFileOpenExecute
  395. 说明: 打开文件
  396. 参数: Sender
  397. -------------------------------------------------------------------------------}
  398. procedure TfmMain.actFileOpenExecute(Sender: TObject);
  399. var
  400. LDocWin: TDocumentWindow;
  401. begin
  402. if not OpenDialog.Execute then
  403. Exit;
  404. LDocWin := g_pub.DocumentWindowList.GetWindowByFilename(OpenDialog.FileName);
  405. if LDocWin <> nil then
  406. begin
  407. LDocWin.Show;
  408. end
  409. else
  410. begin
  411. LDocWin := TDocumentWindow.Create(nil);
  412. LDocWin.Show;
  413. LDocWin.OpenFile(OpenDialog.FileName);
  414. end;
  415. end;
  416. {-------------------------------------------------------------------------------
  417. 名称: TfmMain.actFileSaveExecute
  418. 说明: 保存文件
  419. 参数: Sender
  420. -------------------------------------------------------------------------------}
  421. procedure TfmMain.actFileSaveExecute(Sender: TObject);
  422. begin
  423. if not g_pub.DocumentWindowList.HasActiveWindow then
  424. Exit;
  425. if g_pub.DocumentWindowList.ActiveWindow.Doc.FileName <> '' then
  426. begin
  427. g_pub.DocumentWindowList.ActiveWindow.Doc.Save(g_pub.DocumentWindowList.ActiveWindow.Doc.FileName, g_pub.Config['editor.indent'].ToInt(4));
  428. g_pub.DocumentWindowList.ActiveWindow.ShowInfo('文件保存成功!');
  429. end
  430. else
  431. begin
  432. actFileSaveAsExecute(nil);
  433. end;
  434. end;
  435. {-------------------------------------------------------------------------------
  436. 名称: TfmMain.actFileSaveAsExecute
  437. 说明: 另存为
  438. 参数: Sender
  439. -------------------------------------------------------------------------------}
  440. procedure TfmMain.actFileSaveAsExecute(Sender: TObject);
  441. begin
  442. if g_pub.DocumentWindowList.LastActive.Doc.FileName = '' then
  443. begin
  444. FSaveDialog.FileName := c_untitled_filename;
  445. end
  446. else
  447. begin
  448. FSaveDialog.InitialDir := ExtractFileDir(g_pub.DocumentWindowList.LastActive.Doc.FileName);
  449. FSaveDialog.FileName := ExtractFileName(g_pub.DocumentWindowList.LastActive.Doc.FileName);
  450. end;
  451. if FSaveDialog.Execute then
  452. begin
  453. case FSaveDialog.FilterIndex of
  454. 1:
  455. g_pub.DocumentWindowList.LastActive.Doc.Save(FSaveDialog.FileName, g_pub.Config['editor.indent'].ToInt(4), True, False, False);
  456. 2:
  457. g_pub.DocumentWindowList.LastActive.Doc.Save(FSaveDialog.FileName, g_pub.Config['editor.indent'].ToInt(4), True, True, False);
  458. 3:
  459. g_pub.DocumentWindowList.LastActive.Doc.Save(FSaveDialog.FileName, -1, True, False, False);
  460. 4:
  461. g_pub.DocumentWindowList.LastActive.Doc.Save(FSaveDialog.FileName, -1, True, True, False);
  462. end;
  463. g_pub.DocumentWindowList.LastActive.ShowInfo('文件另存成功!');
  464. end;
  465. end;
  466. {-------------------------------------------------------------------------------
  467. 名称: TfmMain.actEditMoveDownExecute
  468. 说明: 上移
  469. 参数: Sender
  470. -------------------------------------------------------------------------------}
  471. procedure TfmMain.actEditMoveDownExecute(Sender: TObject);
  472. var
  473. LItem: TJSONTreeViewItem;
  474. LDocWin: TDocumentWindow;
  475. begin
  476. if not g_pub.DocumentWindowList.HasActiveWindow then
  477. Exit;
  478. LDocWin := g_pub.DocumentWindowList.ActiveWindow;
  479. LItem := TJSONTreeViewItem(LDocWin.tvJson.Selected);
  480. if LItem = nil then
  481. Exit;
  482. if (LItem.ParentItem = nil) then
  483. Exit;
  484. if (LItem.Index >= LItem.ParentItem.Count - 1) then
  485. Exit;
  486. LItem.TreeView.Selected := nil;
  487. TJSONTreeViewItem(LItem.ParentItem).MoveItem(LItem.Index, LItem.Index + 1, True);
  488. LItem.Select;
  489. end;
  490. {-------------------------------------------------------------------------------
  491. 名称: TfmMain.actEditMoveUpExecute
  492. 说明: 下移
  493. 参数: Sender
  494. -------------------------------------------------------------------------------}
  495. procedure TfmMain.actEditMoveUpExecute(Sender: TObject);
  496. var
  497. LItem: TJSONTreeViewItem;
  498. LDocWin: TDocumentWindow;
  499. begin
  500. if not g_pub.DocumentWindowList.HasActiveWindow then
  501. Exit;
  502. LDocWin := g_pub.DocumentWindowList.ActiveWindow;
  503. LItem := TJSONTreeViewItem(LDocWin.tvJson.Selected);
  504. if LItem = nil then
  505. Exit;
  506. if (LItem.ParentItem = nil) or (LItem.Index <= 0) then
  507. Exit;
  508. if (LItem.Index = 0) then
  509. Exit;
  510. LItem.TreeView.Selected := nil;
  511. TJSONTreeViewItem(LItem.ParentItem).MoveItem(LItem.Index, LItem.Index - 1, True);
  512. LItem.Select;
  513. end;
  514. {-------------------------------------------------------------------------------
  515. 名称: TfmMain.actViewDarkStyleExecute
  516. 说明: 设置暗黑风格
  517. 参数: Sender
  518. -------------------------------------------------------------------------------}
  519. procedure TfmMain.actViewDarkStyleExecute(Sender: TObject);
  520. begin
  521. g_pub.IsDarkStyle := not g_pub.IsDarkStyle;
  522. actViewDarkStyle.Checked := g_pub.IsDarkStyle;
  523. end;
  524. {-------------------------------------------------------------------------------
  525. 名称: TfmMain.actViewFontExecute
  526. 说明: 设置字体
  527. -------------------------------------------------------------------------------}
  528. procedure TfmMain.actViewFontExecute(Sender: TObject);
  529. //var
  530. // LDialog: TFontDialog;
  531. begin
  532. {LDialog := TFontDialog.Create(nil);
  533. try
  534. LDialog.StyleBook := StyleBook;
  535. LDialog.rctTitleBar.Fill.Color := rctTitleBar.Fill.Color; // 标题栏背景
  536. LDialog.pathCloseBtn.Fill.Color := pathCloseBtn.Fill.Color;
  537. if LDialog.ShowModal(mmoEdit.TextSettings) = mrOK then
  538. begin
  539. g_pub.Config[ActiveControl.Name + '.TextSettings'].LoadFromObject(mmoEdit.TextSettings);
  540. g_pub.SaveConfig;
  541. end;
  542. finally
  543. FreeAndNil(LDialog);
  544. end;}
  545. end;
  546. procedure TfmMain.actViewLangExecute(Sender: TObject);
  547. begin
  548. if Sender is TMenuItem then
  549. begin
  550. g_pub.LangIndex := TMenuItem(Sender).Index;
  551. SetLang;
  552. end;
  553. end;
  554. {-------------------------------------------------------------------------------
  555. 名称: TfmMain.actViewShowLogExecute
  556. 说明: 显示日志
  557. 参数: Sender
  558. -------------------------------------------------------------------------------}
  559. procedure TfmMain.actViewShowLogExecute(Sender: TObject);
  560. begin
  561. fmLogger.Show;
  562. end;
  563. procedure TfmMain.actWindowShowAllExecute(Sender: TObject);
  564. var
  565. LOldOnActivate: TNotifyEvent;
  566. begin
  567. for var item in g_pub.DocumentWindowList do
  568. begin
  569. LOldOnActivate := item.OnActivate;
  570. item.OnActivate := nil;
  571. item.Show;
  572. item.OnActivate := LOldOnActivate;
  573. end;
  574. end;
  575. {-------------------------------------------------------------------------------
  576. 名称: TfmMain.actHelpAboutExecute
  577. 说明: 关于...
  578. 参数: Sender
  579. -------------------------------------------------------------------------------}
  580. procedure TfmMain.actHelpAboutExecute(Sender: TObject);
  581. begin
  582. TfmAbout.Create(nil).Show;
  583. end;
  584. {-------------------------------------------------------------------------------
  585. 名称: TfmMain.SetLang
  586. 说明: 设置语言
  587. -------------------------------------------------------------------------------}
  588. procedure TfmMain.SetLang;
  589. var
  590. actItem: TAction;
  591. strTmp: string;
  592. begin
  593. for var item in actsMain do
  594. begin
  595. actItem := TAction(item);
  596. strTmp := g_pub.LangStr(actItem.Name);
  597. if strTmp <> '' then
  598. begin
  599. actItem.Text := g_pub.LangStr(actItem.Name);
  600. end;
  601. end;
  602. {$IFDEF MACOS}
  603. miViewLang.Items[g_pub.LangIndex].IsChecked := True;
  604. miHelpAbout.Text := actHelpAbout.Text;
  605. {$ENDIF}
  606. for var item in g_pub.DocumentWindowList do
  607. begin
  608. item.SetLang;
  609. end;
  610. end;
  611. initialization
  612. end.