Skip to content

Commit 6dd1a90

Browse files
committed
feat: add preference to disable daily tips after slicing (#3142)
Users had no way to permanently turn off the daily tips panel that appears in the slicing notification. Add a 'Show daily tips after slicing' checkbox to Preferences. When unchecked: - DailyTipsWindow::open() returns early without showing tips - SlicingProgressNotification skips the separator + tips panel, collapsing the notification to its compact progress-only height Config key: show_daily_tips (default: enabled) Closes #3142
1 parent 7b7b27a commit 6dd1a90

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/slic3r/GUI/DailyTips.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ DailyTipsWindow::DailyTipsWindow()
614614

615615
void DailyTipsWindow::open()
616616
{
617+
if (wxGetApp().app_config && wxGetApp().app_config->get("show_daily_tips") == "false")
618+
return;
617619
m_show = true;
618620
m_panel->retrieve_data_from_hint_database(HintDataNavigation::Curr);
619621
}

src/slic3r/GUI/Preferences.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,11 +1592,11 @@ void PreferencesDialog::create_gui_page()
15921592

15931593
auto title_index_and_tip = create_item_title(_L("Home page and daily tips"), page, _L("Home page and daily tips"));
15941594
auto item_home_page = create_item_checkbox(_L("Show home page on startup"), page, _L("Show home page on startup"), 50, "show_home_page");
1595-
//auto item_daily_tip = create_item_checkbox(_L("Show daily tip on startup"), page, _L("Show daily tip on startup"), 50, "show_daily_tips");
1595+
auto item_daily_tip = create_item_checkbox(_L("Show daily tips after slicing"), page, _L("If enabled, daily tips are shown in the slicing notification panel after slicing completes."), 50, "show_daily_tips");
15961596

15971597
sizer_page->Add(title_index_and_tip, 0, wxTOP, 26);
15981598
sizer_page->Add(item_home_page, 0, wxTOP, 6);
1599-
//sizer_page->Add(item_daily_tip, 0, wxTOP, 6);
1599+
sizer_page->Add(item_daily_tip, 0, wxTOP, 6);
16001600

16011601
page->SetSizer(sizer_page);
16021602
page->Layout();

src/slic3r/GUI/SlicingProgressNotification.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,20 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
219219
//if (m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_COMPLETED || m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_CANCELLED)
220220
// m_window_width = m_line_height * 25;
221221
const ImVec2 progress_child_window_padding = ImVec2(15.f, 0.f) * scale;
222-
const ImVec2 dailytips_child_window_padding = m_dailytips_panel->is_expanded() ? ImVec2(15.f, 10.f) * scale : ImVec2(15.f, 0.f) * scale;
222+
const bool show_daily_tips = !wxGetApp().app_config || wxGetApp().app_config->get("show_daily_tips") != "false";
223+
const ImVec2 dailytips_child_window_padding = (show_daily_tips && m_dailytips_panel->is_expanded()) ? ImVec2(15.f, 10.f) * scale : ImVec2(15.f, 0.f) * scale;
223224
const ImVec2 bottom_padding = ImVec2(0.f, 0.f) * scale;
224225
const float progress_panel_width = (m_window_width - 2 * progress_child_window_padding.x);
225226
const float progress_panel_height = (58.0f * scale);
226227
const float dailytips_panel_width = (m_window_width - 2 * dailytips_child_window_padding.x);
227228
const float gcodeviewer_height = wxGetApp().plater()->get_preview_canvas3D()->get_gcode_viewer().get_legend_height();
228229
//const float dailytips_panel_height = std::min(380.0f * scale, std::max(90.0f, (cnv_size.get_height() - gcodeviewer_height - progress_panel_height - dailytips_child_window_padding.y - initial_y - m_line_height * 4)));
229-
const float dailytips_panel_height = 380.0f * scale;
230+
const float dailytips_panel_height = show_daily_tips ? 380.0f * scale : 0.f;
230231

231232
float right_gap = right_margin + (move_from_overlay ? overlay_width + m_line_height * 5 : 0);
232233
m_window_pos = ImVec2((float)cnv_size.get_width() - right_gap - m_window_width, (float)cnv_size.get_height() - m_top_y);
233234
imgui.set_next_window_pos(m_window_pos.x, m_window_pos.y, ImGuiCond_Always, 0.0f, 0.0f);
234-
m_window_height = progress_panel_height + m_dailytips_panel->get_size().y + progress_child_window_padding.y + dailytips_child_window_padding.y + bottom_padding.y;
235+
m_window_height = progress_panel_height + (show_daily_tips ? m_dailytips_panel->get_size().y : 0.f) + progress_child_window_padding.y + dailytips_child_window_padding.y + bottom_padding.y;
235236
m_top_y = initial_y + m_window_height;
236237
ImGui::SetNextWindowSizeConstraints(ImVec2(m_window_width, m_window_height), ImVec2(m_window_width, m_window_height));
237238

@@ -287,22 +288,24 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
287288
}
288289
ImGui::EndChild();
289290

