AppConfig: Support for vendor / model / variant enable state

This commit is contained in:
Vojtech Kral 2018-03-28 11:36:36 +02:00
parent 3fcf194e39
commit 57e47a3296
12 changed files with 267 additions and 142 deletions

View file

@ -70,6 +70,8 @@ our $grey = Wx::Colour->new(200,200,200);
our $LANGUAGE_CHANGE_EVENT = Wx::NewEventType;
# 2) To inform about a change of Preferences.
our $PREFERENCES_EVENT = Wx::NewEventType;
# To inform AppConfig about Slic3r version available online
our $VERSION_ONLINE_EVENT = Wx::NewEventType;
sub OnInit {
my ($self) = @_;
@ -101,7 +103,9 @@ sub OnInit {
$self->{app_config}->set('version', $Slic3r::VERSION);
$self->{app_config}->save;
my $slic3r_update_avail = $self->{app_config}->get("version_check") && $self->{app_config}->get("version_online") != $Slic3r::VERSION;
# my $version_check = $self->{app_config}->get('version_check');
$self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config});
my $slic3r_update = $self->{app_config}->slic3r_update_avail;
Slic3r::GUI::set_app_config($self->{app_config});
Slic3r::GUI::load_language();
@ -140,15 +144,17 @@ sub OnInit {
# On OSX the UI was not initialized correctly if the wizard was called
# before the UI was up and running.
$self->CallAfter(sub {
if ($slic3r_update_avail) {
# XXX: recreate_GUI ???
if ($slic3r_update) {
# TODO
} elsif ($run_wizard) {
}
# XXX: ?
if ($run_wizard) {
# Run the config wizard, don't offer the "reset user profile" checkbox.
$self->{mainframe}->config_wizard(1);
}
# XXX: recreate_GUI ???
Slic3r::PresetUpdater::download($self->{app_config}, $self->{preset_bundle});
$self->{preset_updater}->download($self->{preset_bundle});
});
# The following event is emited by the C++ menu implementation of application language change.
@ -161,6 +167,14 @@ sub OnInit {
$self->update_ui_from_settings;
});
# The following event is emited by PresetUpdater (C++)
EVT_COMMAND($self, -1, $VERSION_ONLINE_EVENT, sub {
my ($self, $event) = @_;
my $version = $event->GetString;
$self->{app_config}->set('version_online', $version);
$self->{app_config}->save;
});
return 1;
}