No new version available notification
This commit is contained in:
parent
ef8b9f51cf
commit
96762a2119
4 changed files with 46 additions and 1 deletions
|
@ -1249,7 +1249,7 @@ bool GUI_App::on_init_inner()
|
|||
std::string evt_string = into_u8(evt.GetString());
|
||||
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(evt_string)) {
|
||||
auto notif_type = (evt_string.find("beta") != std::string::npos ? NotificationType::NewBetaAvailable : NotificationType::NewAlphaAvailable);
|
||||
this->plater_->get_notification_manager()->push_notification( notif_type
|
||||
this->plater_->get_notification_manager()->push_version_notification( notif_type
|
||||
, NotificationManager::NotificationLevel::ImportantNotificationLevel
|
||||
, Slic3r::format(_u8L("New prerelease version %1% is available."), evt_string)
|
||||
, _u8L("See Releases page.")
|
||||
|
@ -3300,6 +3300,19 @@ void GUI_App::on_version_read(wxCommandEvent& evt)
|
|||
return;
|
||||
}
|
||||
if (*Semver::parse(SLIC3R_VERSION) >= *Semver::parse(into_u8(evt.GetString()))) {
|
||||
if (m_app_updater->get_triggered_by_user())
|
||||
{
|
||||
std::string text = (*Semver::parse(into_u8(evt.GetString())) == Semver())
|
||||
? Slic3r::format(_u8L("Check for application update has failed."))
|
||||
: Slic3r::format(_u8L("No new version is available. Latest release version is %1%."), evt.GetString());
|
||||
|
||||
this->plater_->get_notification_manager()->push_version_notification(NotificationType::NoNewReleaseAvailable
|
||||
, NotificationManager::NotificationLevel::RegularNotificationLevel
|
||||
, text
|
||||
, std::string()
|
||||
, std::function<bool(wxEvtHandler*)>()
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// notification
|
||||
|
|
|
@ -2246,6 +2246,29 @@ void NotificationManager::push_simplify_suggestion_notification(const std::stri
|
|||
notification->object_id = object_id;
|
||||
push_notification_data(std::move(notification), 0);
|
||||
}
|
||||
void NotificationManager::push_version_notification(NotificationType type, NotificationLevel level, const std::string& text, const std::string& hypertext, std::function<bool(wxEvtHandler*)> callback)
|
||||
{
|
||||
assert (type == NotificationType::NewAlphaAvailable
|
||||
|| type == NotificationType::NewBetaAvailable
|
||||
|| type == NotificationType::NoNewReleaseAvailable);
|
||||
|
||||
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications) {
|
||||
// NoNewReleaseAvailable must not show if alfa / beta is on.
|
||||
NotificationType nttype = notification->get_type();
|
||||
if (type == NotificationType::NoNewReleaseAvailable
|
||||
&& (notification->get_type() == NotificationType::NewAlphaAvailable
|
||||
|| notification->get_type() == NotificationType::NewBetaAvailable)) {
|
||||
return;
|
||||
}
|
||||
// NoNewReleaseAvailable must close if alfa / beta is being push.
|
||||
if (notification->get_type() == NotificationType::NoNewReleaseAvailable
|
||||
&& (type == NotificationType::NewAlphaAvailable
|
||||
|| type == NotificationType::NewBetaAvailable)) {
|
||||
notification->close();
|
||||
}
|
||||
}
|
||||
push_notification(type, level, text, hypertext, callback);
|
||||
}
|
||||
void NotificationManager::close_notification_of_type(const NotificationType type)
|
||||
{
|
||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
||||
|
|
|
@ -56,6 +56,7 @@ enum class NotificationType
|
|||
// Like NewAppAvailable but with text and link for alpha / bet release
|
||||
NewAlphaAvailable,
|
||||
NewBetaAvailable,
|
||||
NoNewReleaseAvailable,
|
||||
// Notification on the start of PrusaSlicer, when updates of system profiles are detected.
|
||||
// Contains a hyperlink to execute installation of the new system profiles.
|
||||
PresetUpdateAvailable,
|
||||
|
@ -191,6 +192,9 @@ public:
|
|||
// Object warning with ObjectID, closes when object is deleted. ID used is of object not print like in slicing warning.
|
||||
void push_simplify_suggestion_notification(const std::string& text, ObjectID object_id, const std::string& hypertext = "",
|
||||
std::function<bool(wxEvtHandler*)> callback = std::function<bool(wxEvtHandler*)>());
|
||||
// Could be either NewAlphaAvailable, NewBetaAvailable or NoNewReleaseAvailable - this function only makes sure only 1 is visible.
|
||||
void push_version_notification(NotificationType type, NotificationLevel level, const std::string& text, const std::string& hypertext,
|
||||
std::function<bool(wxEvtHandler*)> callback);
|
||||
// Close object warnings, whose ObjectID is not in the list.
|
||||
// living_oids is expected to be sorted.
|
||||
void remove_simplify_suggestion_of_released_objects(const std::vector<ObjectID>& living_oids);
|
||||
|
|
|
@ -323,6 +323,11 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
|||
return;
|
||||
#endif // 0
|
||||
BOOST_LOG_TRIVIAL(error) << "Could not find property tree in version file. Checking for application update has failed.";
|
||||
// Lets send event with current version, this way if user triggered this check, it will notify him about no new version online.
|
||||
std::string version = Semver().to_string();
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
||||
evt->SetString(GUI::from_u8(version));
|
||||
GUI::wxGetApp().QueueEvent(evt);
|
||||
return;
|
||||
}
|
||||
std::string tree_string = body.substr(start);
|
||||
|
|
Loading…
Reference in a new issue