implement save as, save version and file existence check on save
This commit is contained in:
@@ -366,10 +366,59 @@ void App::init_menu_file()
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-save")->on_click = [this](Node*) {
|
||||
if (doc_name.empty())
|
||||
{
|
||||
dialog_save();
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas->m_canvas->project_save(data_path + "/" + doc_name + ".pano");
|
||||
}
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-save-as")->on_click = [this](Node*) {
|
||||
dialog_save();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-save-ver")->on_click = [this](Node*) {
|
||||
if (doc_name.empty())
|
||||
{
|
||||
dialog_save();
|
||||
}
|
||||
else
|
||||
{
|
||||
int current = 0;
|
||||
std::string next = doc_name + ".01";
|
||||
std::string base = doc_name;
|
||||
|
||||
std::regex r(R"((.*)\.(\w{2})$)");
|
||||
std::smatch m;
|
||||
if (std::regex_search(doc_name, m, r))
|
||||
{
|
||||
std::string base = m[1].str();
|
||||
current = atoi(m[2].str().c_str());
|
||||
}
|
||||
|
||||
for (int i = current + 1; i < 99; i++)
|
||||
{
|
||||
static char tmp_name[256];
|
||||
sprintf(tmp_name, "%s.%02d", base.c_str(), i);
|
||||
next = tmp_name;
|
||||
if (Asset::exist(data_path + "/" + next + ".pano", false))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
doc_name = next;
|
||||
if (auto docname = layout[main_id]->find<NodeText>("txt-docname"))
|
||||
docname->set_text(("Panodoc: " + doc_name).c_str());
|
||||
canvas->m_canvas->project_save(data_path + "/" + next + ".pano");
|
||||
}
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-export")->on_click = [this](Node*) {
|
||||
dialog_export();
|
||||
popup->mouse_release();
|
||||
|
||||
Reference in New Issue
Block a user