add more checks on unsaved documents
This commit is contained in:
@@ -19,8 +19,8 @@ std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
|
|||||||
|
|
||||||
void App::dialog_newdoc()
|
void App::dialog_newdoc()
|
||||||
{
|
{
|
||||||
if (canvas)
|
auto show_dialog = [this] {
|
||||||
{
|
async_start();
|
||||||
auto dialog = std::make_shared<NodeDialogNewDoc>();
|
auto dialog = std::make_shared<NodeDialogNewDoc>();
|
||||||
dialog->m_manager = &layout;
|
dialog->m_manager = &layout;
|
||||||
dialog->init();
|
dialog->init();
|
||||||
@@ -83,13 +83,40 @@ void App::dialog_newdoc()
|
|||||||
dialog->destroy();
|
dialog->destroy();
|
||||||
App::I.hideKeyboard();
|
App::I.hideKeyboard();
|
||||||
};
|
};
|
||||||
|
async_end();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
if (ui::Canvas::I->m_unsaved)
|
||||||
|
{
|
||||||
|
auto m = layout[main_id]->add_child<NodeMessageBox>();
|
||||||
|
m->m_title->set_text("Unsaved document");
|
||||||
|
m->m_message->set_text("Would you like to save this document before closing?");
|
||||||
|
m->btn_ok->m_text->set_text("Yes");
|
||||||
|
m->btn_cancel->m_text->set_text("No");
|
||||||
|
m->btn_ok->on_click = [this, m, show_dialog](Node*) {
|
||||||
|
ui::Canvas::I->project_save([this, m, show_dialog] {
|
||||||
|
show_dialog();
|
||||||
|
});
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
m->btn_cancel->on_click = [this, m, show_dialog](Node*) {
|
||||||
|
show_dialog();
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_dialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::dialog_open()
|
void App::dialog_open()
|
||||||
{
|
{
|
||||||
if (canvas)
|
auto show_dialog = [this] {
|
||||||
{
|
async_start();
|
||||||
// load thumbnail test
|
// load thumbnail test
|
||||||
auto dialog = std::make_shared<NodeDialogOpen>();
|
auto dialog = std::make_shared<NodeDialogOpen>();
|
||||||
dialog->m_manager = &layout;
|
dialog->m_manager = &layout;
|
||||||
@@ -117,13 +144,40 @@ void App::dialog_open()
|
|||||||
dialog->destroy();
|
dialog->destroy();
|
||||||
ActionManager::clear();
|
ActionManager::clear();
|
||||||
};
|
};
|
||||||
|
async_end();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
if (ui::Canvas::I->m_unsaved)
|
||||||
|
{
|
||||||
|
auto m = layout[main_id]->add_child<NodeMessageBox>();
|
||||||
|
m->m_title->set_text("Unsaved document");
|
||||||
|
m->m_message->set_text("Would you like to save this document before closing?");
|
||||||
|
m->btn_ok->m_text->set_text("Yes");
|
||||||
|
m->btn_cancel->m_text->set_text("No");
|
||||||
|
m->btn_ok->on_click = [this,m,show_dialog](Node*){
|
||||||
|
ui::Canvas::I->project_save([this,m,show_dialog] {
|
||||||
|
show_dialog();
|
||||||
|
});
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
m->btn_cancel->on_click = [this,m,show_dialog](Node*) {
|
||||||
|
show_dialog();
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_dialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::dialog_browse()
|
void App::dialog_browse()
|
||||||
{
|
{
|
||||||
if (canvas)
|
auto show_dialog = [this] {
|
||||||
{
|
async_start();
|
||||||
// load thumbnail test
|
// load thumbnail test
|
||||||
auto dialog = std::make_shared<NodeDialogBrowse>();
|
auto dialog = std::make_shared<NodeDialogBrowse>();
|
||||||
dialog->m_manager = &layout;
|
dialog->m_manager = &layout;
|
||||||
@@ -151,6 +205,33 @@ void App::dialog_browse()
|
|||||||
dialog->destroy();
|
dialog->destroy();
|
||||||
ActionManager::clear();
|
ActionManager::clear();
|
||||||
};
|
};
|
||||||
|
async_end();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
if (ui::Canvas::I->m_unsaved)
|
||||||
|
{
|
||||||
|
auto m = layout[main_id]->add_child<NodeMessageBox>();
|
||||||
|
m->m_title->set_text("Unsaved document");
|
||||||
|
m->m_message->set_text("Would you like to save this document before closing?");
|
||||||
|
m->btn_ok->m_text->set_text("Yes");
|
||||||
|
m->btn_cancel->m_text->set_text("No");
|
||||||
|
m->btn_ok->on_click = [this, m, show_dialog](Node*) {
|
||||||
|
ui::Canvas::I->project_save([this, m, show_dialog] {
|
||||||
|
show_dialog();
|
||||||
|
});
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
m->btn_cancel->on_click = [this, m, show_dialog](Node*) {
|
||||||
|
show_dialog();
|
||||||
|
m->destroy();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_dialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1357,17 +1357,40 @@ void ui::Canvas::export_cubes(std::string data_path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui::Canvas::project_save(std::string file_path)
|
void ui::Canvas::project_save(std::function<void()> on_complete)
|
||||||
{
|
{
|
||||||
if (!App::I.check_license())
|
if (App::I.check_license())
|
||||||
return;
|
{
|
||||||
std::thread t(&ui::Canvas::project_save_thread, this, file_path);
|
std::thread t([=] {
|
||||||
|
project_save_thread(App::I.data_path + "/" + App::I.doc_name + ".pano");
|
||||||
|
if (on_complete)
|
||||||
|
on_complete();
|
||||||
|
});
|
||||||
t.detach();
|
t.detach();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui::Canvas::project_save(std::string file_path, std::function<void()> on_complete)
|
||||||
|
{
|
||||||
|
if (App::I.check_license())
|
||||||
|
{
|
||||||
|
std::thread t([=] {
|
||||||
|
project_save_thread(file_path);
|
||||||
|
if (on_complete)
|
||||||
|
on_complete();
|
||||||
|
});
|
||||||
|
t.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ui::Canvas::project_save_thread(std::string file_path)
|
void ui::Canvas::project_save_thread(std::string file_path)
|
||||||
{
|
{
|
||||||
gl_state gl;
|
gl_state gl;
|
||||||
|
|
||||||
|
// already saved, nothing to do
|
||||||
|
if (!m_unsaved)
|
||||||
|
return;
|
||||||
|
|
||||||
// static char name[128];
|
// static char name[128];
|
||||||
// sprintf(name, "%s/latlong.pano", data_path.c_str());
|
// sprintf(name, "%s/latlong.pano", data_path.c_str());
|
||||||
FILE* fp = fopen(file_path.c_str(), "wb");
|
FILE* fp = fopen(file_path.c_str(), "wb");
|
||||||
|
|||||||
@@ -144,7 +144,8 @@ public:
|
|||||||
void export_equirectangular_thread(std::string file_path);
|
void export_equirectangular_thread(std::string file_path);
|
||||||
void export_anim(std::string data_path);
|
void export_anim(std::string data_path);
|
||||||
void export_cubes(std::string data_path);
|
void export_cubes(std::string data_path);
|
||||||
void project_save(std::string file_path);
|
void project_save(std::function<void()> on_complete = nullptr);
|
||||||
|
void project_save(std::string file_path, std::function<void()> on_complete = nullptr);
|
||||||
void project_save_thread(std::string file_path);
|
void project_save_thread(std::string file_path);
|
||||||
void project_open(std::string file_path, std::function<void()> on_complete = nullptr);
|
void project_open(std::string file_path, std::function<void()> on_complete = nullptr);
|
||||||
void project_open_thread(std::string file_path);
|
void project_open_thread(std::string file_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user