290-
// Separator Line
291-
ImVec2 separator_min = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x, ImGui::GetCursorScreenPos().y);
292-
ImVec2 separator_max = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x + progress_panel_width, ImGui::GetCursorScreenPos().y);
293-
ImGui::GetCurrentWindow()->DrawList->AddLine(separator_min, separator_max, ImColor(238, 238, 238, (int)(255 * m_current_fade_opacity)));
294-
295-
child_name = "##DailyTipsPanel" + std::to_string(parent_window->ID);
296-
ImVec2 dailytips_pos = ImGui::GetCursorScreenPos() + dailytips_child_window_padding;
297-
ImVec2 dailytips_size = ImVec2(dailytips_panel_width, dailytips_panel_height);
298-
m_dailytips_panel->set_position(dailytips_pos);
299-
m_dailytips_panel->set_size(dailytips_size);
300-
m_dailytips_panel->set_fade_opacity(m_current_fade_opacity);
301-
ImGui::SetNextWindowPos(dailytips_pos);
302-
if (ImGui::BeginChild(child_name.c_str(), ImVec2(dailytips_panel_width, dailytips_panel_height), false, child_window_flags)) {
303-
render_dailytips_panel(dailytips_pos, dailytips_size);
291+
if (show_daily_tips) {
292+
// Separator Line
293+
ImVec2 separator_min = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x, ImGui::GetCursorScreenPos().y);
294+
ImVec2 separator_max = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x + progress_panel_width, ImGui::GetCursorScreenPos().y);
295+
ImGui::GetCurrentWindow()->DrawList->AddLine(separator_min, separator_max, ImColor(238, 238, 238, (int)(255 * m_current_fade_opacity)));
296+
297+
child_name = "##DailyTipsPanel" + std::to_string(parent_window->ID);
298+
ImVec2 dailytips_pos = ImGui::GetCursorScreenPos() + dailytips_child_window_padding;
299+
ImVec2 dailytips_size = ImVec2(dailytips_panel_width, dailytips_panel_height);
300+
m_dailytips_panel->set_position(dailytips_pos);
301+
m_dailytips_panel->set_size(dailytips_size);
302+
m_dailytips_panel->set_fade_opacity(m_current_fade_opacity);
303+
ImGui::SetNextWindowPos(dailytips_pos);
304+
if (ImGui::BeginChild(child_name.c_str(), ImVec2(dailytips_panel_width, dailytips_panel_height), false, child_window_flags)) {
305+
render_dailytips_panel(dailytips_pos, dailytips_size);
306+
}
307+
ImGui::EndChild();
304308
}
305-
ImGui::EndChild();
306309
}
307310

308311
if (ImGui::IsMouseHoveringRect(ImGui::GetWindowPos(), ImGui::GetWindowPos() + ImGui::GetWindowSize(), true)) {

0 commit comments

Comments
 (0)