From c884f3b213981b89d7f76a6532e961477705727c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 17:11:56 +0200 Subject: [PATCH] Display app update notification with the main frame --- lib/Slic3r/GUI.pm | 11 ++--------- xs/src/slic3r/Utils/PresetUpdater.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 5ff8fdde1..10375a9dc 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -102,18 +102,13 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; - # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT); Slic3r::GUI::set_preset_updater($self->{preset_updater}); - eval { - $self->{preset_updater}->slic3r_update_notify(); - $self->{preset_updater}->config_update(); - }; + eval { $self->{preset_updater}->config_update(); }; if ($@) { warn $@ . "\n"; fatal_error(undef, $@); } - # my $slic3r_update = $self->{app_config}->slic3r_update_avail; Slic3r::GUI::load_language(); @@ -139,7 +134,6 @@ sub OnInit { ); $self->SetTopWindow($frame); - #EVT_IDLE($frame, sub { EVT_IDLE($self->{mainframe}, sub { while (my $cb = shift @cb) { $cb->(); @@ -151,8 +145,7 @@ sub OnInit { # before the UI was up and running. $self->CallAfter(sub { Slic3r::GUI::config_wizard_startup($app_conf_exists); - - # TODO: call periodically? + $self->{preset_updater}->slic3r_update_notify(); $self->{preset_updater}->sync($self->{preset_bundle}); }); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 439a619c6..2140a2c91 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -86,7 +86,7 @@ struct UpdateNotification : wxDialog sizer->Add(link); sizer->AddSpacer(2*SPACING); - cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new versions any more"))); + cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more"))); sizer->Add(cbox); sizer->AddSpacer(SPACING); @@ -136,6 +136,7 @@ struct PresetUpdater::priv bool enabled_version_check; bool enabled_config_update; std::string version_check_url; + bool had_config_update; fs::path cache_path; fs::path rsrc_path; @@ -159,6 +160,7 @@ struct PresetUpdater::priv PresetUpdater::priv::priv(int version_online_event) : version_online_event(version_online_event), + had_config_update(false), cache_path(fs::path(Slic3r::data_dir()) / "cache"), rsrc_path(fs::path(resources_dir()) / "profiles"), vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), @@ -401,7 +403,8 @@ void PresetUpdater::sync(PresetBundle *preset_bundle) void PresetUpdater::slic3r_update_notify() { - if (! p->enabled_version_check) { return; } + if (! p->enabled_version_check || p->had_config_update) { return; } + // ^ We don't want to bother the user with updates multiple times, put off till next time. auto* app_config = GUI::get_app_config(); const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); @@ -450,6 +453,8 @@ void PresetUpdater::config_update() const // User gave clearance, updates are go p->perform_updates(std::move(updates)); } + + p->had_config_update = true; } }