Merge pull request #83290 from trollodel/move_progress_dialog_on_open
Keep focus on floating window when showing ProgressDialog
This commit is contained in:
commit
d89c5313a5
|
@ -147,6 +147,13 @@ void ProgressDialog::_popup() {
|
||||||
main->set_offset(SIDE_BOTTOM, -style->get_margin(SIDE_BOTTOM));
|
main->set_offset(SIDE_BOTTOM, -style->get_margin(SIDE_BOTTOM));
|
||||||
|
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
|
for (Window *window : host_windows) {
|
||||||
|
if (window->has_focus()) {
|
||||||
|
popup_exclusive_centered(window, ms);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No host window found, use main window.
|
||||||
EditorInterface::get_singleton()->popup_dialog_centered(this, ms);
|
EditorInterface::get_singleton()->popup_dialog_centered(this, ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,6 +233,11 @@ void ProgressDialog::end_task(const String &p_task) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgressDialog::add_host_window(Window *p_window) {
|
||||||
|
ERR_FAIL_NULL(p_window);
|
||||||
|
host_windows.push_back(p_window);
|
||||||
|
}
|
||||||
|
|
||||||
void ProgressDialog::_cancel_pressed() {
|
void ProgressDialog::_cancel_pressed() {
|
||||||
canceled = true;
|
canceled = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,8 @@ class ProgressDialog : public PopupPanel {
|
||||||
VBoxContainer *main = nullptr;
|
VBoxContainer *main = nullptr;
|
||||||
uint64_t last_progress_tick;
|
uint64_t last_progress_tick;
|
||||||
|
|
||||||
|
LocalVector<Window *> host_windows;
|
||||||
|
|
||||||
static ProgressDialog *singleton;
|
static ProgressDialog *singleton;
|
||||||
void _popup();
|
void _popup();
|
||||||
|
|
||||||
|
@ -96,6 +98,8 @@ public:
|
||||||
bool task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_redraw = true);
|
bool task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_redraw = true);
|
||||||
void end_task(const String &p_task);
|
void end_task(const String &p_task);
|
||||||
|
|
||||||
|
void add_host_window(Window *p_window);
|
||||||
|
|
||||||
ProgressDialog();
|
ProgressDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/editor_string_names.h"
|
#include "editor/editor_string_names.h"
|
||||||
|
#include "editor/progress_dialog.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/label.h"
|
#include "scene/gui/label.h"
|
||||||
#include "scene/gui/panel.h"
|
#include "scene/gui/panel.h"
|
||||||
|
@ -332,6 +333,8 @@ WindowWrapper::WindowWrapper() {
|
||||||
window_background = memnew(Panel);
|
window_background = memnew(Panel);
|
||||||
window_background->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
|
window_background->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
|
||||||
window->add_child(window_background);
|
window->add_child(window_background);
|
||||||
|
|
||||||
|
ProgressDialog::get_singleton()->add_host_window(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScreenSelect
|
// ScreenSelect
|
||||||
|
|
Loading…
Reference in New Issue