check version: now working

also update some gui to display full version
This commit is contained in:
supermerill 2020-11-17 19:00:26 +01:00
parent 657f6bbb14
commit d726b33759
9 changed files with 46 additions and 26 deletions

View File

@ -24,7 +24,7 @@ namespace Slic3r {
static const std::string VENDOR_PREFIX = "vendor:";
static const std::string MODEL_PREFIX = "model:";
static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/supermerill/superslicer/releases";
const std::string AppConfig::SECTION_FILAMENTS = "filaments";
const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
@ -61,7 +61,7 @@ void AppConfig::set_defaults()
set("freecad_path", ".");
if (get("version_check").empty())
set("version_check", "0");
set("version_check", "1");
if (get("preset_update").empty())
set("preset_update", "0");

View File

@ -4,6 +4,7 @@
#define SLIC3R_APP_NAME "@SLIC3R_APP_NAME@"
#define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@"
#define SLIC3R_VERSION "@SLIC3R_VERSION@"
#define SLIC3R_VERSION_FULL "@SLIC3R_VERSION_FULL@"
#define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@"
#endif /* __SLIC3R_VERSION_H */

View File

@ -253,7 +253,7 @@ AboutDialog::AboutDialog()
// version
{
auto version_string = _L("Version")+ " " + std::string(SLIC3R_VERSION);
auto version_string = _L("Version")+ " " + std::string(SLIC3R_VERSION_FULL);
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = GetFont();
#ifdef __WXMSW__

View File

@ -244,7 +244,7 @@ private:
#endif // ENABLE_GCODE_VIEWER
// dynamically get the version to display
version = _L("Version") + " " + std::string(SLIC3R_VERSION);
version = _L("Version") + " " + std::string(SLIC3R_VERSION_FULL);
// credits infornation
credits = title + " " + _L("is based on PrusaSlicer by Prusa and Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n\n" +
@ -806,7 +806,7 @@ bool GUI_App::on_init_inner()
}
#endif // ENABLE_GCODE_VIEWER
app_config->set("version", SLIC3R_VERSION);
app_config->set("version", SLIC3R_VERSION_FULL);
app_config->save();
wxInitAllImageHandlers();
@ -854,9 +854,9 @@ bool GUI_App::on_init_inner()
app_config->set("version_online", into_u8(evt.GetString()));
app_config->save();
if (this->plater_ != nullptr) {
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(into_u8(evt.GetString()))) {
//if (*Semver::parse(SLIC3R_VERSION_FULL) < *Semver::parse(into_u8(evt.GetString()))) {
this->plater_->get_notification_manager()->push_notification(NotificationType::NewAppAvailable, *(this->plater_->get_current_canvas3D()));
}
//}
}
});
#if ENABLE_GCODE_VIEWER

View File

@ -6,6 +6,8 @@
#include "GLCanvas3D.hpp"
#include "ImGuiWrapper.hpp"
#include "libslic3r/AppConfig.hpp"
#include "wxExtensions.hpp"
#include <boost/algorithm/string.hpp>
@ -626,7 +628,7 @@ bool NotificationManager::PopNotification::on_text_click()
wxPostEvent(m_evt_handler, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED));
break;
case NotificationType::NewAppAvailable:
wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases");
wxLaunchDefaultBrowser("https://github.com/supermerill/SuperSlicer/releases/tag/" + Slic3r::GUI::get_app_config()->get("version_online"));
break;
default:
break;

View File

@ -39,7 +39,7 @@ std::string get_main_info(bool format_as_html)
#else
out << b_start << SLIC3R_APP_NAME << b_end << line_end;
#endif // ENABLE_GCODE_VIEWER
out << b_start << "Version: " << b_end << SLIC3R_VERSION << line_end;
out << b_start << "Version: " << b_end << SLIC3R_VERSION_FULL << line_end;
#if ENABLE_GCODE_VIEWER
out << b_start << "Build: " << b_end << (wxGetApp().is_editor() ? SLIC3R_BUILD_ID : GCODEVIEWER_BUILD_ID) << line_end;
#else

View File

@ -37,7 +37,7 @@ static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Prus
MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online)
: MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of %s is available")), SLIC3R_APP_NAME))
{
const bool dev_version = ver_online.prerelease() != nullptr;
const bool dev_version = true;// ver_online.prerelease() != nullptr; // SuperSlicer is always a dev version
auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING);
versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:"))));
@ -222,7 +222,7 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map<std::string, w
text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text);
auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This %s version: %s")), SLIC3R_APP_NAME, SLIC3R_VERSION));
auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This %s version: %s")), SLIC3R_APP_NAME, SLIC3R_VERSION_FULL));
text2->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text2);
content_sizer->AddSpacer(VERT_SPACING);

View File

@ -246,7 +246,6 @@ void PresetUpdater::priv::sync_version() const
BOOST_LOG_TRIVIAL(info) << format("Downloading %1% online version from: `%2%`", SLIC3R_APP_NAME, version_check_url);
Http::get(version_check_url)
.size_limit(SLIC3R_VERSION_BODY_MAX)
.on_progress([this](Http::Progress, bool &cancel) {
cancel = this->cancel;
})
@ -258,21 +257,38 @@ void PresetUpdater::priv::sync_version() const
error);
})
.on_complete([&](std::string body, unsigned /* http_status */) {
boost::trim(body);
const auto nl_pos = body.find_first_of("\n\r");
if (nl_pos != std::string::npos) {
body.resize(nl_pos);
boost::property_tree::ptree root;
std::stringstream json_stream(body);
boost::property_tree::read_json(json_stream, root);
bool i_am_pre = false;
std::string best_pre = "1";
std::string best_release = "1";
std::string best_pre_url;
std::string best_release_url;
for (auto json_version : root) {
std::string tag = json_version.second.get<std::string>("tag_name");
if (SLIC3R_VERSION_FULL == tag)
i_am_pre = json_version.second.get<bool>("prerelease");
if (json_version.second.get<bool>("prerelease")) {
if (best_pre < tag) {
best_pre = tag;
best_pre_url = json_version.second.get<std::string>("html_url");
}
} else {
if (best_release < tag) {
best_release = tag;
best_release_url = json_version.second.get<std::string>("html_url");
}
}
}
if (! Semver::parse(body)) {
BOOST_LOG_TRIVIAL(warning) << format("Received invalid contents from `%1%`: Not a correct semver: `%2%`", SLIC3R_APP_NAME, body);
if ((i_am_pre ? best_pre : best_release) <= SLIC3R_VERSION_FULL)
return;
}
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, body);
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, i_am_pre? best_pre:best_release);
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString(GUI::from_u8(body));
evt->SetString(i_am_pre ? best_pre : best_release);
GUI::wxGetApp().QueueEvent(evt);
})
.perform_sync();

View File

@ -4,6 +4,7 @@
set(SLIC3R_APP_NAME "SuperSlicer")
set(SLIC3R_APP_KEY "SuperSlicer")
set(SLIC3R_VERSION "2.3.55")
set(SLIC3R_BUILD_ID "SuperSlicer_${SLIC3R_RC_VERSION}")
set(SLIC3R_VERSION_FULL "2.3.55.1")
set(SLIC3R_BUILD_ID "SuperSlicer_${SLIC3R_VERSION_FULL}")
set(SLIC3R_RC_VERSION "2,3,55,1")
set(SLIC3R_RC_VERSION_DOTS "2.3.55.1")
set(SLIC3R_RC_VERSION_DOTS "${SLIC3R_VERSION_FULL}")