Add progress indicator for background template download

This commit is contained in:
kobewi
2026-03-21 17:49:09 +01:00
parent b0c1084a10
commit 3c112db63a
4 changed files with 69 additions and 9 deletions
+18 -9
View File
@@ -42,6 +42,7 @@
#include "editor/export/editor_export_preset.h"
#include "editor/file_system/editor_file_system.h"
#include "editor/file_system/editor_paths.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/progress_dialog.h"
#include "editor/settings/editor_settings.h"
@@ -213,6 +214,11 @@ void ExportTemplateManager::_download_template(const String &p_url, bool p_skip_
set_process(true);
_set_current_progress_status(TTR("Connecting to the mirror..."));
ProgressIndicator *indicator = EditorNode::get_bottom_panel()->get_progress_indicator();
indicator->set_tooltip_text(TTRC("Downloading export templates..."));
indicator->set_value(0);
indicator->show();
}
void ExportTemplateManager::_download_template_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
@@ -259,6 +265,7 @@ void ExportTemplateManager::_download_template_completed(int p_status, int p_cod
} break;
}
EditorNode::get_bottom_panel()->get_progress_indicator()->hide();
set_process(false);
}
@@ -421,6 +428,9 @@ void ExportTemplateManager::_set_current_progress_status(const String &p_status,
}
void ExportTemplateManager::_set_current_progress_value(float p_value, const String &p_status) {
if (!is_visible()) {
return;
}
download_progress_bar->show();
download_progress_bar->set_indeterminate(false);
download_progress_bar->set_value(p_value);
@@ -929,6 +939,10 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
void ExportTemplateManager::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
EditorNode::get_bottom_panel()->get_progress_indicator()->connect("clicked", callable_mp(this, &ExportTemplateManager::popup_manager));
} break;
case NOTIFICATION_THEME_CHANGED: {
current_value->add_theme_font_override(SceneStringName(font), get_theme_font(SNAME("main"), EditorStringName(EditorFonts)));
current_missing_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
@@ -937,14 +951,6 @@ void ExportTemplateManager::_notification(int p_what) {
mirror_options_button->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
set_process(false);
} else if (is_visible() && is_downloading_templates) {
set_process(true);
}
} break;
case NOTIFICATION_PROCESS: {
update_countdown -= get_process_delta_time();
if (update_countdown > 0) {
@@ -959,7 +965,9 @@ void ExportTemplateManager::_notification(int p_what) {
if (downloaded_bytes >= 0) {
if (total_bytes > 0) {
_set_current_progress_value(float(downloaded_bytes) / total_bytes, status);
float progress = float(downloaded_bytes) / total_bytes;
EditorNode::get_bottom_panel()->get_progress_indicator()->set_value(progress);
_set_current_progress_value(progress, status);
} else {
_set_current_progress_value(0, status);
}
@@ -968,6 +976,7 @@ void ExportTemplateManager::_notification(int p_what) {
}
if (!success) {
EditorNode::get_bottom_panel()->get_progress_indicator()->hide();
set_process(false);
}
} break;