diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index eeb5b6ac5..c50021e2e 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -133,6 +133,21 @@ void Snapshot::load_ini(const std::string &path) } } +static std::string reason_string(const Snapshot::Reason reason) +{ + switch (reason) { + case Snapshot::SNAPSHOT_UPGRADE: + return "upgrade"; + case Snapshot::SNAPSHOT_DOWNGRADE: + return "downgrade"; + case Snapshot::SNAPSHOT_USER: + return "user"; + case Snapshot::SNAPSHOT_UNKNOWN: + default: + return "unknown"; + } +} + void Snapshot::save_ini(const std::string &path) { boost::nowide::ofstream c; @@ -145,7 +160,7 @@ void Snapshot::save_ini(const std::string &path) c << "time_captured = " << Slic3r::Utils::format_time_ISO8601Z(this->time_captured) << std::endl; c << "slic3r_version_captured = " << this->slic3r_version_captured.to_string() << std::endl; c << "comment = " << this->comment << std::endl; - c << "reason = " << this->reason << std::endl; + c << "reason = " << reason_string(this->reason) << std::endl; // Export the active presets at the time of the snapshot. c << std::endl << "[presets]" << std::endl; @@ -294,6 +309,11 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: Snapshot::VendorConfig cfg; cfg.name = vendor.first; cfg.models_variants_installed = vendor.second; + for (auto it = cfg.models_variants_installed.begin(); it != cfg.models_variants_installed.end();) + if (it->second.empty()) + cfg.models_variants_installed.erase(it ++); + else + ++ it; // Read the active config bundle, parse the config version. PresetBundle bundle; bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index a7b8a5aa5..8f27027a4 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -57,6 +57,8 @@ public: std::string comment; Reason reason; + std::string format_reason() const; + // Active presets at the time of the snapshot. std::string print; std::vector filaments; diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 730b97a32..5bc8b1012 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -8,6 +8,21 @@ namespace Slic3r { namespace GUI { +static std::string format_reason(const Config::Snapshot::Reason reason) +{ + switch (reason) { + case Config::Snapshot::SNAPSHOT_UPGRADE: + return std::string(_(L("Upgrade"))); + case Config::Snapshot::SNAPSHOT_DOWNGRADE: + return std::string(_(L("Downgrade"))); + case Config::Snapshot::SNAPSHOT_USER: + return std::string(_(L("User"))); + case Config::Snapshot::SNAPSHOT_UNKNOWN: + default: + return std::string(_(L("Unknown"))); + } +} + static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even) { // Start by declaring a row with an alternating background color. @@ -15,11 +30,15 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ text += row_even ? "#FFFFFF" : "#C0C0C0"; text += "\">"; text += ""; -// text += _(L("ID:")) + " " + snapshot.id + "
"; - text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; - text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; + // Format the row header. + text += std::string("") + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason); if (! snapshot.comment.empty()) - text += _(L("user comment:")) + " " + snapshot.comment + "
"; + text += " (" + snapshot.comment + ")"; + text += "

"; + // End of row header. +// text += _(L("ID:")) + " " + snapshot.id + "
"; + // text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; + text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; // text += "reason: " + snapshot.reason + "
"; text += "print: " + snapshot.print + "
"; text += "filaments: " + snapshot.filaments.front() + "
"; @@ -79,9 +98,9 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db { wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ - int size[] = {8,8,8,8,8,8,8}; + int size[] = {8,8,8,8,11,11,11}; #else - int size[] = {11,11,11,11,11,11,11}; + int size[] = {11,11,11,11,14,14,14}; #endif html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); html->SetBorders(2);