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"))
{
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
{
doc_name = m[2].str();
doc_dir = m[1].str();
doc_path = path;
canvas->reset_camera();
layers->clear();
canvas->m_canvas->project_open(path, [this](bool success){
// on complete
if (success)
{
title_update();
for (int layer_index = 0; layer_index < canvas->m_canvas->m_layers.size(); layer_index++)
auto open_action = [this, path, m] {
doc_name = m[2].str();
doc_dir = m[1].str();
doc_path = path;
canvas->reset_camera();
layers->clear();
canvas->m_canvas->project_open(path, [this](bool success){
// on complete
if (success)
{
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);
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);
l->m_visibility->set_value(canvas->m_canvas->m_layers[layer_index]->m_visible);
}
}
}
else
{
message_box("Open Document Error",
"There was an error opening the document.\n"
"It may be inaccessible or corrupted.");
}
});
ActionManager::clear();
else
{
message_box("Open Document Error",
"There was an error opening the document.\n"
"It may be inaccessible or corrupted.");
}
});
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.descr = dialog->txt_descr->m_text;
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__
App::I->pick_file_save("ppbr",
[this, dialog, info] (std::string path) {

View File

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