Skip to content

Commit 7b90be1

Browse files
committed
Refactor AutoUpdater alerts to use asynchronous calls and update font styles
1 parent 548f2a4 commit 7b90be1

1 file changed

Lines changed: 29 additions & 18 deletions

File tree

Source/AutoUpdater.cpp

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ void LatestVersionCheckerAndUpdater::run()
125125
if (latestVer.compareNatural (CoreServices::getGUIVersion()) <= 0)
126126
{
127127
if (! backgroundCheck)
128-
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
129-
"No Newer Version Available",
130-
"You are running the latest available version of the Open Ephys GUI.");
128+
{
129+
MessageManager::callAsync ([]
130+
{
131+
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
132+
"No Newer Version Available",
133+
"You are running the latest available version of the Open Ephys GUI.");
134+
});
135+
}
131136
return;
132137
}
133138

@@ -180,9 +185,14 @@ void LatestVersionCheckerAndUpdater::run()
180185
}
181186

182187
if (! backgroundCheck)
183-
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
184-
"Failed to find any new downloads",
185-
"Please try again in a few minutes.");
188+
{
189+
MessageManager::callAsync ([]
190+
{
191+
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
192+
"Failed to find any new downloads",
193+
"Please try again in a few minutes.");
194+
});
195+
}
186196
}
187197

188198
//==============================================================================
@@ -192,19 +202,20 @@ class UpdateDialog : public Component
192202
UpdateDialog (const String& newVersion, const String& releaseNotes, bool automaticVerCheck)
193203
{
194204
titleLabel.setText ("Open Ephys GUI version " + newVersion, dontSendNotification);
195-
titleLabel.setFont (FontOptions ("Fira Sans", "SemiBold", 18.0f));
205+
titleLabel.setFont (FontOptions ("Inter", "Semi Bold", 18.0f));
196206
titleLabel.setJustificationType (Justification::centred);
197207
addAndMakeVisible (titleLabel);
198208

199209
contentLabel.setText ("A newer version of Open Ephys GUI is available - would you like to download it?", dontSendNotification);
200-
contentLabel.setFont (FontOptions ("Fira Sans", "Regular", 16.0f));
201-
contentLabel.setJustificationType (Justification::topLeft);
210+
contentLabel.setFont (FontOptions ("Inter", "Regular", 16.0f));
211+
contentLabel.setJustificationType (Justification::centredTop);
202212
contentLabel.setMinimumHorizontalScale (1.0);
203213
addAndMakeVisible (contentLabel);
204214

205215
releaseNotesEditor.setMultiLine (true);
206216
releaseNotesEditor.setReadOnly (true);
207217
releaseNotesEditor.setText (releaseNotes);
218+
releaseNotesEditor.setScrollBarThickness (10);
208219
addAndMakeVisible (releaseNotesEditor);
209220

210221
addAndMakeVisible (downloadButton);
@@ -228,7 +239,7 @@ class UpdateDialog : public Component
228239
#else
229240
File iconDir = File::getSpecialLocation (File::currentApplicationFile).getParentDirectory();
230241
#endif
231-
juceIcon = Drawable::createFromImageFile (iconDir.getChildFile ("icon-small.png"));
242+
openEphysIcon = Drawable::createFromImageFile (iconDir.getChildFile ("icon-small.png"));
232243
lookAndFeelChanged();
233244

234245
setSize (640, 480);
@@ -238,8 +249,8 @@ class UpdateDialog : public Component
238249
{
239250
auto b = getLocalBounds().reduced (10);
240251

241-
auto topSlice = b.removeFromTop (juceIconBounds.getHeight())
242-
.withTrimmedLeft (juceIconBounds.getWidth());
252+
auto topSlice = b.removeFromTop (openEphysIconBounds.getHeight())
253+
.withTrimmedLeft (openEphysIconBounds.getWidth());
243254

244255
titleLabel.setBounds (topSlice.removeFromTop (25));
245256
topSlice.removeFromTop (5);
@@ -256,10 +267,10 @@ class UpdateDialog : public Component
256267

257268
void paint (Graphics& g) override
258269
{
259-
g.fillAll (Colours::lightgrey);
270+
g.fillAll (findColour (ThemeColours::componentBackground));
260271

261-
if (juceIcon != nullptr)
262-
juceIcon->drawWithin (g, juceIconBounds.toFloat(), RectanglePlacement::stretchToFit, 1.0f);
272+
if (openEphysIcon != nullptr)
273+
openEphysIcon->drawWithin (g, openEphysIconBounds.toFloat(), RectanglePlacement::stretchToFit, 1.0f);
263274
}
264275

265276
static std::unique_ptr<DialogWindow> launchDialog (const String& newVersionString,
@@ -286,7 +297,7 @@ class UpdateDialog : public Component
286297
void lookAndFeelChanged() override
287298
{
288299
cancelButton.setColour (TextButton::buttonColourId, Colours::crimson);
289-
releaseNotesEditor.applyFontToAllText (FontOptions ("Fira Sans", "Regular", 16.0f));
300+
releaseNotesEditor.applyFontToAllText (FontOptions ("Inter", "Regular", 16.0f));
290301
}
291302

292303
void setParentWindow (DialogWindow* parent)
@@ -304,8 +315,8 @@ class UpdateDialog : public Component
304315
TextEditor releaseNotesEditor;
305316
TextButton downloadButton { "Download" }, cancelButton { "Cancel" };
306317
ToggleButton dontAskAgainButton { "Don't ask again" };
307-
std::unique_ptr<Drawable> juceIcon;
308-
juce::Rectangle<int> juceIconBounds { 10, 10, 64, 64 };
318+
std::unique_ptr<Drawable> openEphysIcon;
319+
juce::Rectangle<int> openEphysIconBounds { 10, 10, 64, 64 };
309320

310321
DialogWindow* parentWindow = nullptr;
311322
};

0 commit comments

Comments
 (0)