@@ -40,10 +40,11 @@ btnSaveGroff: TButton; btnLoadGroff: TButton; btnBuild: TButton; btnDownloadGroffWindows: TButton; btnSaveSettings: TButton; + chkUpdateCheckOnStart: TCheckBox; chkLogFile: TCheckBox; chkAutoSaveBuildSettings: TCheckBox; chkPdfMark: TCheckBox; chkRefer: TCheckBox; chkChem: TCheckBox; @@ -112,10 +113,11 @@ var unsavedChanges: Boolean; {$IFDEF WINDOWS} var latestGroffWindowsUrl: String; {$ENDIF} var storeBuildSettings: Boolean; + var updateCheck: Boolean; public end; var @@ -169,10 +171,13 @@ // Restore the settings iniStorage.Restore; storeBuildSettings := iniStorage.ReadBoolean('AutoSaveBuildSettings', False); chkAutoSaveBuildSettings.Checked := storeBuildSettings; + updateCheck := iniStorage.ReadBoolean('UpdateCheckOnStart', False); + chkUpdateCheckOnStart.Checked := updateCheck; + if storeBuildSettings then begin chkLogFile.Checked := iniStorage.ReadBoolean('BuildLogFile', False); cmbMacro.Text := iniStorage.ReadString('BuildChosenMacro', '[ select ]'); chkChem.Checked := iniStorage.ReadBoolean('BuildUseChem', False); @@ -194,53 +199,68 @@ edtGroffStudioInstalledVersion.Text := FileVerInfo.VersionStrings.Values['FileVersion']; lblAboutProductName.Caption := FileVerInfo.VersionStrings.Values['ProductName'] + ' ' + FileVerInfo.VersionStrings.Values['FileVersion']; MainStatusBar.Panels[2].Text := ''; {$IFDEF WINDOWS} - OnlineVersionsFile := TFPCustomHTTPClient.SimpleGet('https://groff.tuxproject.de/updates/versions.txt'); - reGroffVersion := TRegExpr.Create('groff-win ([\d\.]+) (.*)$'); - reGroffVersion.ModifierM := True; - if reGroffVersion.Exec(OnlineVersionsFile) then - begin - edtOnlineGroffVersionWindows.Text := reGroffVersion.Match[1]; - latestGroffWindowsUrl := reGroffVersion.Match[2]; - end else begin - edtOnlineGroffVersionWindows.Text := 'error'; - btnDownloadGroffWindows.Enabled := False; - end; - - reGroffStudioVersion := TRegExpr.Create('studio-win ([\d\.]+) (.*)$'); - reGroffStudioVersion.ModifierM := True; - if reGroffStudioVersion.Exec(OnlineVersionsFile) then - begin - // Compare the two versions - ours and the online one: - GroffHelpers.VerStrCompare(reGroffStudioVersion.Match[1], FileVerInfo.VersionStrings.Values['FileVersion'], HasVersionUpdate); - if HasVersionUpdate > 0 then - MainStatusBar.Panels[2].Text := 'update ' + reGroffStudioVersion.Match[1] + ' available'; + if updateCheck then + begin + OnlineVersionsFile := TFPCustomHTTPClient.SimpleGet('https://groff.tuxproject.de/updates/versions.txt'); + + // 1. groff update check + reGroffVersion := TRegExpr.Create('groff-win ([\d\.]+) (.*)$'); + reGroffVersion.ModifierM := True; + if reGroffVersion.Exec(OnlineVersionsFile) then + begin + edtOnlineGroffVersionWindows.Text := reGroffVersion.Match[1]; + latestGroffWindowsUrl := reGroffVersion.Match[2]; + end else begin + edtOnlineGroffVersionWindows.Text := 'error'; + btnDownloadGroffWindows.Enabled := False; + end; + + // 2. groffstudio update check + reGroffStudioVersion := TRegExpr.Create('studio-win ([\d\.]+) (.*)$'); + reGroffStudioVersion.ModifierM := True; + if reGroffStudioVersion.Exec(OnlineVersionsFile) then + begin + // Compare the two versions - ours and the online one: + GroffHelpers.VerStrCompare(reGroffStudioVersion.Match[1], FileVerInfo.VersionStrings.Values['FileVersion'], HasVersionUpdate); + if HasVersionUpdate > 0 then + MainStatusBar.Panels[2].Text := 'update ' + reGroffStudioVersion.Match[1] + ' available'; + end; + end else begin + edtOnlineGroffVersionWindows.Text := 'n/a'; + btnDownloadGroffWindows.Enabled := False; end; {$ELSE} // Non-Windows platforms won't need some of that. {$IFDEF DARWIN} // What's the latest available version? try - HTTPClient := TFPHTTPClient.Create(Nil); - HTTPClient.OnGetSocketHandler := @GetSocketHandler; - OnlineVersionsFile := HTTPClient.SimpleGet('https://groff.tuxproject.de/updates/versions.txt'); - - reGroffStudioVersion := TRegExpr.Create('studio-macos ([\d\.]+) (.*)$'); - reGroffStudioVersion.ModifierM := True; - if reGroffStudioVersion.Exec(OnlineVersionsFile) then + if updateCheck then begin - // Compare the two versions - ours and the online one: - GroffHelpers.VerStrCompare(reGroffStudioVersion.Match[1], FileVerInfo.VersionStrings.Values['FileVersion'], HasVersionUpdate); - if HasVersionUpdate > 0 then - MainStatusBar.Panels[2].Text := 'update ' + reGroffStudioVersion.Match[1] + ' available' - else - MainStatusBar.Panels[2].Text := IntToStr(HasVersionUpdate); + HTTPClient := TFPHTTPClient.Create(Nil); + HTTPClient.OnGetSocketHandler := @GetSocketHandler; + OnlineVersionsFile := HTTPClient.SimpleGet('https://groff.tuxproject.de/updates/versions.txt'); + + reGroffStudioVersion := TRegExpr.Create('studio-macos ([\d\.]+) (.*)$'); + reGroffStudioVersion.ModifierM := True; + if reGroffStudioVersion.Exec(OnlineVersionsFile) then + begin + // Compare the two versions - ours and the online one: + GroffHelpers.VerStrCompare(reGroffStudioVersion.Match[1], FileVerInfo.VersionStrings.Values['FileVersion'], HasVersionUpdate); + if HasVersionUpdate > 0 then + MainStatusBar.Panels[2].Text := 'update ' + reGroffStudioVersion.Match[1] + ' available' + else + MainStatusBar.Panels[2].Text := IntToStr(HasVersionUpdate); + end; + end else begin + edtOnlineGroffVersionWindows.Text := 'n/a'; + btnDownloadGroffWindows.Enabled := False; end; finally - HTTPClient.Free; + if updateCheck then HTTPClient.Free; end; {$ENDIF} edtOnlineGroffVersionWindows.Text := 'n/a'; btnDownloadGroffWindows.Enabled := False; {$ENDIF} @@ -418,10 +438,11 @@ iniStorage.WriteBoolean('BuildToPostscript', rdPs.Checked); iniStorage.WriteBoolean('BuildToPDF', rdPDF.Checked); // Store the IDE settings: iniStorage.WriteBoolean('AutoSaveBuildSettings', chkAutoSaveBuildSettings.Checked); + iniStorage.WriteBoolean('AutoUpdateCheck', chkUpdateCheckOnStart.Checked); iniStorage.Save; end; procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);