diff --git a/data/layout.xml b/data/layout.xml index 971240d..4831214 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -672,7 +672,7 @@ --> - + diff --git a/src/app_cloud.cpp b/src/app_cloud.cpp index fafa57b..9c2933d 100644 --- a/src/app_cloud.cpp +++ b/src/app_cloud.cpp @@ -22,7 +22,7 @@ void App::cloud_upload() } else { - std::thread([this] { + auto upload_thread = [this] { std::string path = data_path + "/" + doc_name + ".ppi"; if (ui::Canvas::I->m_unsaved) { @@ -52,7 +52,25 @@ void App::cloud_upload() layout[main_id]->update(); async_redraw(); async_end(); - }).detach(); + }; + + auto m = layout[main_id]->add_child(); + m->m_title->set_text("Publish document"); + m->m_message->set_text("Would you like to upload this document to the public domain?"); + m->btn_ok->m_text->set_text("Yes"); + m->btn_cancel->m_text->set_text("No"); + m->btn_ok->on_click = [this, m, upload_thread](Node*) { + std::thread(upload_thread).detach(); + async_start(); + m->destroy(); + async_end(); + }; + m->btn_cancel->on_click = [this, m, upload_thread](Node*) { + async_start(); + m->destroy(); + async_end(); + }; + } } diff --git a/src/canvas.cpp b/src/canvas.cpp index c75ba1a..a1f9380 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -1613,13 +1613,14 @@ void ui::Canvas::project_save_thread(std::string file_path) // App::I.upload(data_path); // LOG("uploaded"); + m_unsaved = false; + m_newdoc = false; + App::I.async_start(); pb->destroy(); App::I.title_update(); App::I.async_update(); App::I.async_end(); - m_unsaved = false; - m_newdoc = false; } void ui::Canvas::project_open(std::string file_path, std::function on_complete) @@ -1756,6 +1757,8 @@ void ui::Canvas::project_open_thread(std::string file_path) fclose(fp); LOG("project restore from %s", file_path.c_str()); + m_unsaved = false; + m_newdoc = false; if (App::I.layout.m_loaded) { App::I.async_start(); @@ -1766,8 +1769,6 @@ void ui::Canvas::project_open_thread(std::string file_path) App::I.title_update(); App::I.async_end(); } - m_unsaved = false; - m_newdoc = false; } ui::Image ui::Canvas::thumbnail_generate(int w, int h) diff --git a/src/node_dialog_browse.cpp b/src/node_dialog_browse.cpp index cdd41a9..d8b3161 100644 --- a/src/node_dialog_browse.cpp +++ b/src/node_dialog_browse.cpp @@ -83,7 +83,7 @@ void NodeDialogBrowse::init_controls() return; selected_path = target->m_path; selected_file = target->m_file_name; - selected_name = selected_file.substr(0, selected_file.length() - 5); + selected_name = selected_file.substr(0, selected_file.length() - strlen(".ppi")); if (current) current->m_selected = false; current = target; diff --git a/src/node_dialog_cloud.cpp b/src/node_dialog_cloud.cpp index 7e45854..e5db967 100644 --- a/src/node_dialog_cloud.cpp +++ b/src/node_dialog_cloud.cpp @@ -105,7 +105,7 @@ void NodeDialogCloud::load_thumbs_thread() return; selected_path = target->m_path; selected_file = target->m_file_name; - selected_name = selected_file.substr(0, selected_file.length() - 5); + selected_name = selected_file.substr(0, selected_file.length() - strlen(".ppi")); if (current) current->m_selected = false; current = target; diff --git a/src/node_dialog_open.cpp b/src/node_dialog_open.cpp index 49214af..237020d 100644 --- a/src/node_dialog_open.cpp +++ b/src/node_dialog_open.cpp @@ -87,7 +87,7 @@ void NodeDialogOpen::init_controls() image_tex->tex.create(thumb); selected_path = target->m_path; selected_file = target->m_file_name; - selected_name = selected_file.substr(0, selected_file.length() - 5); + selected_name = selected_file.substr(0, selected_file.length() - strlen(".ppi")); if (current) current->m_selected = false; current = target;