2424
2525#include " AutoUpdater.h"
2626#include " CoreServices.h"
27+ #include " MainWindow.h"
2728#ifdef _WIN32
2829#include < windows.h>
2930#include < shellapi.h>
3233// ==============================================================================
3334LatestVersionCheckerAndUpdater::LatestVersionCheckerAndUpdater ()
3435 : Thread (" VersionChecker" )
36+ , mainWindow(nullptr )
3537{
3638}
3739
@@ -41,11 +43,12 @@ LatestVersionCheckerAndUpdater::~LatestVersionCheckerAndUpdater()
4143 clearSingletonInstance ();
4244}
4345
44- void LatestVersionCheckerAndUpdater::checkForNewVersion (bool background)
46+ void LatestVersionCheckerAndUpdater::checkForNewVersion (bool background, MainWindow* mw )
4547{
4648 if (! isThreadRunning ())
4749 {
4850 backgroundCheck = background;
51+ mainWindow = mw;
4952 startThread (3 );
5053 }
5154}
@@ -179,7 +182,7 @@ void LatestVersionCheckerAndUpdater::run()
179182class UpdateDialog : public Component
180183{
181184public:
182- UpdateDialog (const String& newVersion, const String& releaseNotes)
185+ UpdateDialog (const String& newVersion, const String& releaseNotes, bool automaticVerCheck )
183186 {
184187 titleLabel.setText (" Open Ephys GUI version " + newVersion, dontSendNotification);
185188 titleLabel.setFont (Font (" Fira Sans" , " SemiBold" , 18 .0f ));
@@ -203,11 +206,13 @@ class UpdateDialog : public Component
203206 addAndMakeVisible (cancelButton);
204207 cancelButton.onClick = [this ]
205208 {
206- // ProjucerApplication::getApp().setAutomaticVersionCheckingEnabled (! dontAskAgainButton.getToggleState());
207- exitModalStateWithResult (-1 );
209+ if (dontAskAgainButton.getToggleState ())
210+ exitModalStateWithResult (-1 );
211+ else
212+ exitModalStateWithResult (0 );
208213 };
209214
210- dontAskAgainButton.setToggleState (false , dontSendNotification);
215+ dontAskAgainButton.setToggleState (!automaticVerCheck , dontSendNotification);
211216 addAndMakeVisible (dontAskAgainButton);
212217
213218#if JUCE_MAC
@@ -251,14 +256,15 @@ class UpdateDialog : public Component
251256 }
252257
253258 static std::unique_ptr<DialogWindow> launchDialog (const String& newVersionString,
254- const String& releaseNotes)
259+ const String& releaseNotes,
260+ bool automaticVerCheck)
255261 {
256262 DialogWindow::LaunchOptions options;
257263
258264 options.dialogTitle = " Download Open Ephys GUI version " + newVersionString + " ?" ;
259265 options.resizable = false ;
260266
261- auto * content = new UpdateDialog (newVersionString, releaseNotes);
267+ auto * content = new UpdateDialog (newVersionString, releaseNotes, automaticVerCheck );
262268 options.content .set (content, true );
263269
264270 std::unique_ptr<DialogWindow> dialog (options.create ());
@@ -319,7 +325,9 @@ void LatestVersionCheckerAndUpdater::askUserAboutNewVersion (const String& newVe
319325 const String& releaseNotes,
320326 const Asset& asset)
321327{
322- dialogWindow = UpdateDialog::launchDialog (newVersionString, releaseNotes);
328+ dialogWindow = UpdateDialog::launchDialog (newVersionString,
329+ releaseNotes,
330+ mainWindow->automaticVersionChecking );
323331
324332 if (auto * mm = ModalComponentManager::getInstance ())
325333 {
@@ -328,6 +336,10 @@ void LatestVersionCheckerAndUpdater::askUserAboutNewVersion (const String& newVe
328336 {
329337 if (result == 1 )
330338 askUserForLocationToDownload (asset);
339+ else if (result == -1 )
340+ mainWindow->automaticVersionChecking = false ;
341+ else if (result == 0 )
342+ mainWindow->automaticVersionChecking = true ;
331343
332344 dialogWindow.reset ();
333345 }));
0 commit comments