Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Use OS taskbar progress when `ProgressDialog` is shown

chocola-minte6814ac0c587
diff --git a/editor/gui/progress_dialog.cpp b/editor/gui/progress_dialog.cpp
index de137375758..fa271b71da2 100644
--- a/editor/gui/progress_dialog.cpp
+++ b/editor/gui/progress_dialog.cpp
@@ -132,6 +132,17 @@ ProgressDialog *ProgressDialog::singleton = nullptr;
void ProgressDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ Window *base_window = get_window();
+ if (base_window) {
+ base_window->set_taskbar_progress_value(0.0);
+ if (is_visible()) {
+ base_window->set_taskbar_progress_state(DisplayServerEnums::PROGRESS_STATE_NORMAL);
+ } else {
+ base_window->set_taskbar_progress_state(DisplayServerEnums::PROGRESS_STATE_NOPROGRESS);
+ }
+ }
+ } break;
case NOTIFICATION_THEME_CHANGED: {
Ref<StyleBox> style = main->get_theme_stylebox(SceneStringName(panel), SNAME("PopupMenu"));
main_border_size = style->get_minimum_size();
@@ -243,6 +254,11 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
t.progress->set_value(p_step);
}
+ Window *base_window = get_window();
+ if (base_window) {
+ base_window->set_taskbar_progress_value(t.progress->get_as_ratio());
+ }
+
t.state->set_text(p_state);
t.last_progress_tick = OS::get_singleton()->get_ticks_usec();
_update_ui();