single file cloud upload
This commit is contained in:
@@ -501,7 +501,7 @@
|
|||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="file-cloud-upload" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-cloud-upload" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="weather_clouds" width="20"/>
|
<icon icon="weather_clouds" width="20"/>
|
||||||
<text text="Cloud Upload All" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="Cloud Upload" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="file-cloud-browse" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-cloud-browse" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="weather_clouds" width="20"/>
|
<icon icon="weather_clouds" width="20"/>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void App::download(std::string filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::upload(std::string filename)
|
void App::upload(std::string filename, std::string name)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
|
|
||||||
@@ -100,7 +100,8 @@ void App::upload(std::string filename)
|
|||||||
|
|
||||||
if (curl)
|
if (curl)
|
||||||
{
|
{
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "http://omigamedev.ddns.net:8080/panoview/upl.php");
|
std::string url = "http://omigamedev.ddns.net:8080/panoview/cloud-upl.php?name=" + name;
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||||
|
|||||||
@@ -121,14 +121,16 @@ public:
|
|||||||
void init_menu_layer();
|
void init_menu_layer();
|
||||||
void dialog_newdoc();
|
void dialog_newdoc();
|
||||||
void dialog_save();
|
void dialog_save();
|
||||||
|
void dialog_save_ver();
|
||||||
void dialog_open();
|
void dialog_open();
|
||||||
void dialog_browse();
|
void dialog_browse();
|
||||||
void dialog_export();
|
void dialog_export();
|
||||||
void dialog_layer_rename();
|
void dialog_layer_rename();
|
||||||
|
|
||||||
|
void cloud_upload();
|
||||||
void cloud_upload_all();
|
void cloud_upload_all();
|
||||||
void cloud_browse();
|
void cloud_browse();
|
||||||
void upload(std::string filename);
|
void upload(std::string filename, std::string name = "");
|
||||||
void download(std::string filename);
|
void download(std::string filename);
|
||||||
|
|
||||||
void brush_update();
|
void brush_update();
|
||||||
|
|||||||
@@ -6,6 +6,39 @@
|
|||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
void App::cloud_upload()
|
||||||
|
{
|
||||||
|
if (!canvas)
|
||||||
|
return;
|
||||||
|
if (doc_name.empty())
|
||||||
|
{
|
||||||
|
auto msgbox = new NodeMessageBox();
|
||||||
|
msgbox->m_manager = &layout;
|
||||||
|
msgbox->init();
|
||||||
|
msgbox->m_title->set_text("Warning");
|
||||||
|
msgbox->m_message->set_text("This document needs to be saved before upload.");
|
||||||
|
layout[main_id]->add_child(msgbox);
|
||||||
|
layout[main_id]->update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::thread([this] {
|
||||||
|
std::string path = data_path + "/" + doc_name + ".pano";
|
||||||
|
Canvas::I->project_save_thread(path);
|
||||||
|
upload(path);
|
||||||
|
async_start();
|
||||||
|
auto msgbox = new NodeMessageBox();
|
||||||
|
msgbox->m_manager = &layout;
|
||||||
|
msgbox->init();
|
||||||
|
msgbox->m_title->set_text("Success");
|
||||||
|
msgbox->m_message->set_text("This document has been succesfully uploaded.");
|
||||||
|
layout[main_id]->add_child(msgbox);
|
||||||
|
layout[main_id]->update();
|
||||||
|
async_end();
|
||||||
|
}).detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void App::cloud_upload_all()
|
void App::cloud_upload_all()
|
||||||
{
|
{
|
||||||
std::thread([] {
|
std::thread([] {
|
||||||
|
|||||||
@@ -133,6 +133,36 @@ void App::dialog_browse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::dialog_save_ver()
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
void App::dialog_save()
|
void App::dialog_save()
|
||||||
{
|
{
|
||||||
if (canvas)
|
if (canvas)
|
||||||
|
|||||||
@@ -383,39 +383,7 @@ void App::init_menu_file()
|
|||||||
popup->destroy();
|
popup->destroy();
|
||||||
};
|
};
|
||||||
popup->find<NodeButtonCustom>("file-save-ver")->on_click = [this](Node*) {
|
popup->find<NodeButtonCustom>("file-save-ver")->on_click = [this](Node*) {
|
||||||
if (doc_name.empty())
|
doc_name.empty() ? dialog_save() : dialog_save_ver();
|
||||||
{
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
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->mouse_release();
|
||||||
popup->destroy();
|
popup->destroy();
|
||||||
};
|
};
|
||||||
@@ -425,7 +393,7 @@ void App::init_menu_file()
|
|||||||
popup->destroy();
|
popup->destroy();
|
||||||
};
|
};
|
||||||
popup->find<NodeButtonCustom>("file-cloud-upload")->on_click = [this](Node*) {
|
popup->find<NodeButtonCustom>("file-cloud-upload")->on_click = [this](Node*) {
|
||||||
cloud_upload_all();
|
cloud_upload();
|
||||||
popup->mouse_release();
|
popup->mouse_release();
|
||||||
popup->destroy();
|
popup->destroy();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user