confirm dialog when opening from shell

This commit is contained in:
2019-09-23 12:29:25 +02:00
parent c0b57b6662
commit 3f28fd9229
3 changed files with 52 additions and 24 deletions

View File

@@ -57,34 +57,60 @@ void App::open_document(std::string path)
if (str_iequals(m[3].str(), "abr")) if (str_iequals(m[3].str(), "abr"))
{ {
std::thread(&NodePanelBrushPreset::import_abr, presets, path).detach(); auto mb = message_box("Import ABR", "Would you like to import the brushes?", true);
mb->on_submit = [this, path] (Node* target) {
std::thread(&NodePanelBrushPreset::import_abr, presets, path).detach();
target->destroy();
};
}
else if (str_iequals(m[3].str(), "ppbr"))
{
auto mb = message_box("Import PPBR", "Would you like to import the brushes?", true);
mb->on_submit = [this, path] (Node* target) {
std::thread(&NodePanelBrushPreset::import_ppbr, presets, path).detach();
target->destroy();
};
} }
else else
{ {
doc_name = m[2].str(); auto open_action = [this, path, m] {
doc_dir = m[1].str(); doc_name = m[2].str();
doc_path = path; doc_dir = m[1].str();
canvas->reset_camera(); doc_path = path;
layers->clear(); canvas->reset_camera();
canvas->m_canvas->project_open(path, [this](bool success){ layers->clear();
// on complete canvas->m_canvas->project_open(path, [this](bool success){
if (success) // on complete
{ if (success)
title_update();
for (int layer_index = 0; layer_index < canvas->m_canvas->m_layers.size(); layer_index++)
{ {
auto l = layers->add_layer(canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false); title_update();
l->m_visibility->set_value(canvas->m_canvas->m_layers[layer_index]->m_visible); for (int layer_index = 0; layer_index < canvas->m_canvas->m_layers.size(); layer_index++)
{
auto l = layers->add_layer(canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false);
l->m_visibility->set_value(canvas->m_canvas->m_layers[layer_index]->m_visible);
}
} }
} else
else {
{ message_box("Open Document Error",
message_box("Open Document Error", "There was an error opening the document.\n"
"There was an error opening the document.\n" "It may be inaccessible or corrupted.");
"It may be inaccessible or corrupted."); }
} });
}); ActionManager::clear();
ActionManager::clear(); };
if (!Canvas::I->m_unsaved)
{
open_action();
}
else
{
auto mb = message_box("Unsaved document", "Do you want to close the unsaved document before opening the file?", true);
mb->on_submit = [this, open_action] (Node* target) {
open_action();
target->destroy();
};
}
} }
} }

View File

@@ -606,7 +606,8 @@ void App::dialog_ppbr_export()
info.email = dialog->txt_email->m_text; info.email = dialog->txt_email->m_text;
info.descr = dialog->txt_descr->m_text; info.descr = dialog->txt_descr->m_text;
info.header_image = dialog->m_header_image; info.header_image = dialog->m_header_image;
info.export_data = dialog->export_check->checked; if (dialog->export_check)
info.export_data = dialog->export_check->checked;
#if __IOS__ #if __IOS__
App::I->pick_file_save("ppbr", App::I->pick_file_save("ppbr",
[this, dialog, info] (std::string path) { [this, dialog, info] (std::string path) {

View File

@@ -3,6 +3,7 @@
#ifdef __APPLE__ #ifdef __APPLE__
#define LOG(M,...) { printf(M"\n", ##__VA_ARGS__); LogRemote::I.log(M, ##__VA_ARGS__); } #define LOG(M,...) { printf(M"\n", ##__VA_ARGS__); LogRemote::I.log(M, ##__VA_ARGS__); }
#define LOGW
#elif __ANDROID__ #elif __ANDROID__
#define LOG(...) { ((void)__android_log_print(ANDROID_LOG_INFO, "PanoPainterCPP", __VA_ARGS__)); LogRemote::I.log(__VA_ARGS__); } #define LOG(...) { ((void)__android_log_print(ANDROID_LOG_INFO, "PanoPainterCPP", __VA_ARGS__)); LogRemote::I.log(__VA_ARGS__); }
#define LOGW #define LOGW