Hints notifications: OS specific tags

This commit is contained in:
David Kocik 2021-08-10 15:25:25 +02:00
parent cf32b56454
commit 0e6d77d25a
2 changed files with 42 additions and 3 deletions

View File

@ -43,7 +43,8 @@
# Each notification can have disabled and enabled modes and techs - divided by ; and space
# enabled_tags = ...
# disabled_tags = ...
# supported tags are: simple; advanced; expert; FFF; MMU; SLA
# supported tags are: simple; advanced; expert; FFF; MMU; SLA; Windows; Linux; OSX;
# Tags are case sensitive.
# FFF is affirmative for both one or more extruder printers.
# Algorithm shows hint only if ALL enabled tags are affirmative. (so never do enabled_tags = FFF; SLA;)
# Algorithm shows hint only if not in all disabled tags.
@ -206,6 +207,7 @@ documentation_link = https://help.prusa3d.com/en/article/infill-patterns_177130
[hint:Fullscreen mode]
text = Fullscreen mode\nDid you know that you can switch PrusaSlicer to fullscreen mode? Use the <b>F11</b> hotkey.
enabled_tags = Windows
[hint:Simplify mesh]
text = Simplify mesh\nDid you know that you can reduce the number of triangles in a mesh using the Simplify mesh feature? Right-click the model and select Simplify model. Read more in the documentation.

View File

@ -68,6 +68,34 @@ inline TagCheckResult tag_check_tech(const std::string& tag)
return TagCheckNotCompatible;
}
inline TagCheckResult tag_check_system(const std::string& tag)
{
std::vector<std::string> allowed_tags = { "Windows", "Linux", "OSX" };
if (std::find(allowed_tags.begin(), allowed_tags.end(), tag) != allowed_tags.end()) {
if (tag =="Windows")
#ifdef WIN32
return TagCheckAffirmative;
#else
return TagCheckNegative;
#endif // WIN32
if (tag == "Linux")
#ifdef __linux__
return TagCheckAffirmative;
#else
return TagCheckNegative;
#endif // __linux__
if (tag == "OSX")
#ifdef __APPLE__
return TagCheckAffirmative;
#else
return TagCheckNegative;
#endif // __apple__
}
return TagCheckNotCompatible;
}
// return true if NOT in disabled mode.
inline bool tags_check(const std::string& disabled_tags, const std::string& enabled_tags)
{
@ -93,6 +121,11 @@ inline bool tags_check(const std::string& disabled_tags, const std::string& enab
if (result == TagCheckResult::TagCheckAffirmative)
continue;
result = tag_check_tech(tag);
if (result == TagCheckResult::TagCheckNegative)
return false;
if (result == TagCheckResult::TagCheckAffirmative)
continue;
result = tag_check_system(tag);
if (result == TagCheckResult::TagCheckNegative)
return false;
if (result == TagCheckResult::TagCheckAffirmative)
@ -128,6 +161,11 @@ inline bool tags_check(const std::string& disabled_tags, const std::string& enab
continue;
if (result == TagCheckResult::TagCheckAffirmative)
return false;
result = tag_check_system(tag);
if (result == TagCheckResult::TagCheckAffirmative)
return false;
if (result == TagCheckResult::TagCheckNegative)
continue;
BOOST_LOG_TRIVIAL(error) << "Hint Notification: Tag " << tag << " in disabled_tags not compatible.";
}
}
@ -655,8 +693,7 @@ void NotificationManager::HintNotification::render_preferences_button(ImGuiWrapp
//hover
if (ImGui::IsMouseHoveringRect(ImVec2(win_pos_x - m_window_width / 15.f, win_pos_y + m_window_height - 1.75f * m_line_height),
ImVec2(win_pos_x, win_pos_y + m_window_height),
true))
{
true)) {
button_text = ImGui::PreferencesHoverButton;
// tooltip
long time_now = wxGetLocalTime();