Improvement of the snapshot dialog, fixed storing of the snapshot "reason"
field.
This commit is contained in:
parent
aaa8f133c0
commit
9ab38f416d
3 changed files with 48 additions and 7 deletions
xs/src/slic3r
|
@ -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)
|
void Snapshot::save_ini(const std::string &path)
|
||||||
{
|
{
|
||||||
boost::nowide::ofstream c;
|
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 << "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 << "slic3r_version_captured = " << this->slic3r_version_captured.to_string() << std::endl;
|
||||||
c << "comment = " << this->comment << 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.
|
// Export the active presets at the time of the snapshot.
|
||||||
c << std::endl << "[presets]" << std::endl;
|
c << std::endl << "[presets]" << std::endl;
|
||||||
|
@ -294,6 +309,11 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot:
|
||||||
Snapshot::VendorConfig cfg;
|
Snapshot::VendorConfig cfg;
|
||||||
cfg.name = vendor.first;
|
cfg.name = vendor.first;
|
||||||
cfg.models_variants_installed = vendor.second;
|
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.
|
// Read the active config bundle, parse the config version.
|
||||||
PresetBundle bundle;
|
PresetBundle bundle;
|
||||||
bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY);
|
bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY);
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
std::string comment;
|
std::string comment;
|
||||||
Reason reason;
|
Reason reason;
|
||||||
|
|
||||||
|
std::string format_reason() const;
|
||||||
|
|
||||||
// Active presets at the time of the snapshot.
|
// Active presets at the time of the snapshot.
|
||||||
std::string print;
|
std::string print;
|
||||||
std::vector<std::string> filaments;
|
std::vector<std::string> filaments;
|
||||||
|
|
|
@ -8,6 +8,21 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
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)
|
static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even)
|
||||||
{
|
{
|
||||||
// Start by declaring a row with an alternating background color.
|
// 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 += row_even ? "#FFFFFF" : "#C0C0C0";
|
||||||
text += "\">";
|
text += "\">";
|
||||||
text += "<td>";
|
text += "<td>";
|
||||||
// text += _(L("ID:")) + " " + snapshot.id + "<br>";
|
// Format the row header.
|
||||||
text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "<br>";
|
text += std::string("<font size=\"5\"><b>") + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason);
|
||||||
text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "<br>";
|
|
||||||
if (! snapshot.comment.empty())
|
if (! snapshot.comment.empty())
|
||||||
text += _(L("user comment:")) + " " + snapshot.comment + "<br>";
|
text += " (" + snapshot.comment + ")";
|
||||||
|
text += "</b></font><br>";
|
||||||
|
// End of row header.
|
||||||
|
// text += _(L("ID:")) + " " + snapshot.id + "<br>";
|
||||||
|
// text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "<br>";
|
||||||
|
text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "<br>";
|
||||||
// text += "reason: " + snapshot.reason + "<br>";
|
// text += "reason: " + snapshot.reason + "<br>";
|
||||||
text += "print: " + snapshot.print + "<br>";
|
text += "print: " + snapshot.print + "<br>";
|
||||||
text += "filaments: " + snapshot.filaments.front() + "<br>";
|
text += "filaments: " + snapshot.filaments.front() + "<br>";
|
||||||
|
@ -79,9 +98,9 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
|
||||||
{
|
{
|
||||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
int size[] = {8,8,8,8,8,8,8};
|
int size[] = {8,8,8,8,11,11,11};
|
||||||
#else
|
#else
|
||||||
int size[] = {11,11,11,11,11,11,11};
|
int size[] = {11,11,11,11,14,14,14};
|
||||||
#endif
|
#endif
|
||||||
html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
||||||
html->SetBorders(2);
|
html->SetBorders(2);
|
||||||
|
|
Loading…
Add table
Reference in a new issue