NEW:support for launching studio from the model web

Change-Id: I931fc8633c057228441daf2ab4c9c37f97e898ab
This commit is contained in:
tao wang 2023-03-13 16:41:17 +08:00 committed by Lane.Wei
parent 6f141ea740
commit 7481da52d6
7 changed files with 78 additions and 124 deletions

View file

@ -170,7 +170,7 @@ void ProjectPanel::OnScriptMessage(wxWebViewEvent& evt)
wxString accessory_path = j["accessory_path"];
if (!accessory_path.empty()) {
std::string decode_path = url_decode(accessory_path.ToStdString());
std::string decode_path = wxGetApp().url_decode(accessory_path.ToStdString());
fs::path path(decode_path);
if (fs::exists(path)) {
@ -352,36 +352,6 @@ void ProjectPanel::RunScript(std::string content)
WebView::RunScript(m_browser, content);
}
char ProjectPanel::from_hex(char ch) {
return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
}
std::string ProjectPanel::url_decode(string text) {
char h;
ostringstream escaped;
escaped.fill('0');
for (auto i = text.begin(), n = text.end(); i != n; ++i) {
string::value_type c = (*i);
if (c == '%') {
if (i[1] && i[2]) {
h = from_hex(i[1]) << 4 | from_hex(i[2]);
escaped << h;
i += 2;
}
}
else if (c == '+') {
escaped << ' ';
}
else {
escaped << c;
}
}
return escaped.str();
}
bool ProjectPanel::Show(bool show)
{
if (show) update_model_data();